Skip to content

Commit

Permalink
Make bazel runner tolerant of periodic jobs.
Browse files Browse the repository at this point in the history
If a periodic job uses the bazelbuild image and passes an argument of
"--repo=...", it ends up getting appended to the list of repos instead
of overwriting it. This change is to make the runner detect if it's
being run in a periodic context, and if so, not add its own --repo flag.

This also reverts the attempted (failed) workaround from
kubernetes#2393.
  • Loading branch information
pipejakob committed Apr 5, 2017
1 parent cead27d commit 41bdf9f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion images/pull_kubernetes_bazel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION = 0.11
VERSION = 0.12

image:
docker build -t "gcr.io/k8s-testimages/bazelbuild:$(VERSION)" .
Expand Down
10 changes: 9 additions & 1 deletion images/pull_kubernetes_bazel/runner
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ set -o errexit
set -o nounset
set -o pipefail

# Only add the --repo flag if this image is used during a presubmit/postsubmit
# job. Periodic jobs pass --repo explicitly, which will append to the value
# (instead of overwriting it) if the runner also specifies it, which is
# generally undesired for periodic jobs.
if [ "${PULL_REFS:-}" != ":" ]; then
FLAGS=--repo="k8s.io/${REPO_NAME:-test-infra}"
fi

git clone https://github.com/kubernetes/test-infra
./test-infra/jenkins/bootstrap.py \
--repo="k8s.io/${REPO_NAME:-test-infra}" \
${FLAGS:-} \
--job=${JOB_NAME} \
--service-account=${GOOGLE_APPLICATION_CREDENTIALS} \
"$@"
28 changes: 13 additions & 15 deletions prow/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ presubmits:
- master
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.11
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--pull=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/pr-logs"
Expand Down Expand Up @@ -226,7 +226,7 @@ presubmits:
- master
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.11
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--pull=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/pr-logs"
Expand Down Expand Up @@ -400,7 +400,7 @@ presubmits:
trigger: "@k8s-bot (bazel )?test this"
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.11
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--pull=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/pr-logs"
Expand Down Expand Up @@ -490,7 +490,7 @@ postsubmits:
- master
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.11
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--branch=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/logs"
Expand Down Expand Up @@ -519,7 +519,7 @@ postsubmits:
- name: ci-kubernetes-bazel-test
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.11
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--branch=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/logs"
Expand Down Expand Up @@ -587,7 +587,7 @@ postsubmits:
- release-1.6
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.9
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--branch=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/logs"
Expand Down Expand Up @@ -616,7 +616,7 @@ postsubmits:
- name: ci-kubernetes-bazel-test-1-6
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.9
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--branch=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/logs"
Expand Down Expand Up @@ -686,7 +686,7 @@ postsubmits:
- master
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.11
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--branch=$(PULL_REFS)"
- "--upload=gs://kubernetes-jenkins/logs"
Expand Down Expand Up @@ -739,7 +739,7 @@ periodics:
interval: 1h
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.11
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--branch=master"
- "--upload=gs://kubernetes-jenkins/logs"
Expand Down Expand Up @@ -821,17 +821,16 @@ periodics:
interval: 2h
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.9
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--repo=k8s.io/kubernetes=release-1.6"
- "--upload=gs://kubernetes-jenkins/logs"
- "--git-cache=/root/.cache/git"
- "--clean"
# Bazel needs privileged mode in order to sandbox builds.
securityContext:
privileged: true
env:
- name: REPO_NAME
value: kubernetes=release-1.6
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /etc/service-account/service-account.json
volumeMounts:
Expand All @@ -851,16 +850,15 @@ periodics:
- name: periodic-kubernetes-bazel-test-1-6
spec:
containers:
- image: gcr.io/k8s-testimages/bazelbuild:0.9
- image: gcr.io/k8s-testimages/bazelbuild:0.12
args:
- "--repo=k8s.io/kubernetes=release-1.6"
- "--upload=gs://kubernetes-jenkins/logs"
- "--git-cache=/root/.cache/git"
- "--clean"
securityContext:
privileged: true
env:
- name: REPO_NAME
value: kubernetes=release-1.6
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /etc/service-account/service-account.json
volumeMounts:
Expand Down

0 comments on commit 41bdf9f

Please sign in to comment.