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

vms-admitter: remove validation of vm clone volume from webhook #12628

Merged
merged 5 commits into from
Oct 28, 2024

Conversation

ShellyKa13
Copy link
Contributor

@ShellyKa13 ShellyKa13 commented Aug 19, 2024

When having this check in the webhook we are preventing the creation of VMs which their datasource might not exist yet. Furthermore there are cases like in restore of backup where the vms volumes are already populated and dont event need to create the datavolume hence for sure no need to prevent the VM from being created in absence of such source.
This fix aims to fix bug: https://issues.redhat.com/browse/CNV-43272 While also make our product more aligned with eventual consistency model.

Note: to clarify the removed authentication from the webhook is still being done in the vm reconcile loop before creating the datavolumes

Fixes # Jira-ticket: https://issues.redhat.com/browse/CNV-43272

Why we need it and why it was done in this way

The following tradeoffs were made:

The following alternatives were considered:

Links to places where the discussion took place:

Special notes for your reviewer

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

VMs admitter: remove validation of vm clone volume from the webhook

@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. labels Aug 19, 2024
@ShellyKa13
Copy link
Contributor Author

/sig storage
/sig code-quality

@kubevirt-bot kubevirt-bot added sig/storage kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Aug 19, 2024
@ShellyKa13
Copy link
Contributor Author

/cc @mhenriks

@kubevirt-bot kubevirt-bot requested a review from mhenriks August 19, 2024 14:49
@mhenriks
Copy link
Member

/hold

Let's get #12547 in first so we have a PR that we can easily backport

Then this one will only hit main and release 1.4+

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 21, 2024
@ShellyKa13
Copy link
Contributor Author

/unhold
@mhenriks I wrote to you also in the PR you mentioned #12547
I think this PR fixes several issues related to creating a vm with dvtemplate with clone source which the other PR doesnt solve, hence I think we can and should backport this PR instead and drop PR #12547

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 28, 2024
@mhenriks
Copy link
Member

@ShellyKa13 Not good form for you to unhold a PR you did not put a hold on

@ShellyKa13
Copy link
Contributor Author

/hold
You are right. Sorry.

@kubevirt-bot kubevirt-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 28, 2024
@kubevirt-bot kubevirt-bot added dco-signoff: no Indicates the PR's author has not DCO signed all their commits. size/XL release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. labels Sep 1, 2024
@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. and removed dco-signoff: no Indicates the PR's author has not DCO signed all their commits. labels Sep 1, 2024
vm, err := virtClient.VirtualMachine(vm.Namespace).Create(context.Background(), vm, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
defer func() {
err := virtClient.VirtualMachine(vm.Namespace).Delete(context.Background(), vm.Name, metav1.DeleteOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

Can you remind me why this defer is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure why I added it, can't think of a reason why would it be needed since the vm should be cleaned up when the test ends anyways.. Will remove it..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mhenriks
Copy link
Member

/retest-required

@mhenriks
Copy link
Member

/test pull-kubevirt-e2e-k8s-1.30-sig-storage

@mhenriks
Copy link
Member

/approve

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 13, 2024
@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 Oct 13, 2024
@EdDev
Copy link
Member

EdDev commented Oct 14, 2024

@arnongilboa , can you please have a look at this change?

@arnongilboa
Copy link
Contributor

@arnongilboa , can you please have a look at this change?

sure, it's in my queue

@@ -1025,30 +1025,6 @@ var _ = SIGDescribe("DataVolume Integration", func() {
Entry("with explicit role (all namespaces) snapshot clone", explicitCloneRole, true, false, snapshotCloneMutateFunc, false),
Entry("with explicit role (one namespace) snapshot clone", explicitCloneRole, false, true, snapshotCloneMutateFunc, false),
)

It("should skip authorization when DataVolume already exists", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this test irrelevant anymore? shouldn't we test it even after dropping the webhook validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was part of a PR of Micheal which is mostly since he added this logic to the webhook, but I guess I can keep this test since it can test the vm watch as well

@@ -1602,48 +1594,6 @@ var _ = Describe("Validating VM Admitter", func() {
Entry("when everything suppied with 'sa' service account", "ns1", "ns2", "ns3", "sa", "ns3", "ns2", "sa"),
)

It("should successfully authorize clone with existing DataVolume", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this utest irrelevant anymore? shouldn't we test it even after dropping the webhook validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the auth is checked in the vm watch ut. no need to test it here anymore since the webhook doesnt take it into account anymore

@@ -1537,195 +1532,6 @@ var _ = Describe("Validating VM Admitter", func() {
Expect(causes).To(HaveLen(1))
Expect(causes[0].Field).To(Equal("fake"))
})

DescribeTable("should successfully authorize clone", func(arNamespace, vmNamespace, sourceNamespace,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this utest irrelevant anymore? shouldn't we check clone authorization from same / differnt ns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is being tested in the vm watch


// stop vm
vm = libvmops.StopVirtualMachine(vm)
libvmops.StartVirtualMachine(vm)
},
Copy link
Contributor

@arnongilboa arnongilboa Oct 15, 2024

Choose a reason for hiding this comment

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

intentionally removed the DV succeeded check covered by createVMSuccess? no need to stop as the ns is deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont need to create the vm anymore since the webhook doesnt fail the creation, instead the VM is created I see that the condition I expect is there and then I start the vm in that function there is a check the VM started successfully which assures the dv succeeded.

…taVolume already exists"

Since the change that I will be making removes the auth check
alltogether from the webhook we dont need some of the changes
that were recently in PR kubevirt#12547

Signed-off-by: Shelly Kagan <[email protected]>
When having this check in the webhook we are preventing the creation
of VMs which they datasource might not exist yet. Furthermore there
are cases like in restore of backup where the vms volumes are already
populated and dont event need to create the datavolume hence for
sure no neede to prevent the VM from being created in absence of such
source.
This fix aims to fix bug: https://issues.redhat.com/browse/CNV-43272
While also make our product more aligned with eventual consistency
model.

Signed-off-by: Shelly Kagan <[email protected]>
Now we expect the create action to succeed and have a condition
to represent that there are permission issues with the creation
of the DV. After adding the permission we see that the we can be
started and running successfully.

Signed-off-by: Shelly Kagan <[email protected]>
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 27, 2024
@arnongilboa
Copy link
Contributor

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 27, 2024
@kubevirt-commenter-bot
Copy link

Required labels detected, running phase 2 presubmits:
/test pull-kubevirt-e2e-windows2016
/test pull-kubevirt-e2e-kind-1.30-vgpu
/test pull-kubevirt-e2e-kind-sriov
/test pull-kubevirt-e2e-k8s-1.30-ipv6-sig-network
/test pull-kubevirt-e2e-k8s-1.29-sig-network
/test pull-kubevirt-e2e-k8s-1.29-sig-storage
/test pull-kubevirt-e2e-k8s-1.29-sig-compute
/test pull-kubevirt-e2e-k8s-1.29-sig-operator
/test pull-kubevirt-e2e-k8s-1.30-sig-network
/test pull-kubevirt-e2e-k8s-1.30-sig-storage
/test pull-kubevirt-e2e-k8s-1.30-sig-compute
/test pull-kubevirt-e2e-k8s-1.30-sig-operator

@ShellyKa13
Copy link
Contributor Author

/unhold
Was approved by @mhenriks which put the hold originally

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 28, 2024
@ShellyKa13
Copy link
Contributor Author

/retest

@kubevirt-bot kubevirt-bot merged commit 180c938 into kubevirt:main Oct 28, 2024
40 checks passed
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants