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
Delete CRDs & check finalizers in operator delete #2097
Conversation
621275b
to
e4a52e3
Compare
reconcileDeleteControllerDeployment deletes the CRDs of DataImportCron and DataVolume, and returns error if any DIC/DV has a finalizer. It will get retried and controller will eventually remove the finalizers. Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
e4a52e3
to
62a7566
Compare
pkg/operator/controller/callbacks.go
Outdated
return err | ||
} | ||
dics := &cdiv1.DataImportCronList{} | ||
if err := args.Client.List(context.TODO(), dics, &client.ListOptions{}); err != nil && !errors.IsNotFound(err) { |
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 should be IsNoMatchError
not IsNotFound
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.
Should probably check for both no? If the CRD doesn't exist, or there are no DICs left, we are happy.
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 don't think list returns notfound. Just returns an empty list in that case
Should be "destructive" test for this that uninstalls CDI |
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.
Also agree with Michael need a destructive test here where some DICs and DVs with finalizers on them.
pkg/operator/controller/callbacks.go
Outdated
return err | ||
} | ||
dics := &cdiv1.DataImportCronList{} | ||
if err := args.Client.List(context.TODO(), dics, &client.ListOptions{}); err != nil && !errors.IsNotFound(err) { |
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.
Should probably check for both no? If the CRD doesn't exist, or there are no DICs left, we are happy.
pkg/operator/controller/callbacks.go
Outdated
return err | ||
} | ||
dvs := &cdiv1.DataVolumeList{} | ||
if err := args.Client.List(context.TODO(), dvs, &client.ListOptions{}); err != nil && !errors.IsNotFound(err) { |
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.
Same here, check for IsNoMatchError and NotFound
pkg/operator/controller/callbacks.go
Outdated
args.Logger.Info("Deleting CRDs and verifing no finalizers") | ||
|
||
crd := &extv1.CustomResourceDefinition{ObjectMeta: metav1.ObjectMeta{Name: "dataimportcrons.cdi.kubevirt.io"}} | ||
if err := args.Client.Delete(context.TODO(), crd, &client.DeleteOptions{}); cdicontroller.IgnoreIsNoMatchError(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.
NotFound is okay here
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 you say in CRD delete we need to accept both NoMatch and NotFound?
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.
Just NotFound
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
pkg/operator/controller/callbacks.go
Outdated
return err | ||
} | ||
dics := &cdiv1.DataImportCronList{} | ||
if err := args.Client.List(context.TODO(), dics, &client.ListOptions{}); 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.
NoMatch is okay here
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 in List (after we deleted the CRD) we need to accept both NoMatch and NotFound?
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.
Just NoMatch
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
/retest |
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
8141309
to
f6df10f
Compare
/retest |
url := fmt.Sprintf(utils.TrustedRegistryURL, f.DockerPrefix) | ||
cron := NewDataImportCron("cron-test", "5Gi", scheduleEveryMinute, "ds", cdiv1.DataVolumeSourceRegistry{URL: &url, PullMethod: ®istryPullNode}, cdiv1.DataImportCronRetainAll) | ||
cron, err := f.CdiClient.CdiV1beta1().DataImportCrons(f.Namespace.Name).Create(context.TODO(), cron, metav1.CreateOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) |
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.
can we wait for DV to be created/succeed? Or at least validate that the finalizer exists?
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
8c0e73b
to
de86883
Compare
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
de86883
to
84ad9dd
Compare
/lgtm |
/test pull-containerized-data-importer-e2e-k8s-1.22-hpp-istio |
/approve |
[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 |
/cherrypick release-v1.43 |
@arnongilboa: new pull request created: #2114 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. |
Signed-off-by: Arnon Gilboa agilboa@redhat.com
What this PR does / why we need it:
reconcileDeleteControllerDeployment
deletes the CRDs ofDataImportCron
andDataVolume
, and returns error if any DIC/DV has a finalizer. It will get retried and controller will eventually remove the finalizers.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: