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

release init images WITH stable tag #395

Open
wants to merge 1 commit into
base: mainline
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 60 additions & 11 deletions scripts/publish.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ publish_to_docker_hub() {
if [ "$IMAGE_SHA_MATCHED" = "FALSE" ]; then
create_manifest_list ${1} "stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
fi

docker pull ${1}:"$init"-stable || echo "0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm either I didn't notice this before or I no longer remember why its :"$init"-stable shouldn't it just be init-stable...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, let me recall...

I think I did this because we need to put different suffixes after "init" other than "stable".
Like here and here.

And sometimes we need to use "init stable" rather than "init-stable" like here.

Due to the different code styles and parameter passing way in this file so I chose not to hard code "init".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Galaoaoa for showing strong ownership and continuing to track this PR :)

I think I did this because we need to put different suffixes after "init" other than "stable".

Hmm but I don't understand why we need the "$init"... the init part never changes right? Its the bit afterwards. So I'd expect to see: init-${var}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can use init instead of "$init". From the current perspective, I think we could indeed just use the init, this would be the better way :)

sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${1}:"$init"-stable || echo "0")
docker pull ${1}:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${1}:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION})

match_two_sha $sha1_init $sha2_init

if [ "$IMAGE_SHA_MATCHED" = "FALSE" ]; then
create_manifest_list_init ${1} ""$init"-stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
fi
else
for arch in "${ARCHITECTURES[@]}"
do
Expand Down Expand Up @@ -155,6 +166,18 @@ publish_to_public_ecr() {
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
create_manifest_list public.ecr.aws/aws-observability/aws-for-fluent-bit "stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
fi

docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-stable || echo "0"
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-stable || echo "0")
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION})

match_two_sha $sha1_init $sha2_init

if [ "$IMAGE_SHA_MATCHED" = "FALSE" ]; then
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
create_manifest_list_init public.ecr.aws/aws-observability/aws-for-fluent-bit "$init"-"stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
fi
else
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability

Expand Down Expand Up @@ -197,6 +220,10 @@ publish_stable_ssm() {
aws ssm put-parameter --name /aws/service/aws-for-fluent-bit/stable --overwrite \
--description 'Regional Amazon ECR Image URI for the latest stable AWS for Fluent Bit Docker Image' \
--type String --region ${1} --value ${2}:${3}

aws ssm put-parameter --name /aws/service/aws-for-fluent-bit/"$init"stable --overwrite \
--description 'Regional Amazon ECR Image URI for the latest stable AWS for Fluent Bit Docker Image with Init Process' \
--type String --region ${1} --value ${2}:${3}
}

rollback_ssm() {
Expand All @@ -217,18 +244,16 @@ check_parameter() {
repo_uri=$(sed -e 's/^"//' -e 's/"$//' <<<"$repo_uri")
docker pull $repo_uri

if [ "${2}" != "stable"]; then
repo_uri_init=$(aws ssm get-parameter --name /aws/service/aws-for-fluent-bit/"$init"-${2} --region ${1} --query 'Parameter.Value')
IFS='.' read -r -a array <<<"$repo_uri_init"
region="${array[3]}"
if [ "${1}" != "${region}" ]; then
echo "${1}: Region found in repo URI does not match SSM Parameter region: ${repo_uri}"
exit 1
fi
# remove leading and trailing quotes from repo_uri
repo_uri_init=$(sed -e 's/^"//' -e 's/"$//' <<<"$repo_uri")
docker pull $repo_uri_init
repo_uri_init=$(aws ssm get-parameter --name /aws/service/aws-for-fluent-bit/"$init"-${2} --region ${1} --query 'Parameter.Value')
IFS='.' read -r -a array <<<"$repo_uri_init"
region="${array[3]}"
if [ "${1}" != "${region}" ]; then
echo "${1}: Region found in repo URI does not match SSM Parameter region: ${repo_uri}"
exit 1
fi
# remove leading and trailing quotes from repo_uri
repo_uri_init=$(sed -e 's/^"//' -e 's/"$//' <<<"$repo_uri")
docker pull $repo_uri_init
}

sync_latest_image() {
Expand Down Expand Up @@ -302,6 +327,8 @@ sync_latest_image() {
fi
create_manifest_list ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION} || echo "0"

create_manifest_list_init ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "init-stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION} || echo "0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code has changed: #571 (comment)


make_repo_public ${region}

ssm_parameters=$(aws ssm get-parameters --names "/aws/service/aws-for-fluent-bit/${AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB}" --region ${region})
Expand Down Expand Up @@ -437,6 +464,14 @@ verify_ecr() {
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB}
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB})


docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-stable || echo "0"
stableSha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-stable || echo "0")
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION} || echo "0"
stableSha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION} || echo "0")

verify_sha $stableSha1_init $stableSha2_init

docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB}
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION_DOCKERHUB})
else
Expand Down Expand Up @@ -503,6 +538,13 @@ verify_dockerhub() {
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION})

verify_sha $sha1 $sha2

docker pull amazon/aws-for-fluent-bit:"$init"-stable
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:"$init"-stable)
docker pull amazon/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION})

verify_sha $sha1_init $sha2_init
else
# Get the image SHA's
docker pull amazon/aws-for-fluent-bit:latest
Expand Down Expand Up @@ -532,6 +574,13 @@ verify_public_ecr() {
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION})

verify_sha $sha1 $sha2

docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-stable
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-stable)
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_STABLE_VERSION})

verify_sha $sha1_init $sha2_init
else
# Get the image SHA's
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:latest
Expand Down