aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

Push fails when image already exists on repository with tag and is immutable #750

Closed daveisfera closed 1 month ago

daveisfera commented 1 month ago

Describe the bug

Pushing an image to a tag where it already exists reports an error

Expected Behavior

If the image is identical, then it should report that it already exists without an error

Current Behavior

An error is reported with return code 254

Reproduction Steps

  1. Put an image with a tag
  2. Put the the same image with the same tag

Possible Solution

Report that it already exists and return success

Additional Information/Context

No response

CLI version used

aws-cli/2.15.17 Python/3.11.7 Darwin/23.4.0 source/x86_64 prompt/off

Environment details (OS name and version, etc.)

macOS 14.4.1

daveisfera commented 1 month ago

Here's an issue from the docker repo: https://github.com/moby/buildkit/issues/3776

tim-finnigan commented 1 month ago

Thanks for reaching out. Are you using any ECR CLI commands or can you provide more details on your workflow? It seems like this issue relates more to Docker/ECR than the CLI directly. We can forward issues to service teams like ECR if necessary. I saw one other issue (https://github.com/aws/containers-roadmap/issues/862) in an AWS repository referencing that error but it looks like that was closed a few years ago.

daveisfera commented 1 month ago

We do a build with the SHA of the git commit and tag that for each PR and then when it's merged to branch associated with an environment we get the manifest using this command:

aws ecr batch-get-image --repository-name mycompany/myrepo --image-ids imageTag="${git_sha} --query 'images[].imageManifest' --output text

And then we tag it to that branch using this command:

 aws ecr put-image --repository-name mycompany/myrepo --image-tag "${branch}" --image-manifest "$MANIFEST"

That works just fine, but if the deploy fails and we need to re-run that, then the put-image command fails since the exact image is already there. It would be nice if this could be handled somehow and the linked to issue from buildkit indicates that it's a "client problem"

amberkushwaha commented 1 month ago

aws ecr batch-get-image --repository-name mycompany/myrepo --image-ids imageTag="${git_sha} --query 'images[].imageManifest' --output text This code has been updated in the main stream scenario.

daveisfera commented 1 month ago

So this will be fixed in an upcoming version? If so, which version number and is there an expected release date?

tim-finnigan commented 1 month ago

Thanks for following up. I'm going to reach out to the ECR team regarding this issue (ref: P130774841), as they own the underlying BatchGetImage / PutImage APIs. I'm also going to transfer this to our cross-SDK repository since service APIs like these are used across AWS SDKs in addition to the AWS CLI. I'll share any updates here in the issue.

tim-finnigan commented 1 month ago

We heard back from the ECR team and they recommended creating an issue in this repository where they publicly tracks customer feature requests: https://github.com/aws/containers-roadmap

You can can see if a similar feature request already exists, or create one if not. Those issues are reviewed by the ECR service team.

As far as workarounds on the client-side, you can either treating ImageAlreadyExistsException as a non-exception or check if an image exists before calling put-image.

github-actions[bot] commented 1 month ago

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.