From e456e7e6260ca63bbd83bbd247b552a291625b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cgkazanci=E2=80=9D?= Date: Fri, 1 Nov 2024 13:27:48 +0000 Subject: [PATCH 1/2] exclude self-managed nodes from being processed --- cluster-autoscaler/cloudprovider/oci/common/oci_ref.go | 2 ++ .../cloudprovider/oci/nodepools/oci_cloud_provider.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go b/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go index b6b6465916ff..d8323f71671f 100644 --- a/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go +++ b/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go @@ -21,6 +21,7 @@ type OciRef struct { PrivateIPAddress string PublicIPAddress string Shape string + IsNodeSelfManaged bool } // NodeToOciRef converts a node object into an oci reference @@ -36,6 +37,7 @@ func NodeToOciRef(n *apiv1.Node) (OciRef, error) { PrivateIPAddress: getNodeInternalAddress(n), PublicIPAddress: getNodeExternalAddress(n), Shape: getNodeShape(n), + IsNodeSelfManaged: n.Labels["oci.oraclecloud.com/node.info.byon"] != "", }, nil } diff --git a/cluster-autoscaler/cloudprovider/oci/nodepools/oci_cloud_provider.go b/cluster-autoscaler/cloudprovider/oci/nodepools/oci_cloud_provider.go index b97f98fc6179..ae3f70549151 100644 --- a/cluster-autoscaler/cloudprovider/oci/nodepools/oci_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/oci/nodepools/oci_cloud_provider.go @@ -54,6 +54,10 @@ func (ocp *OciCloudProvider) NodeGroupForNode(n *apiv1.Node) (cloudprovider.Node return nil, err } + // self-managed-nodes aren't expected to be managed by cluster-autoscaler + if ociRef.IsNodeSelfManaged { + return nil, nil + } ng, err := ocp.manager.GetNodePoolForInstance(ociRef) // this instance may be part of a node pool that the autoscaler does not handle @@ -75,6 +79,9 @@ func (ocp *OciCloudProvider) HasInstance(node *apiv1.Node) (bool, error) { if err != nil { return true, err } + if instance.IsNodeSelfManaged { + return false, nil + } np, err := ocp.manager.GetNodePoolForInstance(instance) if err != nil { return true, err From a9d5b64eb95dba75ec126dcdd97cb7b4dc0c8afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cgkazanci=E2=80=9D?= Date: Mon, 4 Nov 2024 11:00:22 +0000 Subject: [PATCH 2/2] checking the self managed node with label and the value --- cluster-autoscaler/cloudprovider/oci/common/oci_ref.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go b/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go index d8323f71671f..df5f3ec488e8 100644 --- a/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go +++ b/cluster-autoscaler/cloudprovider/oci/common/oci_ref.go @@ -37,7 +37,7 @@ func NodeToOciRef(n *apiv1.Node) (OciRef, error) { PrivateIPAddress: getNodeInternalAddress(n), PublicIPAddress: getNodeExternalAddress(n), Shape: getNodeShape(n), - IsNodeSelfManaged: n.Labels["oci.oraclecloud.com/node.info.byon"] != "", + IsNodeSelfManaged: n.Labels["oci.oraclecloud.com/node.info.byon"] == "true", }, nil }