Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions controllers/core/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ import (
// one routines to help high rate churn and larger nodes groups restarting
// when the controller has to be restarted for various reasons.
const (
NodeTerminationFinalizer = "networking.k8s.aws/resource-cleanup"
NodeTerminationFinalizer = "networking.k8s.aws/resource-cleanup"
computeTypeLabelKey = "eks.amazonaws.com/compute-type"
autoComputeTypeLabelValue = "auto"
)

// NodeReconciler reconciles a Node object
Expand Down Expand Up @@ -89,7 +91,11 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
}
return ctrl.Result{}, client.IgnoreNotFound(nodeErr)
}

computeKey, ok := node.Labels[computeTypeLabelKey]
if ok && computeKey == autoComputeTypeLabelValue {
logger.Info("node is auto compute type, skipping")
return ctrl.Result{}, nil
}
var err error

_, found := r.Manager.GetNode(req.Name)
Expand Down
26 changes: 26 additions & 0 deletions controllers/core/node_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,29 @@ func TestNodeReconciler_Reconcile_AddNode_Internal_Server_Error(t *testing.T) {
assert.Error(t, err, "We return error on internal server error to make sure it gets requeued by controller-runtime.")
assert.False(t, res.Requeue)
}

func TestNodeReconciler_Reconcile_SkipAutoComputeType(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

autoComputeNode := &corev1.Node{
ObjectMeta: v1.ObjectMeta{
Name: mockNodeName,
Labels: map[string]string{
computeTypeLabelKey: autoComputeTypeLabelValue,
},
},
}

mock := NewNodeMock(ctrl, autoComputeNode)

mock.Conditions.EXPECT().GetPodDataStoreSyncStatus().Return(true)
mock.Manager.EXPECT().AddNode(gomock.Any()).Times(0)
mock.Manager.EXPECT().UpdateNode(gomock.Any()).Times(0)
mock.Manager.EXPECT().GetNode(gomock.Any()).Times(0)
mock.Manager.EXPECT().CheckNodeForLeakedENIs(gomock.Any()).Times(0)

res, err := mock.Reconciler.Reconcile(context.TODO(), reconcileRequest)
assert.NoError(t, err)
assert.Equal(t, res, reconcile.Result{})
}