-
Notifications
You must be signed in to change notification settings - Fork 39
Validate released operator image by digest. #408
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
.github/actions/prepare-operator-minikube-image/action.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Gets the operator image into minikube and deploys it. Source mode builds from | ||
| # source (real versions baked). Digest mode pulls the released image by digest | ||
| # and overrides instrumentation images from versions.txt (like Helm/addon do). | ||
| name: Prepare and deploy operator in minikube | ||
| description: Build from source or pull a released digest, load into minikube, deploy, and (digest mode) set real instrumentation images. | ||
|
|
||
| inputs: | ||
| operator-image-uri: | ||
| description: 'ECR repo URI of a released operator image to validate by digest. Empty => build from source.' | ||
| required: false | ||
| default: '' | ||
| operator-image-digest: | ||
| description: 'Immutable sha256:... digest to validate (digest mode).' | ||
| required: false | ||
| default: '' | ||
| region: | ||
| description: 'AWS region for ECR login (digest mode).' | ||
| required: false | ||
| default: 'us-west-2' | ||
| aws-role: | ||
| description: 'IAM role ARN to assume for ECR pull (digest mode).' | ||
| required: false | ||
| default: '' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Build image from source | ||
| if: ${{ inputs.operator-image-digest == '' }} | ||
| shell: bash | ||
| run: | | ||
| eval $(minikube docker-env) | ||
| make container | ||
| docker images | ||
|
|
||
| - name: Configure AWS credentials | ||
| if: ${{ inputs.operator-image-digest != '' }} | ||
| uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | ||
| with: | ||
| role-to-assume: ${{ inputs.aws-role }} | ||
| aws-region: ${{ inputs.region }} | ||
|
|
||
| - name: Login to ECR | ||
| if: ${{ inputs.operator-image-digest != '' }} | ||
| uses: aws-actions/amazon-ecr-login@183a1442edf41672e66566b7fc560e297a290896 # v2.1.1 | ||
|
|
||
| - name: Pull released image by digest and load into minikube | ||
| if: ${{ inputs.operator-image-digest != '' }} | ||
| shell: bash | ||
| env: | ||
| LOCAL_IMG: aws/cloudwatch-agent-operator:release-validation | ||
| run: | | ||
| set -euo pipefail | ||
| RELEASED="${{ inputs.operator-image-uri }}@${{ inputs.operator-image-digest }}" | ||
| echo "Validating released operator image: ${RELEASED}" | ||
| docker pull "${RELEASED}" | ||
| docker tag "${RELEASED}" "${LOCAL_IMG}" | ||
| minikube image load "${LOCAL_IMG}" | ||
|
|
||
| - name: Deploy operator | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -n "${{ inputs.operator-image-digest }}" ]; then | ||
| make deploy IMG=aws/cloudwatch-agent-operator:release-validation | ||
| else | ||
| make deploy | ||
| fi | ||
|
|
||
| # Released images default instrumentation refs to 0.0.0; supply the real, | ||
| # published images. | ||
| - name: Override instrumentation images from source | ||
| if: ${{ inputs.operator-image-digest != '' }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| ver() { grep "^$1=" versions.txt | cut -d '=' -f2; } | ||
| repo() { grep "${1}ImageRepository" main.go | head -1 | cut -d '"' -f2; } | ||
| kubectl set env deployment/cloudwatch-controller-manager -n amazon-cloudwatch \ | ||
| RELATED_IMAGE_AUTO_INSTRUMENTATION_JAVA=$(repo autoInstrumentationJava):$(ver aws-otel-java-instrumentation) \ | ||
| RELATED_IMAGE_AUTO_INSTRUMENTATION_PYTHON=$(repo autoInstrumentationPython):$(ver aws-otel-python-instrumentation) \ | ||
| RELATED_IMAGE_AUTO_INSTRUMENTATION_DOTNET=$(repo autoInstrumentationDotNet):$(ver aws-otel-dotnet-instrumentation) \ | ||
| RELATED_IMAGE_AUTO_INSTRUMENTATION_NODEJS=$(repo autoInstrumentationNodeJS):$(ver aws-otel-nodejs-instrumentation) | ||
| kubectl rollout status deployment/cloudwatch-controller-manager -n amazon-cloudwatch --timeout=180s | ||
|
|
||
| - name: Wait for operator ready | ||
| shell: bash | ||
| run: kubectl wait --for=condition=Ready pod --all -n amazon-cloudwatch --timeout=180s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I know this is not part of this PR but maybe something to consider is if we are triggering manual run and at the same time some one merges a PR it will cancel our manual run, do we want this behaviour?
Uh oh!
There was an error while loading. Please reload this page.
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.
yes because a merge to main takes top priority as we care about what was just merged, rather than the manual one. A manual run of your branch won't get cancelled.