Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #72507: remove stale OutOfDisk condition from kubelet side #73394

Merged
merged 1 commit into from
Feb 23, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/kubelet/kubelet_node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ func (kl *Kubelet) defaultNodeStatusFuncs() []func(*v1.Node) error {
nodestatus.PIDPressureCondition(kl.clock.Now, kl.evictionManager.IsUnderPIDPressure, kl.recordNodeStatusEvent),
nodestatus.ReadyCondition(kl.clock.Now, kl.runtimeState.runtimeErrors, kl.runtimeState.networkErrors, validateHostFunc, kl.containerManager.Status, kl.recordNodeStatusEvent),
nodestatus.VolumesInUse(kl.volumeManager.ReconcilerStatesHasBeenSynced, kl.volumeManager.GetVolumesInUse),
nodestatus.RemoveOutOfDiskCondition(),
// TODO(mtaufen): I decided not to move this setter for now, since all it does is send an event
// and record state back to the Kubelet runtime object. In the future, I'd like to isolate
// these side-effects by decoupling the decisions to send events and partial status recording
Expand Down
15 changes: 15 additions & 0 deletions pkg/kubelet/nodestatus/setters.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,18 @@ func VolumeLimits(volumePluginListFunc func() []volume.VolumePluginWithAttachLim
return nil
}
}

// RemoveOutOfDiskCondition removes stale OutOfDisk condition
// OutOfDisk condition has been removed from kubelet in 1.12
func RemoveOutOfDiskCondition() Setter {
return func(node *v1.Node) error {
var conditions []v1.NodeCondition
for i := range node.Status.Conditions {
if node.Status.Conditions[i].Type != v1.NodeOutOfDisk {
conditions = append(conditions, node.Status.Conditions[i])
}
}
node.Status.Conditions = conditions
return nil
}
}
48 changes: 48 additions & 0 deletions pkg/kubelet/nodestatus/setters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,54 @@ func TestVolumeLimits(t *testing.T) {
}
}

func TestRemoveOutOfDiskCondition(t *testing.T) {
now := time.Now()

var cases = []struct {
desc string
inputNode *v1.Node
expectNode *v1.Node
}{
{
desc: "should remove stale OutOfDiskCondition from node status",
inputNode: &v1.Node{
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
*makeMemoryPressureCondition(false, now, now),
{
Type: v1.NodeOutOfDisk,
Status: v1.ConditionFalse,
},
*makeDiskPressureCondition(false, now, now),
},
},
},
expectNode: &v1.Node{
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
*makeMemoryPressureCondition(false, now, now),
*makeDiskPressureCondition(false, now, now),
},
},
},
},
}

for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
// construct setter
setter := RemoveOutOfDiskCondition()
// call setter on node
if err := setter(tc.inputNode); err != nil {
t.Fatalf("unexpected error: %v", err)
}
// check expected node
assert.True(t, apiequality.Semantic.DeepEqual(tc.expectNode, tc.inputNode),
"Diff: %s", diff.ObjectDiff(tc.expectNode, tc.inputNode))
})
}
}

// Test Helpers:

// sortableNodeAddress is a type for sorting []v1.NodeAddress
Expand Down