Skip to content

Commit

Permalink
Generate version info for cached images only when is active (#1341)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermckinnon authored Jul 7, 2023
1 parent 453da19 commit 6ab0808
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion eks-worker-al2.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@
"type": "shell",
"remote_folder": "{{ user `remote_folder`}}",
"script": "{{template_dir}}/scripts/generate-version-info.sh",
"execute_command": "chmod +x {{ .Path }}; {{ .Path }} {{user `working_dir`}}/version-info.json"
"execute_command": "chmod +x {{ .Path }}; {{ .Path }} {{user `working_dir`}}/version-info.json",
"environment_vars": [
"CACHE_CONTAINER_IMAGES={{user `cache_container_images`}}"
]
},
{
"type": "file",
Expand Down
7 changes: 6 additions & 1 deletion scripts/generate-version-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ echo $(jq ".binaries.kubelet = \"$(kubelet --version | awk '{print $2}')\"" $OUT
echo $(jq ".binaries.awscli = \"$(aws --version | awk '{print $1}' | cut -d '/' -f 2)\"" $OUTPUT_FILE) > $OUTPUT_FILE

# cached images
echo $(jq ".images = [ $(sudo ctr -n k8s.io image ls -q | cut -d'/' -f2- | sort | uniq | grep -v 'sha256' | xargs -r printf "\"%s\"," | sed 's/,$//') ]" $OUTPUT_FILE) > $OUTPUT_FILE
if systemctl is-active --quiet containerd; then
echo $(jq ".images = [ $(sudo ctr -n k8s.io image ls -q | cut -d'/' -f2- | sort | uniq | grep -v 'sha256' | xargs -r printf "\"%s\"," | sed 's/,$//') ]" $OUTPUT_FILE) > $OUTPUT_FILE
elif [ "${CACHE_CONTAINER_IMAGES}" = "true" ]; then
echo "containerd must be active to generate version info for cached images"
exit 1
fi

0 comments on commit 6ab0808

Please sign in to comment.