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

clear MAC addresses on restore #235

Closed
wants to merge 2 commits into from

Conversation

esteban-ee
Copy link

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 virtual machine. This results in a MAC address conflict when the original virtual machine is still running on the original namespace.

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 #
#199

Special notes for your reviewer:

Release note:


@kubevirt-bot kubevirt-bot requested a review from aglitke March 25, 2024 20:50
@kubevirt-bot kubevirt-bot added the dco-signoff: no Indicates the PR's author has not DCO signed all their commits. label Mar 25, 2024
@kubevirt-bot kubevirt-bot requested a review from mhenriks March 25, 2024 20:50
@kubevirt-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign aglitke for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link

Hi @esteban-ee. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@@ -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++ {
vm.Spec.Template.Spec.Domain.Devices.Interfaces[i].MacAddress = ""
Copy link
Member

Choose a reason for hiding this comment

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

What about users that want to preserve the mac address?

I think a better solution would be to add an annotation to the VM like backup.kubevirt.io/clearMacAddress: true and if that's set, the plugin will clear the mac

Copy link
Author

Choose a reason for hiding this comment

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

right, added annotation check

Eduartdo Esteban added 2 commits April 25, 2024 12:43
Signed-off-by: Eduardo Esteban <[email protected]>
Signed-off-by: Eduardo Esteban <[email protected]>
@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 Apr 25, 2024
@mhenriks
Copy link
Member

I think the approach in #248 is preferable. When restoring to existing namespace, preserve macs otherwise clear

@esteban-ee
Copy link
Author

I think the approach in #248 is preferable. When restoring to existing namespace, preserve macs otherwise clear

Yes, #248 looks good, thanks

@BAMSHK
Copy link

BAMSHK commented Jul 24, 2024

I believe it's best to check for MAC address conflicts before restoration. If a VM is being restored into a different namespace and the original VM no longer exists in its original namespace, would it still be necessary to clear the MAC addresses?

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 2, 2024
@kubevirt-bot
Copy link

PR needs rebase.

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.

@kubevirt-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@kubevirt-bot kubevirt-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 31, 2024
@@ -365,3 +366,12 @@ func AddVMIObjectGraph(spec v1.VirtualMachineInstanceSpec, namespace string, ext
return extra

}

func IsMacAdressClearedByAnnotation(vm *v1.VirtualMachine) (bool) {
annotations := vm.GetAnnotations()
Copy link
Contributor

Choose a reason for hiding this comment

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

It may make more sense to have the annotation in the restore object so the decision about clearing mac address out can be made retroactively.

Copy link
Contributor

@alromeros alromeros left a comment

Choose a reason for hiding this comment

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

Hey @esteban-ee, many thanks for the contribution! I'm interested in merging this but there are a couple of things we should consider first. Are you still working on this?

@@ -28,6 +28,7 @@ import (
)

const VELERO_EXCLUDE_LABEL = "velero.io/exclude-from-backup"
const CLEAR_MAC_ADDRESS_ANNOTATION = "restore.kubevirt.io/clear-mac-address"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also say to support a label too since currently, velero client only allows adding labels to the backup/restore objects during creation. It'd be easier for users to also allow a label and we can deprecate it once the client support annotations (PR is already merged).

@alromeros alromeros mentioned this pull request Dec 11, 2024
@alromeros
Copy link
Contributor

#304 was merged so it's appropriate to close this PR. @esteban-ee thank you for your contribution, I cherry-picked your commits so the contribution is still in the code base. Thanks!
/close

@kubevirt-bot
Copy link

@alromeros: Closed this PR.

In response to this:

#304 was merged so it's appropriate to close this PR. @esteban-ee thank you for your contribution, I cherry-picked your commits so the contribution is still in the code base. Thanks!
/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants