Skip to content
Snippets Groups Projects

[bmk1157] Fix BMK-1157 : in clear_images remove images >1GB even if they are...

Merged Domenico Giordano requested to merge BMK-1157 into qa-build-hello-world-c7-ma
3 files
+ 15
12
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 5
5
#!/bin/bash
# Copyright 2019-2020 CERN. See the COPYRIGHT file at the top-level
# Copyright 2019-2023 CERN. See the COPYRIGHT file at the top-level
# directory of this distribution. For licensing information, see the
# COPYING file at the top-level directory of this distribution.
function usage(){
echo "Usage: $(basename $0) [-r regex|--all]"
echo "Usage: $(basename $0) [-r regex|--all|--days]"
exit 1
}
@@ -23,9 +23,9 @@ elif [ "$1" == "--days" ]; then
# Remove all <none> images created more than 2 days ago
# In the clean stage of .gitlab-ci.sh, this does NOT remove newly created layers, easing caching across CI runs (BMK-1010)
IMAGES_A=$(docker images | grep '<none>' | egrep -v '(second|minute|hour)(s|) ago' | awk '{print $3}')
# remove also all images older than days having large size
IMAGES_B=$(docker images --format "{{.ID}} {{.CreatedSince}} {{.Size}}" | grep -e "ago [0-9\.]*GB" | awk '{print $1}')
IMAGES=$(echo ${IMAGES_A} " " ${IMAGES_B})
# Remove also images that are not <none>, if they are larger than 1 GB, except for builder images (BMK-1157)
IMAGES_B=$(docker images | grep -e "ago *[0-9\.]*GB" | grep -v hep-workload-builder | awk '{print $3}')
if [ "$IMAGES_A" != "" ]; then IMAGES=$(echo ${IMAGES_A} " " ${IMAGES_B}); else IMAGES=${IMAGES_B}; fi
elif [ "$1" == "--all" ]; then
IMAGES=$(docker images | egrep -v '^(REPOSITORY|gitlab-registry.cern.ch/linuxsupport/(slc6|cc7)-base)' | awk '{print $3}')
shift
Loading