Skip to content

Commit

Permalink
document default prowjob preset behavior
Browse files Browse the repository at this point in the history
Specifically

- added an example to the prowjob docs
- linked to the way we use it for GOPROXY in k8s-specific job docs
- added unit tests for presets
- since we use it for env vars, added a unit test to confirm env vars
  will conflict
  • Loading branch information
spiffxp committed Aug 17, 2019
1 parent 30835d8 commit 7790a33
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/jobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ files here. eg:
kubernetes e2e tests less susceptible to flakes
- [`preset-aws-credentials: "true"`] ensures the prowjob has AWS credentials
for kops tests in a well known location, with an env var pointint to it
- [the default preset with no labels] is used to set the `GOPROXY` env var
for all jobs by default

## Job Examples

Expand Down Expand Up @@ -227,3 +229,4 @@ bazel run //experiment/config-forker -- \
[`preset-service-account: "true"`]: https://github.com/kubernetes/test-infra/blob/f4e6553b27d9ee8b35b2f2e588ea2e18c3fa818b/prow/config.yaml#L467-L483
[`preset-pull-kubernetes-e2e: "true"`]: https://github.com/kubernetes/test-infra/blob/f4e6553b27d9ee8b35b2f2e588ea2e18c3fa818b/config/jobs/kubernetes/sig-gcp/sig-gcp-gce-config.yaml#L2-L8
[`preset-aws-credentials: "true"`]: https://github.com/kubernetes/test-infra/blob/f4e6553b27d9ee8b35b2f2e588ea2e18c3fa818b/config/jobs/kubernetes/sig-aws/sig-aws-credentials.yaml#L3-L15
[the default preset with no labels]: https://github.com/kubernetes/test-infra/blob/551edb4702e262989fe5d162a2c642c3201bf68e/prow/config.yaml#L630
52 changes: 52 additions & 0 deletions prow/config/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,19 @@ func TestMergePreset(t *testing.T) {
},
numEnv: 1,
},
{
name: "conflicting env",
jobLabels: map[string]string{"foo": "bar"},
pod: &coreapi.PodSpec{Containers: []coreapi.Container{coreapi.Container{Env: []coreapi.EnvVar{{Name: "baz"}}}}},
buildSpec: &buildapi.BuildSpec{Template: &buildapi.TemplateInstantiationSpec{Env: []coreapi.EnvVar{{Name: "baz"}}}},
presets: []Preset{
{
Labels: map[string]string{"foo": "bar"},
Env: []coreapi.EnvVar{{Name: "baz"}},
},
},
shouldError: true,
},
{
name: "one vm",
jobLabels: map[string]string{"foo": "bar"},
Expand Down Expand Up @@ -683,6 +696,45 @@ func TestMergePreset(t *testing.T) {
},
numVolMounts: 2,
},
{
name: "default preset only",
jobLabels: map[string]string{"foo": "bar"},
pod: &coreapi.PodSpec{Containers: []coreapi.Container{{}}},
buildSpec: &buildapi.BuildSpec{},
presets: []Preset{
{
Env: []coreapi.EnvVar{{Name: "baz"}},
},
},
numEnv: 1,
},
{
name: "default preset and non-matching preset",
jobLabels: map[string]string{"foo": "bar"},
pod: &coreapi.PodSpec{Containers: []coreapi.Container{{}}},
buildSpec: &buildapi.BuildSpec{},
presets: []Preset{
{
Env: []coreapi.EnvVar{{Name: "baz"}},
},
{
Labels: map[string]string{"no": "match"},
Volumes: []coreapi.Volume{{Name: "qux"}},
},
},
numEnv: 1,
},
{
name: "default presets can also conflict",
jobLabels: map[string]string{"foo": "bar"},
pod: &coreapi.PodSpec{Volumes: []coreapi.Volume{{Name: "baz"}}},
presets: []Preset{
{
Volumes: []coreapi.Volume{{Name: "baz"}},
},
},
shouldError: true,
},
}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions prow/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ presets:
- name: bar
mountPath: /etc/bar
readOnly: true
- env: # a preset with no labels is applied to all jobs
- name: BAZ
value: qux
volumes:
# etc...
volumeMounts:
# etc...
```

## Standard Triggering and Execution Behavior for Jobs
Expand Down

0 comments on commit 7790a33

Please sign in to comment.