From fa4dad456867fcfb8f61d74b3b8d78deadfa87c4 Mon Sep 17 00:00:00 2001 From: Gaurav Ghildiyal Date: Mon, 7 Jul 2025 20:58:37 -0700 Subject: [PATCH] fix: Do not fail if physical location of VM is not available --- pkg/cloudprovider/gce/gce.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/cloudprovider/gce/gce.go b/pkg/cloudprovider/gce/gce.go index 33f44136..d2bc9902 100644 --- a/pkg/cloudprovider/gce/gce.go +++ b/pkg/cloudprovider/gce/gce.go @@ -95,12 +95,16 @@ func GetInstance(ctx context.Context) (*cloudprovider.CloudInstance, error) { klog.Infof("could not get network interfaces on GCE ... retrying: %v", err) return false, nil } + // Physical location of VM is not always available. We don't fail if + // it's not available. + // + // Ref. https://cloud.google.com/compute/docs/instances/use-compact-placement-policies#verify-vm-location gceTopologyAttributes, err := metadata.GetWithContext(ctx, "instance/attributes/physical_host") if err != nil { - klog.Infof("could not get physical host on GCE ... retrying: %v", err) - return false, nil + klog.Warningf("Failed to retrieve physical host for GCE VM %q, this maybe normal since not all VMs and VM types have this populated: %v", instanceName, err) + } else { + instance.Topology = gceTopologyAttributes } - instance.Topology = gceTopologyAttributes return true, nil }) if err != nil {