-
Notifications
You must be signed in to change notification settings - Fork 362
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
ecr.repository: Add forceDelete to delete images #743
Conversation
Hi @chlunde, It may make sense to put such a flag under I also have a concern about naming: Per API conventions, we had better use declarative API names instead of imperative ones. Maybe something like @hasheddan, what's your opinion here? |
@ulucinar you're right, in this case the provider does support the option. The name is simply I notice secrets manager has |
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.
Apologies for the delayed response here folks! @chlunde I think putting this under forProvider
as @ulucinar suggests is the right move, and I also think calling it something like forceDelete
is appropriate here. The only other route I would consider going is an embedded struct under forProvider
with something like delete.force
, but I agree that just using forceDelete
is more aligned with fields like skipFinalSnapshotBeforeDeletion
, etc.
Add flag forceDelete to the CRD directly under spec. This enabled the force flag on the DeleteRepository AWS API call, which will also delete images if the repository contains any. Without this option, AWS blocks deletion of repositories without images. Updates crossplane-contrib#495 Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
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.
LGTM! Thanks @chlunde! Did you test this against an actual ECR repository?
Yeah, I tested on an actual cluster. I have not re-tested yet after moving the field. |
re-tested OK: 2021-08-02T20:20:31.613+0200 DEBUG controller-runtime.manager.events Warning {"object": {"kind":"Repository","name":"example","uid":"70fd7f05-cd0e-4267-9ff0-21b326c8972d","apiVersion":"ecr.aws.crossplane.io/v1alpha1","resourceVersion":"4837"}, "reason": "CannotDeleteExternalResource", "message": "failed to delete the repository resource: RepositoryNotEmptyException: The repository with name 'example' in registry with id '21913760....' cannot be deleted because it still contains images"} $ kubectl patch repository.ecr example --type=merge --patch '{"spec": {"forProvider": {"forceDelete": true}}}'
repository.ecr.aws.crossplane.io/example patched 2021-08-02T20:25:19.267+0200 DEBUG provider-aws Reconciling {"controller": "managed/repository.ecr.aws.crossplane.io", "request": "/example"}
2021-08-02T20:25:19.534+0200 DEBUG provider-aws Successfully requested deletion of external resource {"controller": "managed/repository.ecr.aws.crossplane.io", "request": "/example", "uid": "70fd7f05-cd0e-4267-9ff0-21b326c8972d", "version": "5338", "external-name": "example", "deletion-timestamp": "2021-08-02 20:20:21 +0200 CEST"}
2021-08-02T20:25:19.535+0200 DEBUG controller-runtime.manager.events Normal {"object": {"kind":"Repository","name":"example","uid":"70fd7f05-cd0e-4267-9ff0-21b326c8972d","apiVersion":"ecr.aws.crossplane.io/v1alpha1","resourceVersion":"5338"}, "reason": "DeletedExternalResource", "message": "Successfully requested deletion of external resource"}
2021-08-02T20:25:19.555+0200 DEBUG provider-aws Reconciling {"controller": "managed/repository.ecr.aws.crossplane.io", "request": "/example"} |
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.
This works in testing. Confirmed that forceDelete: false
results in an error on delete of populated repo. forceDelete: true
successfully forces delete of the repo even with images.
Thanks, @chlunde!
Provide up-to-date UPTEST_CLOUD_CREDENTIALS export examples
Description of your changes
Add flag forceDelete to the CRD directly under spec. This enabled the
force flag on the DeleteRepository AWS API call, which will also delete
images if the repository contains any.
Without this option, AWS blocks deletion of repositories without images.
Updates #495
Implementation notes:
forceDelete
carefully, does it make sense for recursive delete on S3 too? I guess it's pretty generic (unlikerecursiveDelete
which makes sense for S3 and ECR but not "delete an active bundle" as discussed in Force Delete Flag for some resources #495)I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested