Skip to content

Commit 04f3163

Browse files
committed
Fix pipeline issues by multiple small changes
Pin ko version so it's known to be compatible with used go version Supply _CLOUDSDK_IMAGE variable to force alpine with docker Add _REF_NAME only if it's required
1 parent edfc66a commit 04f3163

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

ci/cloudbuild/release-and-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ steps:
6666
name: "${_CLOUDSDK_IMAGE}"
6767
args: ["./hack/prow/e2e-test.sh"]
6868
env:
69+
- "_CLOUDSDK_IMAGE=${_CLOUDSDK_IMAGE}"
6970
- "GCP_PROJECT_ID=$PROJECT_ID"
70-
- "REF_NAME=$REF_NAME"
7171
- "BUILD_ID=$BUILD_ID"
7272
- "RELEASE_BUCKET=$_RELEASE_BUCKET"
7373
- "EXPORT_BUCKET=$_EXPORT_BUCKET"

ci/cloudbuild/scheduled/reap-gke-clusters/build-image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#
1818
# ```sh
1919
# gcloud builds submit ./ci/cloudbuild/scheduled \
20-
# --config=./ci/cloudbuild/scheduled/reap-gke-clusters/cloudbuild.yaml
20+
# --config=./ci/cloudbuild/scheduled/reap-gke-clusters/build-image.yaml
2121
# ```
2222

2323
images: ["gcr.io/${PROJECT_ID}/reap-gke-clusters"]

ci/cloudbuild/test.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,31 @@ steps:
257257
echo -e "import random\n\nimport time\ntime.sleep(random.randint(30,90))" | python3
258258
done
259259
260-
gcloud builds submit \
261-
--no-source \
262-
--config=/workspace/${BUILD_ID}/fresh-cluster.yaml \
263-
--substitutions=_CLOUDSDK_COMPUTE_ZONE=$(cat /workspace/${BUILD_ID}/_CLOUDSDK_COMPUTE_ZONE),_CLOUDSDK_CONTAINER_CLUSTER=$(cat /workspace/${BUILD_ID}/_CLOUDSDK_CONTAINER_CLUSTER),_NODE_COUNT=${_NODE_COUNT},_MACHINE_TYPE=${_MACHINE_TYPE},_RELEASE_CHANNEL=${_RELEASE_CHANNEL},_REF_NAME=${_REF_NAME},_ASM_MANAGED=${_ASM_MANAGED}
260+
CONFIG_FILE="/workspace/${BUILD_ID}/fresh-cluster.yaml"
261+
262+
ZONE=$(cat "/workspace/${BUILD_ID}/_CLOUDSDK_COMPUTE_ZONE")
263+
CLUSTER=$(cat "/workspace/${BUILD_ID}/_CLOUDSDK_CONTAINER_CLUSTER")
264+
265+
VARS="_CLOUDSDK_COMPUTE_ZONE=$${ZONE}"
266+
VARS="$${VARS},_CLOUDSDK_CONTAINER_CLUSTER=$${CLUSTER}"
267+
VARS="$${VARS},_NODE_COUNT=${_NODE_COUNT}"
268+
VARS="$${VARS},_MACHINE_TYPE=${_MACHINE_TYPE}"
269+
VARS="$${VARS},_RELEASE_CHANNEL=${_RELEASE_CHANNEL}"
270+
VARS="$${VARS},_ASM_MANAGED=${_ASM_MANAGED}"
271+
272+
# Older versions of kf don't use _REF_NAME, therefore check if it exists in the config file before adding it
273+
# This is related to https://github.com/google/kf/pull/1092
274+
# The if statement below can be safely removed after two versions following v2.11.29.
275+
# The reason is that we run tests for previous releases as well. Newer versions will always have _REF_NAME.
276+
if grep -q "_REF_NAME" "$$CONFIG_FILE"; then
277+
echo "Found _REF_NAME in config, adding to substitutions..."
278+
VARS="$${VARS},_REF_NAME=${_REF_NAME}"
279+
fi
280+
281+
gcloud builds submit \
282+
--no-source \
283+
--config="$$CONFIG_FILE" \
284+
--substitutions="$$VARS"
264285
265286
if [ ! -z "${_EXTRA_CERTS_URL}" ]; then
266287
gsutil cp "${_EXTRA_CERTS_URL}" /workspace/certs.pem

