Skip to content

Commit c3b4991

Browse files
authored
ignoring nodes with auto compute type (#608)
1 parent 94e0a2b commit c3b4991

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

controllers/core/node_controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ import (
3939
// one routines to help high rate churn and larger nodes groups restarting
4040
// when the controller has to be restarted for various reasons.
4141
const (
42-
NodeTerminationFinalizer = "networking.k8s.aws/resource-cleanup"
42+
NodeTerminationFinalizer = "networking.k8s.aws/resource-cleanup"
43+
computeTypeLabelKey = "eks.amazonaws.com/compute-type"
44+
autoComputeTypeLabelValue = "auto"
4345
)
4446

4547
// NodeReconciler reconciles a Node object
@@ -89,7 +91,11 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
8991
}
9092
return ctrl.Result{}, client.IgnoreNotFound(nodeErr)
9193
}
92-
94+
computeKey, ok := node.Labels[computeTypeLabelKey]
95+
if ok && computeKey == autoComputeTypeLabelValue {
96+
logger.Info("node is auto compute type, skipping")
97+
return ctrl.Result{}, nil
98+
}
9399
var err error
94100

95101
_, found := r.Manager.GetNode(req.Name)

controllers/core/node_controller_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,29 @@ func TestNodeReconciler_Reconcile_AddNode_Internal_Server_Error(t *testing.T) {
186186
assert.Error(t, err, "We return error on internal server error to make sure it gets requeued by controller-runtime.")
187187
assert.False(t, res.Requeue)
188188
}
189+
190+
func TestNodeReconciler_Reconcile_SkipAutoComputeType(t *testing.T) {
191+
ctrl := gomock.NewController(t)
192+
defer ctrl.Finish()
193+
194+
autoComputeNode := &corev1.Node{
195+
ObjectMeta: v1.ObjectMeta{
196+
Name: mockNodeName,
197+
Labels: map[string]string{
198+
computeTypeLabelKey: autoComputeTypeLabelValue,
199+
},
200+
},
201+
}
202+
203+
mock := NewNodeMock(ctrl, autoComputeNode)
204+
205+
mock.Conditions.EXPECT().GetPodDataStoreSyncStatus().Return(true)
206+
mock.Manager.EXPECT().AddNode(gomock.Any()).Times(0)
207+
mock.Manager.EXPECT().UpdateNode(gomock.Any()).Times(0)
208+
mock.Manager.EXPECT().GetNode(gomock.Any()).Times(0)
209+
mock.Manager.EXPECT().CheckNodeForLeakedENIs(gomock.Any()).Times(0)
210+
211+
res, err := mock.Reconciler.Reconcile(context.TODO(), reconcileRequest)
212+
assert.NoError(t, err)
213+
assert.Equal(t, res, reconcile.Result{})
214+
}

0 commit comments

Comments
 (0)