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
Fix CRDs deletion in operator deletion #2129
Fix CRDs deletion in operator deletion #2129
Conversation
Also check DataImportCron CRD has no DeletionTimestamp before adding a finalizer Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
81c0c7d
to
f2a0d50
Compare
| Eventually(func() bool { | ||
| result, err := args.reconciler.Reconcile(context.TODO(), reconcileRequest(args.cdi.Name)) | ||
| return err == nil && !result.Requeue | ||
| }, 1*time.Minute, 2*time.Second).Should(BeTrue()) |
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.
What's going on here? Unit tests should be deterministic.
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 think I get it
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.
Thanks. Reverted it.
pkg/operator/controller/callbacks.go
Outdated
| } | ||
| crdsExist := false | ||
| for _, crdName := range crdNames { | ||
| crd := &extv1.CustomResourceDefinition{ObjectMeta: metav1.ObjectMeta{Name: crdName}} |
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.
Maybe changing this to the following to address unit test issues?
Get CRD if not exist continue
If CRD.deletionTimestamp == nil{
Delete CRD
Get CRD if not exist continue
}
crdsExist = true
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.
So the issue was caused by repeated Delete() of CRD which already had DeletionTimestamp? Late night games...
Fixed
|
/retest |
| } | ||
| args.Logger.Info("CRD is not deleted yet", "crdName", crdName) | ||
| crdsExist = true | ||
| } |
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.
you have to set crdsExist = true here is else block when crd.DeletionTimestamp != nil
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.
Fat fingers. Fixed.
ae92bd7
to
071b8b4
Compare
| log := r.log.WithName("initCron") | ||
| if !HasFinalizer(dataImportCron, dataImportCronFinalizer) { | ||
| crd := &extv1.CustomResourceDefinition{} | ||
| if err := r.client.Get(context.TODO(), types.NamespacedName{Name: "dataimportcrons.cdi.kubevirt.io"}, crd); err == nil { |
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.
err == nil
Don’t think that’s correct
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.
fixed
| crd := &extv1.CustomResourceDefinition{} | ||
| if err := r.client.Get(context.TODO(), types.NamespacedName{Name: "dataimportcrons.cdi.kubevirt.io"}, crd); err == nil { | ||
| log.Error(err, "Cannot get CRD") | ||
| return nil |
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.
Return err?
| } | ||
| if crd.DeletionTimestamp != nil { | ||
| log.Info("CRD has DeletionTimestamp") | ||
| return nil |
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.
Return an error instead maybe?
071b8b4
to
4985f05
Compare
|
/retest |
|
/lgtm |
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mhenriks The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold |
|
new func test may be flaky |
4985f05
to
6f0774d
Compare
|
/retest |
@mhenriks it was not the new func test, but a missing |
|
/hold cancel |
|
/test pull-containerized-data-importer-e2e-k8s-1.22-hpp-destructive |
|
/lgtm |
|
/cherrypick release-v1.43 |
|
@arnongilboa: new pull request created: #2130 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Also check DataImportCron CRD has no DeletionTimestamp before adding a
finalizer
Signed-off-by: Arnon Gilboa agilboa@redhat.com
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Release note: