Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: better recovery from a failed skopeo... #529

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 20 additions & 10 deletions build/workflows/check-sidecar-image-digests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,26 @@ check_image_digest() {

local latest_digest
latest_digest="$(skopeo inspect --tls-verify=false docker://"${base_image_name}" 2>/dev/null | jq -r '.Digest')"
latest_digest="${base_image_name%:*}@${latest_digest}"

if [[ "${latest_digest}" != "${base_image_digest}" ]]; then
echo -e "\n${RED}Detected newer image digest${NC} for ${BLUE}${base_image_name}${NC}"

sed -i "s|FROM ${base_image_digest}$|FROM ${latest_digest}|" "${ROOT_DIR}/dockerfiles/${image}/Dockerfile"

UPDATED="${UPDATED} ${image_name}\n"
else
echo -e "Image ${BLUE}${base_image_name}${NC} has valid digest"
if [[ ! $latest_digest ]]; then # try again -- might have had a transient error resolving the digest from the registry
sleep 30s
latest_digest="$(skopeo inspect --tls-verify=false docker://"${base_image_name}" 2>/dev/null | jq -r '.Digest')"
fi
if [[ ! $latest_digest ]]; then # if still missing after second attempt, skip
echo -e "\n${RED}ERROR: Could not resolve latest digest for${NC}: ${BLUE}${base_image_name}${NC}"
else
latest_digest="${base_image_name%:*}@${latest_digest}"

if [[ "${latest_digest}" != "${base_image_digest}" ]]; then
echo -e "\n${BLUE}Detected newer image digest${NC}:"
echo -e "${RED}- ${base_image_digest}${NC}"
echo -e "${GREEN}+ ${latest_digest}${NC}"

sed -i "s|FROM ${base_image_digest}$|FROM ${latest_digest}|" "${ROOT_DIR}/dockerfiles/${image}/Dockerfile"

UPDATED="${UPDATED} ${image_name}\n"
else
echo -e "Image ${BLUE}${base_image_name}${NC} has valid digest"
fi
fi
}

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/golang-1.17/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

ARG BASE_IMAGE="docker.io/golang:1.17-stretch"

FROM docker.io/golang@sha256:a49b4952c45d08591cb837a2c9c9385852fd4d2912007406c6b4417d75833521
FROM docker.io/golang@sha256:2996c0e10f27cd7d3e2c1ac4badf80f423c81793540b4af89b3d75331ee22597

#{INCLUDE:../base.dockerfile}