cmd/generate-release/cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ substitutions:
3333
_CLOUDSDK_IMAGE: 'gcr.io/google.com/cloudsdktool/cloud-sdk:528.0.0-alpine'
3434
_GOLANG_IMAGE: 'golang:1.25'
3535
_BUILDPACK_WRAPPER_GOLANG_IMAGE: 'golang:1.17'
36-
_KO_VERSION: 'github.com/google/ko@latest'
36+
_KO_VERSION: 'github.com/google/ko@v0.18.1'
3737

3838
timeout: '1800s'
3939

hack/prow/e2e-test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ _ASM_MANAGED="${ASM_MANAGED:-false}"
2525
_RELEASE_CHANNEL="${RELEASE_CHANNEL:-REGULAR}"
2626
_SKIP_UNIT_TESTS="${SKIP_UNIT_TESTS:-true}"
2727
_EXTRA_CERTS_URL="${_EXTRA_CERTS_URL:-}"
28-
_REF_NAME="${REF_NAME:-}"
2928

3029
if ! [ -x "$(command -v jq)" ]; then
3130
apk add --update --no-cache jq
@@ -80,7 +79,7 @@ trap finish EXIT
8079
gcloud builds submit . \
8180
--project ${_GCP_PROJECT_ID} \
8281
--config=cmd/generate-release/cloudbuild.yaml \
83-
--substitutions=_RELEASE_BUCKET=${_RELEASE_BUCKET},_GIT_SHA=${git_sha},_VERSION=${release_id} \
82+
--substitutions=_RELEASE_BUCKET=${_RELEASE_BUCKET},_GIT_SHA=${git_sha},_VERSION=${release_id},_CLOUDSDK_IMAGE=${_CLOUDSDK_IMAGE} \
8483
| tee -a ./build-log.txt
8584

8685
# Run integration tests.
@@ -90,7 +89,7 @@ full_release_bucket=gs://${_RELEASE_BUCKET}/${release_id}
9089
gcloud builds submit . \
9190
--project ${_GCP_PROJECT_ID} \
9291
--config=ci/cloudbuild/test.yaml \
93-
--substitutions="_CLOUDSDK_COMPUTE_ZONE=random,_CLOUDSDK_CONTAINER_CLUSTER=${cluster_name},_NODE_COUNT=6,_FULL_RELEASE_BUCKET=${full_release_bucket},_DELETE_CLUSTER=${_DELETE_CLUSTER},_MACHINE_TYPE=n1-highmem-4,_RELEASE_CHANNEL=${_RELEASE_CHANNEL},_REF_NAME=${_REF_NAME},_SKIP_UNIT_TESTS=${_SKIP_UNIT_TESTS},_ASM_MANAGED=${_ASM_MANAGED}",_EXTRA_CERTS_URL=${_EXTRA_CERTS_URL} \
92+
--substitutions="_CLOUDSDK_COMPUTE_ZONE=random,_CLOUDSDK_CONTAINER_CLUSTER=${cluster_name},_NODE_COUNT=6,_FULL_RELEASE_BUCKET=${full_release_bucket},_DELETE_CLUSTER=${_DELETE_CLUSTER},_MACHINE_TYPE=n1-highmem-4,_RELEASE_CHANNEL=${_RELEASE_CHANNEL},_REF_NAME=${git_sha},_SKIP_UNIT_TESTS=${_SKIP_UNIT_TESTS},_ASM_MANAGED=${_ASM_MANAGED},_CLOUDSDK_IMAGE=${_CLOUDSDK_IMAGE}",_EXTRA_CERTS_URL=${_EXTRA_CERTS_URL} \
9493
| tee -a ./build-log.txt
9594

9695
# Update result to success if we reach the end, elsewise we'll report a failure

hack/prow/reap.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ _GCP_PROJECT_ID="${GCP_PROJECT_ID}"
1919

2020
cd ci/cloudbuild/scheduled/reap-gke-clusters
2121

22+
# Make sure to rebuild reap image after any modifications in following files, see build-image.yaml
23+
2224
python3 delete_im_deployments.py ${_GCP_PROJECT_ID}
2325
python3 delete_gke_clusters.py ${_GCP_PROJECT_ID}
2426
python3 cleanup_load_balancers.py ${_GCP_PROJECT_ID}

0 commit comments

Comments
 (0)