Skip to content
Open
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
9 changes: 9 additions & 0 deletions controllers/nodelifecycle/node_lifecycle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import (
const (
deleteNodeEvent = "DeletingNode"
deleteNodeFailedEvent = "DeletingNodeFailed"

// LabelNodeLifecycleExclude is the label used to exclude a node from lifecycle management
LabelNodeLifecycleExclude = "node.kubernetes.io/exclude-from-lifecycle-management"
)

var ShutdownTaint = &v1.Taint{
Expand Down Expand Up @@ -134,6 +137,12 @@ func (c *CloudNodeLifecycleController) MonitorNodes(ctx context.Context) {
}

for _, node := range nodes {
// Skip nodes with the lifecycle exclusion label
if _, excluded := node.Labels[LabelNodeLifecycleExclude]; excluded {
klog.V(4).Infof("Skipping node %s due to exclusion label %s", node.Name, LabelNodeLifecycleExclude)
continue
}

// Default NodeReady status to v1.ConditionUnknown
status := v1.ConditionUnknown
if _, c := nodeutil.GetNodeCondition(&node.Status, v1.NodeReady); c != nil {
Expand Down
45 changes: 45 additions & 0 deletions controllers/nodelifecycle/node_lifecycle_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,51 @@ func Test_NodesDeleted(t *testing.T) {
ExistsByProviderID: false,
},
},
{
name: "node is not ready and does not exist, but has exclusion label",
existingNode: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
Labels: map[string]string{
LabelNodeLifecycleExclude: "true",
},
},
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
{
Type: v1.NodeReady,
Status: v1.ConditionFalse,
LastHeartbeatTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
LastTransitionTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
},
},
},
},
expectedNode: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
Labels: map[string]string{
LabelNodeLifecycleExclude: "true",
},
},
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
{
Type: v1.NodeReady,
Status: v1.ConditionFalse,
LastHeartbeatTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
LastTransitionTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
},
},
},
},
expectedDeleted: false,
fakeCloud: &fakecloud.Cloud{
ExistsByProviderID: false,
},
},
}

for _, testcase := range testcases {
Expand Down