Skip to content

Commit bfeefad

Browse files
committed
Handle virtual nodes and missing node pools to avoid crash
1 parent ff8a810 commit bfeefad

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cluster-autoscaler/cloudprovider/oci/nodepools/oci_cloud_provider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
"k8s.io/apimachinery/pkg/api/resource"
1111
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
1212
ocicommon "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/oci/common"
13+
npconsts "k8s.io/autoscaler/cluster-autoscaler/cloudprovider/oci/nodepools/consts"
1314
caerrors "k8s.io/autoscaler/cluster-autoscaler/utils/errors"
1415
"k8s.io/autoscaler/cluster-autoscaler/utils/gpu"
1516
klog "k8s.io/klog/v2"
17+
"strings"
1618
)
1719

1820
// OciCloudProvider creates a cloud provider object that is compatible with node pools
@@ -86,6 +88,11 @@ func (ocp *OciCloudProvider) HasInstance(node *apiv1.Node) (bool, error) {
8688
if err != nil {
8789
return true, err
8890
}
91+
// Handle virtual nodes and missing node pools to avoid crash
92+
if np == nil || np.Id() == "" || strings.Contains(instance.InstanceID, npconsts.OciVirtualNodeResourceIdent) {
93+
return false, cloudprovider.ErrNotImplemented
94+
}
95+
8996
nodes, err := ocp.manager.GetNodePoolNodes(np)
9097
if err != nil {
9198
return true, err

0 commit comments

Comments
 (0)