You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by yi...@apache.org on 2022/04/12 18:06:46 UTC
[beam] branch master updated: [BEAM-14219] Run cleanup script to remove stale prebuilt SDK container images on jenkins (#17342)
This is an automated email from the ASF dual-hosted git repository.
yichi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 73b222e7936 [BEAM-14219] Run cleanup script to remove stale prebuilt SDK container images on jenkins (#17342)
73b222e7936 is described below
commit 73b222e793610d76bfac30e3c6649c0c3a2f2a44
Author: Yichi Zhang <zy...@google.com>
AuthorDate: Tue Apr 12 11:06:39 2022 -0700
[BEAM-14219] Run cleanup script to remove stale prebuilt SDK container images on jenkins (#17342)
---
.../jenkins/job_CleanUpPrebuiltSDKImages.groovy | 44 ++++++++++++++++++++++
.test-infra/tools/build.gradle | 4 ++
.../tools/stale_dataflow_prebuilt_image_cleaner.sh | 33 ++++++++++++++++
3 files changed, 81 insertions(+)
diff --git a/.test-infra/jenkins/job_CleanUpPrebuiltSDKImages.groovy b/.test-infra/jenkins/job_CleanUpPrebuiltSDKImages.groovy
new file mode 100644
index 00000000000..083d929ba3e
--- /dev/null
+++ b/.test-infra/jenkins/job_CleanUpPrebuiltSDKImages.groovy
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import CommonJobProperties as commonJobProperties
+
+job("beam_CleanUpPrebuiltSDKImages") {
+ description("Clean up stale dataflow prebuilt sdk container images")
+
+ // Set common parameters.
+ commonJobProperties.setTopLevelMainJobProperties(delegate)
+
+ // Sets that this is a cron job, run once randomly per day.
+ commonJobProperties.setCronJob(delegate, '0 */4 * * *')
+
+ // Allows triggering this build against pull requests.
+ commonJobProperties.enablePhraseTriggeringFromPullRequest(
+ delegate,
+ 'Clean Up Prebuilt SDK Images',
+ 'Run Clean Prebuilt Images')
+
+ // Gradle goals for this job.
+ steps {
+ gradle {
+ rootBuildScriptDir(commonJobProperties.checkoutDir)
+ tasks(':beam-test-tools:removeStaleSDKContainerImages')
+ commonJobProperties.setGradleSwitches(delegate)
+ }
+ }
+}
diff --git a/.test-infra/tools/build.gradle b/.test-infra/tools/build.gradle
index 53445b62cb8..6c14213cfef 100644
--- a/.test-infra/tools/build.gradle
+++ b/.test-infra/tools/build.gradle
@@ -19,3 +19,7 @@
task cancelStaleDataflowJobs(type: Exec) {
commandLine './stale_dataflow_jobs_cleaner.sh'
}
+
+task removeStaleSDKContainerImages(type: Exec) {
+ commandLine './stale_dataflow_prebuilt_image_cleaner.sh'
+}
diff --git a/.test-infra/tools/stale_dataflow_prebuilt_image_cleaner.sh b/.test-infra/tools/stale_dataflow_prebuilt_image_cleaner.sh
new file mode 100755
index 00000000000..f37110290d0
--- /dev/null
+++ b/.test-infra/tools/stale_dataflow_prebuilt_image_cleaner.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+# Delete stale python prebuilt SDK container images older than one day.
+#
+set -euo pipefail
+
+STALE_IMAGES=$(gcloud container images list-tags \
+gcr.io/apache-beam-testing/prebuilt_beam_sdk/beam_python_prebuilt_sdk \
+--sort-by=TIMESTAMP --filter="timestamp.datetime < $(date --iso-8601=s -d '1 day ago')" \
+--format="get(digest)")
+
+if [[ ${STALE_IMAGES} ]]; then
+ for digest in ${STALE_IMAGES}; do
+ gcloud container images delete gcr.io/apache-beam-testing/prebuilt_beam_sdk/beam_python_prebuilt_sdk@"$digest" --force-delete-tags -q
+ done
+else
+ echo "No stale prebuilt container images found."
+fi