From 841c88d90eafe48b70713d2610bbf063778a50f6 Mon Sep 17 00:00:00 2001 From: Travis Clarke Date: Wed, 11 Dec 2019 10:13:03 -0800 Subject: [PATCH] Generate authentikos and genjobs image push jobs --- .../istio.test-infra.master.gen.yaml | 78 +++++++++++++++++++ prow/config/config_test.go | 7 +- prow/config/generate.go | 8 +- prow/config/jobs/test-infra.yaml | 28 +++++++ 4 files changed, 117 insertions(+), 4 deletions(-) diff --git a/prow/cluster/jobs/istio/test-infra/istio.test-infra.master.gen.yaml b/prow/cluster/jobs/istio/test-infra/istio.test-infra.master.gen.yaml index 12d7999bcb..145bfc7a03 100644 --- a/prow/cluster/jobs/istio/test-infra/istio.test-infra.master.gen.yaml +++ b/prow/cluster/jobs/istio/test-infra/istio.test-infra.master.gen.yaml @@ -82,6 +82,84 @@ postsubmits: privileged: true nodeSelector: testing: test-pool + - annotations: + testgrid-alert-email: istio-oncall@googlegroups.com + testgrid-dashboards: istio_test-infra_postsubmit + testgrid-num-failures-to-alert: "1" + branches: + - ^master$ + cluster: test-infra-trusted + decorate: true + max_concurrency: 1 + name: push-authentikos_test-infra_postsubmit + path_alias: istio.io/test-infra + run_if_changed: ^authentikos/Makefile$ + spec: + containers: + - command: + - entrypoint + - make + - -C + - authentios + - deploy + image: gcr.io/istio-testing/build-tools:master-2019-12-03T17-07-58 + name: "" + resources: + limits: + cpu: "3" + memory: 24Gi + requests: + cpu: 500m + memory: 3Gi + securityContext: + privileged: true + volumeMounts: + - mountPath: /var/lib/docker + name: docker-root + nodeSelector: + testing: test-pool + volumes: + - emptyDir: {} + name: docker-root + - annotations: + testgrid-alert-email: istio-oncall@googlegroups.com + testgrid-dashboards: istio_test-infra_postsubmit + testgrid-num-failures-to-alert: "1" + branches: + - ^master$ + cluster: test-infra-trusted + decorate: true + max_concurrency: 1 + name: push-genjobs_test-infra_postsubmit + path_alias: istio.io/test-infra + run_if_changed: ^prow/genjobs/Makefile$ + spec: + containers: + - command: + - entrypoint + - make + - -C + - prow/genjobs + - deploy + image: gcr.io/istio-testing/build-tools:master-2019-12-03T17-07-58 + name: "" + resources: + limits: + cpu: "3" + memory: 24Gi + requests: + cpu: 500m + memory: 3Gi + securityContext: + privileged: true + volumeMounts: + - mountPath: /var/lib/docker + name: docker-root + nodeSelector: + testing: test-pool + volumes: + - emptyDir: {} + name: docker-root presubmits: istio/test-infra: - always_run: true diff --git a/prow/config/config_test.go b/prow/config/config_test.go index 0e04636599..8efaf1bbec 100644 --- a/prow/config/config_test.go +++ b/prow/config/config_test.go @@ -19,6 +19,7 @@ import ( "fmt" "os" "path" + "strings" "testing" "k8s.io/apimachinery/pkg/util/sets" @@ -334,7 +335,7 @@ func TestConfig(t *testing.T) { func TestTrustedJobs(t *testing.T) { const trusted = "test-infra-trusted" - trustedPath := path.Join(*jobConfigPath, "istio", "test-infra", "istio.test-infra.trusted.master.yaml") + trustedPath := path.Join(*jobConfigPath, "istio", "test-infra") // Presubmits may not use trusted clusters. for _, pre := range c.AllStaticPresubmits(nil) { @@ -348,7 +349,7 @@ func TestTrustedJobs(t *testing.T) { if post.Cluster != trusted { continue } - if post.SourcePath != trustedPath { + if !strings.HasPrefix(post.SourcePath, trustedPath) { t.Errorf("%s defined in %s may not run in trusted cluster", post.Name, post.SourcePath) } } @@ -358,7 +359,7 @@ func TestTrustedJobs(t *testing.T) { if per.Cluster != trusted { continue } - if per.SourcePath != trustedPath { + if !strings.HasPrefix(per.SourcePath, trustedPath) { t.Errorf("%s defined in %s may not run in trusted cluster", per.Name, per.SourcePath) } } diff --git a/prow/config/generate.go b/prow/config/generate.go index 39d7b5324f..9248c4b647 100644 --- a/prow/config/generate.go +++ b/prow/config/generate.go @@ -91,6 +91,8 @@ type Job struct { Repos []string `json:"repos,omitempty"` Image string `json:"image,omitempty"` Regex string `json:"regex,omitempty"` + Cluster string `json:"cluster,omitempty"` + MaxConcurrency int `json:"max_concurrency,omitempty"` } // Reads the job yaml @@ -413,7 +415,8 @@ func createContainer(jobConfig JobConfig, job Job, resources map[string]v1.Resou func createJobBase(jobConfig JobConfig, job Job, name string, repo string, branch string, resources map[string]v1.ResourceRequirements) config.JobBase { jb := config.JobBase{ - Name: name, + Name: name, + MaxConcurrency: job.MaxConcurrency, Spec: &v1.PodSpec{ NodeSelector: map[string]string{"testing": "test-pool"}, Containers: createContainer(jobConfig, job, resources), @@ -434,6 +437,9 @@ func createJobBase(jobConfig JobConfig, job Job, name string, repo string, branc Timeout: job.Timeout, } } + if job.Cluster != "" && job.Cluster != "default" { + jb.Cluster = job.Cluster + } return jb } diff --git a/prow/config/jobs/test-infra.yaml b/prow/config/jobs/test-infra.yaml index a81efee44f..474e6d6baa 100644 --- a/prow/config/jobs/test-infra.yaml +++ b/prow/config/jobs/test-infra.yaml @@ -11,3 +11,31 @@ jobs: - name: gencheck command: [make, gen-check] + + - name: push-authentikos + type: postsubmit + regex: '^authentikos/Makefile$' + cluster: test-infra-trusted + max_concurrency: 1 + command: + - entrypoint + - make + - -C + - authentios + - deploy + requirements: + - docker + + - name: push-genjobs + type: postsubmit + regex: '^prow/genjobs/Makefile$' + cluster: test-infra-trusted + max_concurrency: 1 + command: + - entrypoint + - make + - -C + - prow/genjobs + - deploy + requirements: + - docker