Skip to content

Commit

Permalink
Merge pull request #6265 from zendesk/grosser/spam
Browse files Browse the repository at this point in the history
allow users to avoid aws instance not found spam
  • Loading branch information
k8s-ci-robot authored Nov 20, 2023
2 parents 8de60c9 + 2b8874d commit 81eed96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ func (aws *awsCloudProvider) HasInstance(node *apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
}

// avoid log spam for not autoscaled asgs:
// Nodes that belong to an asg that is not autoscaled will not be found in the asgCache below,
// so do not trigger warning spam by returning an error from being unable to find them.
// Annotation is not automated, but users that see the warning can add the annotation to avoid it.
if node.Annotations != nil && node.Annotations["k8s.io/cluster-autoscaler/enabled"] == "false" {
return false, nil
}

awsRef, err := AwsRefFromProviderId(node.Spec.ProviderID)
if err != nil {
return false, err
Expand Down
15 changes: 15 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,4 +723,19 @@ func TestHasInstance(t *testing.T) {
assert.ErrorContains(t, err, nodeNotPresentErr)
assert.False(t, present)

// Case 4: correct node - not autoscaled -> not present in AWS -> no warning
node4 := &apiv1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node-2",
Annotations: map[string]string{
"k8s.io/cluster-autoscaler/enabled": "false",
},
},
Spec: apiv1.NodeSpec{
ProviderID: "aws:///us-east-1a/test-instance-id-2",
},
}
present, err = provider.HasInstance(node4)
assert.NoError(t, err)
assert.False(t, present)
}

0 comments on commit 81eed96

Please sign in to comment.