-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[WIP] Defensive code in pull-sandbox-image.sh for custom AMI(s) #1648
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,25 @@ set -euo pipefail | |
|
||
source <(grep "sandbox_image" /etc/containerd/config.toml | tr -d ' ') | ||
|
||
### skip if we don't have a sandbox_image set in config.toml | ||
if [[ -z ${sandbox_image:-} ]]; then | ||
echo >&2 "Skipping ... missing sandbox_image from /etc/containerd/config.toml" | ||
exit 0 | ||
fi | ||
|
||
### Short-circuit fetching sandbox image if its already present | ||
if [[ "$(sudo ctr --namespace k8s.io image ls | grep $sandbox_image)" != "" ]]; then | ||
if [[ $(sudo ctr --namespace k8s.io image ls | grep "${sandbox_image}") != "" ]]; then | ||
exit 0 | ||
fi | ||
|
||
# use the region that the sandbox image comes from for the ecr authentication, | ||
# also mitigating the localzone isse: https://github.com/aws/aws-cli/issues/7043 | ||
region=$(echo "${sandbox_image}" | cut -f4 -d ".") | ||
### skip if we don't find a region in the sandbox image | ||
if [[ -z ${region:-} ]]; then | ||
echo >&2 "Skipping ... missing region in sandbox_image" | ||
exit 0 | ||
fi | ||
|
||
MAX_RETRIES=3 | ||
|
||
|
@@ -29,7 +40,7 @@ function retry() { | |
done | ||
} | ||
|
||
ecr_password=$(retry aws ecr get-login-password --region $region) | ||
ecr_password=$(retry aws ecr get-login-password --region "${region}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we add carter's fix https://github.com/awslabs/amazon-eks-ami/pull/1646/files so that we don't break the whole workflow on this failing, the tested empty # crictl pull --creds "AWS:" registry.k8s.io/pause:3.9
Image is up to date for sha256:e6f1816883972d4be47bd48879a08919b96afcd344132622e4d444987919323c There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree |
||
if [[ -z ${ecr_password} ]]; then | ||
echo >&2 "Unable to retrieve the ECR password." | ||
exit 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just because we parse a non-empty region doesn't mean its valid right?
registry.k8s.io/pause:3.9
is going to parse9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, we need more validation!