From de16a925defecdd9d813b6e917cf78a5b2fa39fa Mon Sep 17 00:00:00 2001 From: Omer Aplatony Date: Thu, 3 Oct 2024 14:13:52 +0300 Subject: [PATCH] Fix nil handling in NodeGroupForNode wrapper Signed-off-by: Omer Aplatony --- .../external-grpc-cloud-provider-service/wrapper/wrapper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cluster-autoscaler/cloudprovider/externalgrpc/examples/external-grpc-cloud-provider-service/wrapper/wrapper.go b/cluster-autoscaler/cloudprovider/externalgrpc/examples/external-grpc-cloud-provider-service/wrapper/wrapper.go index 10a5a4fae6cb..ae57430d9624 100644 --- a/cluster-autoscaler/cloudprovider/externalgrpc/examples/external-grpc-cloud-provider-service/wrapper/wrapper.go +++ b/cluster-autoscaler/cloudprovider/externalgrpc/examples/external-grpc-cloud-provider-service/wrapper/wrapper.go @@ -19,6 +19,7 @@ package wrapper import ( "context" "fmt" + "reflect" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -99,7 +100,8 @@ func (w *Wrapper) NodeGroupForNode(_ context.Context, req *protos.NodeGroupForNo if err != nil { return nil, err } - if ng == nil { + // Checks if ng is nil interface or contains nil value + if ng == nil || reflect.ValueOf(ng).IsNil() { return &protos.NodeGroupForNodeResponse{ NodeGroup: &protos.NodeGroup{}, //NodeGroup with id = "", meaning the node should not be processed by cluster autoscaler }, nil