-
Notifications
You must be signed in to change notification settings - Fork 31
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
MAC address cleanup #304
MAC address cleanup #304
Conversation
@alromeros: GitHub didn't allow me to request PR reviews from the following users: esteban-ee. Note that only kubevirt members and repo collaborators can review this PR, and authors cannot review their own PRs. 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-sigs/prow repository. |
/cc @ShellyKa13 @mhenriks |
/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 |
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.
Some comments are relevant to the 2 commit which are not yours.. I get the desire to use community member commits but they dont have much value.. I believe you should either delete them or squash the first 3 commits and add him as as signed by also..
pkg/plugin/vm_restore_item_action.go
Outdated
@@ -63,6 +63,10 @@ func (p *VMRestorePlugin) Execute(input *velero.RestoreItemActionExecuteInput) ( | |||
return nil, errors.WithStack(err) | |||
} | |||
|
|||
for i := 0; i < len(vm.Spec.Template.Spec.Domain.Devices.Interfaces); i++ { |
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.
dont think you need this commit..
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'm not against having "incomplete" commits such as these if they showcase the development history and specifically wanted to make an exception for these as they are from another contributor. That said, we've had this conversation in the past and I'm also ok with a cleaner approach, so I'll squash them as suggested.
pkg/plugin/vm_restore_item_action.go
Outdated
@@ -63,8 +64,11 @@ func (p *VMRestorePlugin) Execute(input *velero.RestoreItemActionExecuteInput) ( | |||
return nil, errors.WithStack(err) | |||
} | |||
|
|||
for i := 0; i < len(vm.Spec.Template.Spec.Domain.Devices.Interfaces); i++ { | |||
vm.Spec.Template.Spec.Domain.Devices.Interfaces[i].MacAddress = "" | |||
if util.IsMacAdressClearedByAnnotation(vm) { |
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.
typo Adress -> address
Also I think the name is missleading..
consider something like: ShouldClearMacAddress
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.
Related to my comment above
pkg/plugin/vm_restore_item_action.go
Outdated
if util.IsMacAdressClearedByAnnotation(vm) { | ||
p.log.Info("Clear virtual machine MAC addresses") | ||
for i := 0; i < len(vm.Spec.Template.Spec.Domain.Devices.Interfaces); i++ { | ||
vm.Spec.Template.Spec.Domain.Devices.Interfaces[i].MacAddress = "" |
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 its better also to put this in a function ClearMacAddress
pkg/util/util_test.go
Outdated
vm kvcore.VirtualMachine | ||
expected bool | ||
}{ | ||
{"Clear mac addres should return false", |
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.
the name of the tests should also explain what is tested i.e here: with no annotation, in the next with annotation false etc..
pkg/util/util_test.go
Outdated
{"Clear mac addres should return false", | ||
"VirtualMachine", | ||
kvcore.VirtualMachine{ | ||
{"Clear MAC address should return false", |
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 should add here "without label" and in the next test "with label"
vm.Spec.Template.Spec.Domain.Devices.Interfaces[0].MacAddress = originalMAC | ||
return vm | ||
} | ||
retryOnceOnErr(updateVm(f.KvClient, f.Namespace.Name, vm.Name, update)).Should(BeNil()) |
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 you should use patch 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.
This is a preexisting function used in several other tests, prefer to leave it here and consider refactoring the function itself in a follow-up.
tests/vm_backup_test.go
Outdated
Expect(err).ToNot(HaveOccurred()) | ||
Expect(phase).To(Equal(velerov1api.BackupPhaseCompleted)) | ||
|
||
By("Stopping VM") |
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.
why do you need to stop the vm before you delete 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.
Just a remnant from copy-pasting another test that does the same. I can remove it.
3ff4b30
to
2a82153
Compare
/test pull-kvp-functional-test |
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.
putting hold on it so Shelly can take a look, but if not before you want it merged, you have the lgtm
/hold
This commit allows to optionally clear the MAC address in VM and VMIs during restore. Currently, the way to go for modular backup/restore behavior in velero plugin is by using labels instead of annotations. Labels are easier to add to the restore/backup objects during creation as the velero client has a flag to include them. This commit also changes some const names to use PascalCase to match exported const naming standard. Signed-off-by: Eduardo Esteban <[email protected]> Signed-off-by: Alvaro Romero <[email protected]>
2a82153
to
7a72685
Compare
Signed-off-by: Alvaro Romero <[email protected]>
7a72685
to
423e3f3
Compare
/unhold |
Will backport this once #310 is merged, thanks @ShellyKa13! |
/cherrypick release-v0.7 |
1 similar comment
/cherrypick release-v0.7 |
@alromeros: #304 failed to apply on top of branch "release-v0.7":
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-sigs/prow repository. |
What this PR does / why we need it:
When a virtual machine is restored to an alternate namespace, the virtual machine is restored with the same MAC address as the original one. This results in a MAC address conflict if the original virtual machine is still running on the original namespace.
Though we already have a work-in-progress PR, recent interest in this feature has forced us to open a new one to address this issue. From now on, users can optionally clean a VM or VMI MAC address by setting the
"velero.kubevirt.io/clear-mac-address"
label in the restore object.Cherry-picked a couple of commits from #235 to keep the original contributor's work.
/cc @esteban-ee
Which issue(s) this PR fixes:
Fixes #199
Release note: