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

Bugfix: Agent fails to resolve digest for a locally available image for images with docker.io prefix #4251

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

amogh09
Copy link
Contributor

@amogh09 amogh09 commented Jul 23, 2024

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 or docker.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 has docker.io or docker.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

  • Update GetDigestFromRepoDigests in utils/reference package to parse image references and repoDigests using ParseNormalizedNamed 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 without docker.io and docker.io/library prefixes on an instance with IMAGE_PULL_BEHAVIOR set to once. 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 or docker.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.

@amogh09 amogh09 changed the base branch from master to dev July 23, 2024 21:23
@amogh09 amogh09 changed the title Repo digest bug Bugfix: Agent fails to resolve digest for a locally available image for images with docker.io prefix Jul 23, 2024
@amogh09 amogh09 marked this pull request as ready for review July 23, 2024 21:46
@amogh09 amogh09 requested a review from a team as a code owner July 23, 2024 21:46
@amogh09 amogh09 merged commit cb012dc into aws:dev Jul 23, 2024
40 checks passed
xxx0624 pushed a commit to xxx0624/amazon-ecs-agent that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants