Skip to content

Commit

Permalink
extract fargate into a standalone file
Browse files Browse the repository at this point in the history
Signed-off-by: Davanum Srinivas <[email protected]>
  • Loading branch information
dims committed May 19, 2024
1 parent 389877c commit 2e10be6
Show file tree
Hide file tree
Showing 15 changed files with 613 additions and 381 deletions.
7 changes: 5 additions & 2 deletions pkg/controllers/tagging/tagging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
nodehelpers "k8s.io/cloud-provider/node/helpers"
_ "k8s.io/component-base/metrics/prometheus/workqueue" // enable prometheus provider for workqueue metrics
"k8s.io/klog/v2"

"k8s.io/cloud-provider-aws/pkg/providers/v1/variant"
)

func init() {
Expand Down Expand Up @@ -231,8 +233,9 @@ func (tc *Controller) process() bool {
}
klog.Infof("Instance ID of work item %s is %s", workItem, instanceID)

if awsv1.IsFargateNode(string(instanceID)) {
klog.Infof("Skip processing the node %s since it is a Fargate node", instanceID)
if variant.IsVariantNode(string(instanceID)) {
klog.Infof("Skip processing the node %s since it is a %s node",
instanceID, variant.NodeType(string(instanceID)))
tc.workqueue.Forget(obj)
return nil
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/controllers/tagging/tagging_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/util/workqueue"
awsv1 "k8s.io/cloud-provider-aws/pkg/providers/v1"
"k8s.io/cloud-provider-aws/pkg/providers/v1/config"
"k8s.io/klog/v2"
)

Expand Down Expand Up @@ -133,7 +134,7 @@ func Test_NodesJoiningAndLeaving(t *testing.T) {
},
},
toBeTagged: true,
expectedMessages: []string{"Skip processing the node fargate-ip-10-0-55-27.us-west-2.compute.internal since it is a Fargate node"},
expectedMessages: []string{"Skip processing the node fargate-ip-10-0-55-27.us-west-2.compute.internal since it is a fargate node"},
},
{
name: "node0 leaves the cluster, failed to untag.",
Expand Down Expand Up @@ -194,7 +195,7 @@ func Test_NodesJoiningAndLeaving(t *testing.T) {
}

awsServices := awsv1.NewFakeAWSServices(TestClusterID)
fakeAws, _ := awsv1.NewAWSCloud(awsv1.CloudConfig{}, awsServices)
fakeAws, _ := awsv1.NewAWSCloud(config.CloudConfig{}, awsServices)

for _, testcase := range testcases {
t.Run(testcase.name, func(t *testing.T) {
Expand Down
Loading

0 comments on commit 2e10be6

Please sign in to comment.