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

Delete CRDs & check finalizers in operator delete #2097

Merged
merged 3 commits into from Jan 19, 2022

Conversation

arnongilboa
Copy link
Collaborator

Signed-off-by: Arnon Gilboa agilboa@redhat.com

What this PR does / why we need it:
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.

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:

NONE

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/S labels Jan 13, 2022
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>
return err
}
dics := &cdiv1.DataImportCronList{}
if err := args.Client.List(context.TODO(), dics, &client.ListOptions{}); err != nil && !errors.IsNotFound(err) {
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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

@mhenriks
Copy link
Member

Should be "destructive" test for this that uninstalls CDI

Copy link
Member

@awels awels left a 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.

return err
}
dics := &cdiv1.DataImportCronList{}
if err := args.Client.List(context.TODO(), dics, &client.ListOptions{}); err != nil && !errors.IsNotFound(err) {
Copy link
Member

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.

return err
}
dvs := &cdiv1.DataVolumeList{}
if err := args.Client.List(context.TODO(), dvs, &client.ListOptions{}); err != nil && !errors.IsNotFound(err) {
Copy link
Member

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

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 {
Copy link
Member

@mhenriks mhenriks Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotFound is okay here

Copy link
Collaborator Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just NotFound

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

return err
}
dics := &cdiv1.DataImportCronList{}
if err := args.Client.List(context.TODO(), dics, &client.ListOptions{}); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoMatch is okay here

Copy link
Collaborator Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just NoMatch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@awels
Copy link
Member

awels commented Jan 14, 2022

/retest

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
@awels
Copy link
Member

awels commented Jan 17, 2022

/retest

url := fmt.Sprintf(utils.TrustedRegistryURL, f.DockerPrefix)
cron := NewDataImportCron("cron-test", "5Gi", scheduleEveryMinute, "ds", cdiv1.DataVolumeSourceRegistry{URL: &url, PullMethod: &registryPullNode}, cdiv1.DataImportCronRetainAll)
cron, err := f.CdiClient.CdiV1beta1().DataImportCrons(f.Namespace.Name).Create(context.TODO(), cron, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
@awels
Copy link
Member

awels commented Jan 19, 2022

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 19, 2022
@awels
Copy link
Member

awels commented Jan 19, 2022

/test pull-containerized-data-importer-e2e-k8s-1.22-hpp-istio

@mhenriks
Copy link
Member

/approve

@kubevirt-bot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 19, 2022
@kubevirt-bot kubevirt-bot merged commit d9a23e5 into kubevirt:main Jan 19, 2022
@arnongilboa
Copy link
Collaborator Author

/cherrypick release-v1.43

@kubevirt-bot
Copy link
Contributor

@arnongilboa: new pull request created: #2114

In response to this:

/cherrypick release-v1.43

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants