Skip to content
Open
Changes from all commits
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: 11 additions & 1 deletion pkg/controller/virtualmachineinstance/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
)

const (
vmiControllerName = "harvester-cloudprovider-resync-topology"
vmiControllerName = "harvester-cloudprovider-resync-topology"
externallyManagedNodeLabel = "harvesterhci.io/externally-managed-node"
)

// Register the controller is helping to re-sync harvester node topology labels to guest cluster nodes.
Expand Down Expand Up @@ -75,6 +76,15 @@ func (h *Handler) OnVmiChanged(_ string, vmi *kubevirtv1.VirtualMachineInstance)
return vmi, nil
}

// Skip processing if the external-managed-node label is present
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mattmattox Thanks for your committing and sorry for the later review, as no one was assigned to review the PR.

The PR looks good, and I only have this question:

L88 has the check if creator := vmi.Labels[builder.LabelKeyVirtualMachineCreator]; creator != virtualmachine.VirtualMachineCreatorNodeDriver to skip the VM.

If you add external VMIs to the cluster, does the related VMI still happens to have LabelKeyVirtualMachineCreator label? could you utilize this existing label to skip it?

if _, exists := vmi.Labels[externallyManagedNodeLabel]; exists {
logrus.WithFields(logrus.Fields{
"namespace": vmi.Namespace,
"name": vmi.Name,
}).Info("skip processing virtual machine instance due to externally-managed-node label")
return vmi, nil
}

if creator := vmi.Labels[builder.LabelKeyVirtualMachineCreator]; creator != virtualmachine.VirtualMachineCreatorNodeDriver {
logrus.WithFields(logrus.Fields{
"namespace": vmi.Namespace,
Expand Down