Bugfix: Agent fails to resolve digest for a locally available image for images with docker.io prefix #4251
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.
Summary
ECS Agent has a bug that prevents it from resolving image manifest digest for locally cached images if the image reference in the task payload has a
docker.io
ordocker.io/library
prefix which is optional.Agent resolves image manifest digest for a locally cached image by inspecting the image (equivalent of
docker image inspect <image-reference>
) and then finding a repoDigest element whose repository name matches that of the image reference. However, if the image reference hasdocker.io
ordocker.io/library
prefix then Docker doesn't add the prefix to the repoDigest while Agent does not take that into account.The change in this PR makes Agent normalize image reference from the task payload and repoDigests when comparing them to fix this bug.
Implementation details
GetDigestFromRepoDigests
inutils/reference
package to parse image references and repoDigests usingParseNormalizedNamed
function that normalizes image references in addition to parsing them.Testing
Unit tests for
GetDigestFromRepoDigests
have been updated to cover the missing cases. I also ran many tasks with and withoutdocker.io
anddocker.io/library
prefixes on an instance withIMAGE_PULL_BEHAVIOR
set toonce
. All tasks ran without issues.New tests cover the changes: yes
Description for the changelog
Bugfix: Fix digest resolution for locally cached images when image reference in the task payload contains
docker.io
ordocker.io/library
prefix.Does this PR include breaking model changes? If so, Have you added transformation functions?
No
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.