Skip to content

Commit 205fbb1

Browse files
authored
[BEAM-12653] Fix container cleanup for Java Dataflow tests (#15213)
1 parent a1abdf1 commit 205fbb1

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

runners/google-cloud-dataflow-java/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ task cleanUpDockerImages() {
279279
commandLine "docker", "rmi", "--force", "${dockerImageName}"
280280
}
281281
exec {
282-
commandLine "gcloud", "--quiet", "container", "images", "delete", "--force-delete-tags", "${dockerImageName}"
282+
commandLine "gcloud", "--quiet", "container", "images", "untag", "${dockerImageName}"
283+
}
284+
exec {
285+
commandLine "./scripts/cleanup_untagged_gcr_images.sh", "${dockerImageContainer}"
283286
}
284287
}
285288
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
set -e
19+
20+
IMAGE_NAME=$1
21+
22+
# Find all untagged images
23+
DIGESTS=$(gcloud container images list-tags "${IMAGE_NAME}" --filter='-tags:*' --format="get(digest)")
24+
25+
# Delete image
26+
echo "${DIGESTS}" | while read -r digest; do
27+
if [[ ! -z "${digest}" ]]; then
28+
img="${IMAGE_NAME}@${digest}"
29+
echo "Removing untagged image ${img}"
30+
gcloud container images delete --quiet "${img}"
31+
fi
32+
done

0 commit comments

Comments
 (0)