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

Add 'app' label to the template of the migrated VM #671

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkg/controller/plan/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (r *KubeVirt) EnsureVM(vm *plan.VMStatus) (err error) {
return
}

virtualMachine := &cnv.VirtualMachine{}
var virtualMachine *cnv.VirtualMachine
if len(list.Items) == 0 {
virtualMachine = newVM
err = r.Destination.Client.Create(context.TODO(), virtualMachine)
Expand Down Expand Up @@ -1075,6 +1075,12 @@ func (r *KubeVirt) virtualMachine(vm *plan.VMStatus) (object *cnv.VirtualMachine
object = r.emptyVm(vm)
}

if object.Spec.Template.ObjectMeta.Labels == nil {
object.Spec.Template.ObjectMeta.Labels = map[string]string{}
}
// Set the 'app' label for identification of the virtual machine instance(s)
object.Spec.Template.ObjectMeta.Labels["app"] = vm.Name

//Add the original name and ID info to the VM annotations
if len(originalName) > 0 {
annotations := make(map[string]string)
Expand Down Expand Up @@ -1164,7 +1170,9 @@ func (r *KubeVirt) emptyVm(vm *plan.VMStatus) (virtualMachine *cnv.VirtualMachin
Labels: r.vmLabels(vm.Ref),
Name: vm.Name,
},
Spec: cnv.VirtualMachineSpec{},
Spec: cnv.VirtualMachineSpec{
Template: &cnv.VirtualMachineInstanceTemplateSpec{},
},
}
return
}
Expand Down
Loading