Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genjobs: update docs, create Dockerfile, autodeploy #2163

Merged
merged 2 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ testgrid:
generate-config:
@rm -fr prow/cluster/jobs/istio/*/*.gen.yaml
@(cd prow/config/cmd; GOARCH=amd64 GOOS=linux go run generate.go write)
@$(MAKE) -C prow gen-private-jobs
@$(MAKE) -C prow/genjobs gen-private-jobs

diff-config:
@(cd prow/config/cmd; GOARCH=amd64 GOOS=linux go run generate.go diff)
Expand Down
16 changes: 8 additions & 8 deletions authentikos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@

Install using Golang:

```console
$ GO111MODULE="on" go get -u istio.io/test-infra/authentikos
```shell
GO111MODULE="on" go get -u istio.io/test-infra/authentikos
```

Install using Docker:

```console
$ docker pull gcr.io/istio-testing/authentikos:latest
```shell
docker pull gcr.io/istio-testing/authentikos:latest
```

## Usage

Run using Golang:
> Ensure `$GOPATH/bin` is on your `$PATH`; or execute `$GOPATH/bin/authentikos` directly.

```console
$ authentikos <options>
```shell
authentikos <options>
```

Run using Docker:

```console
$ docker run gcr.io/istio-testing/authentikos:latest <options>
```shell
docker run gcr.io/istio-testing/authentikos:latest <options>
```

The following is a list of supported options for `authentikos`:
Expand Down
3 changes: 0 additions & 3 deletions prow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ CLUSTER_BUILD ?= prow
CLUSTER_PRIVATE ?= prow-private
ZONE ?= us-west1-a

gen-private-jobs:
@./genjobs/gen-private-jobs.sh

update-config-dry-run: get-cluster-credentials
./recreate_prow_configmaps.py \
--job-config-dir=cluster/jobs \
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions prow/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"os"
"path"
"strings"
"testing"

"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -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")
clarketm marked this conversation as resolved.
Show resolved Hide resolved

// Presubmits may not use trusted clusters.
for _, pre := range c.AllStaticPresubmits(nil) {
Expand All @@ -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)
}
}
Expand All @@ -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)
}
}
Expand Down
8 changes: 7 additions & 1 deletion prow/config/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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
}

Expand Down
28 changes: 28 additions & 0 deletions prow/config/jobs/test-infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions prow/genjobs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.13 as build-env

WORKDIR /go/src/istio

COPY . /go/src/istio

RUN go get -d -v ./...
RUN go build -o /go/bin/genjobs /go/src/istio/prow/genjobs

FROM gcr.io/distroless/base:22bd467b41e5e656e31db347265fae118db166d9

COPY --from=build-env /go/bin/genjobs /

ENTRYPOINT ["/genjobs"]
33 changes: 33 additions & 0 deletions prow/genjobs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2019 Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PROJECT = istio-testing
HUB = gcr.io
VERSION ?= 0.0.1

.PHONY: deploy
deploy: image push

.PHONY: gen-private-jobs
gen-private-jobs:
@./gen-private-jobs.sh

.PHONY: image
image:
docker build -t "$(HUB)/$(PROJECT)/genjobs:$(VERSION)" -t "$(HUB)/$(PROJECT)/genjobs:latest" -f Dockerfile ../../

.PHONY: push
push:
docker push "$(HUB)/$(PROJECT)/genjobs:$(VERSION)"
docker push "$(HUB)/$(PROJECT)/genjobs:latest"
Loading