Skip to content

Commit

Permalink
Merge pull request #13956 from spiffxp/doc-default-preset
Browse files Browse the repository at this point in the history
document default prowjob preset behavior
  • Loading branch information
k8s-ci-robot authored Aug 17, 2019
2 parents 551edb4 + c9b263a commit 7001522
Show file tree
Hide file tree
Showing 3 changed files with 98 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
88 changes: 88 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{{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,81 @@ 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 and matching presets",
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{"foo": "bar"},
Volumes: []coreapi.Volume{{Name: "qux"}},
},
},
numEnv: 1,
numVol: 1,
},
{
name: "default and non-matching presets",
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: "multiple default presets",
jobLabels: map[string]string{"foo": "bar"},
pod: &coreapi.PodSpec{Containers: []coreapi.Container{{}}},
buildSpec: &buildapi.BuildSpec{},
presets: []Preset{
{
Env: []coreapi.EnvVar{{Name: "baz"}},
},
{
Env: []coreapi.EnvVar{{Name: "foo"}},
},
{
Volumes: []coreapi.Volume{{Name: "qux"}},
},
},
numEnv: 2,
numVol: 1,
},
{
name: "default preset conflicts with job",
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 7001522

Please sign in to comment.