From 86465fdee5dacef170752ad18e2169f448b027e5 Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Fri, 8 Mar 2024 11:45:41 +0800 Subject: [PATCH] fix: use vm name to get vmi Signed-off-by: PoAn Yang --- pkg/cloud-controller-manager/instance.go | 2 +- pkg/controller/virtualmachineinstance/controller.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cloud-controller-manager/instance.go b/pkg/cloud-controller-manager/instance.go index c4d5f917..1cd33fdf 100644 --- a/pkg/cloud-controller-manager/instance.go +++ b/pkg/cloud-controller-manager/instance.go @@ -50,7 +50,7 @@ func (i *instanceManager) InstanceMetadata(ctx context.Context, node *v1.Node) ( ProviderID: ProviderName + "://" + string(vm.UID), } - vmi, err := i.vmiClient.Get(i.namespace, node.Name, metav1.GetOptions{}) + vmi, err := i.vmiClient.Get(i.namespace, vm.Name, metav1.GetOptions{}) if err != nil { if errors.IsNotFound(err) { return meta, nil diff --git a/pkg/controller/virtualmachineinstance/controller.go b/pkg/controller/virtualmachineinstance/controller.go index 6e63bdb4..9bad99b9 100644 --- a/pkg/controller/virtualmachineinstance/controller.go +++ b/pkg/controller/virtualmachineinstance/controller.go @@ -40,6 +40,7 @@ func Register( restClient: restClient, kubevirtClient: kubevirtClient, nodeToVMName: nodeToVMName, + namespace: namespace, } vmis.OnChange(ctx, vmiControllerName, handler.OnVmiChanged) }