Merge pull request #8047 from raykrueger/aws-eks-hybrid-nodes-fix

fix: AWSCloudProvider should ignore unrecognized provider IDs
This commit is contained in:
Kubernetes Prow Robot 2025-05-04 15:25:56 -07:00 committed by GitHub
commit 9cdcc284ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -117,7 +117,9 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
}
ref, err := AwsRefFromProviderId(node.Spec.ProviderID)
if err != nil {
return nil, err
// Dropping this into V as it will be noisy with many Hybrid Nodes
klog.V(6).Infof("Node %v has unrecognized providerId: %v", node.Name, node.Spec.ProviderID)
return nil, nil
}
asg := aws.awsManager.GetAsgForInstance(*ref)

View File

@ -18,6 +18,8 @@ package aws
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
apiv1 "k8s.io/api/core/v1"
@ -26,7 +28,6 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/aws/aws-sdk-go/aws"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/aws/aws-sdk-go/service/autoscaling"
"k8s.io/autoscaler/cluster-autoscaler/config"
"testing"
)
var testAwsManager = &AwsManager{
@ -251,6 +252,20 @@ func TestNodeGroupForNodeWithNoProviderId(t *testing.T) {
assert.Equal(t, group, nil)
}
func TestNodeGroupForNodeWithHybridNode(t *testing.T) {
hybridNode := &apiv1.Node{
Spec: apiv1.NodeSpec{
ProviderID: "eks-hybrid:///us-west-2/my-cluster/my-node-1",
},
}
a := &autoScalingMock{}
provider := testProvider(t, newTestAwsManagerWithAsgs(t, a, nil, []string{"1:5:test-asg"}))
group, err := provider.NodeGroupForNode(hybridNode)
assert.NoError(t, err)
assert.Nil(t, group)
}
func TestAwsRefFromProviderId(t *testing.T) {
tests := []struct {
provID string