mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 10:48:15 +00:00
Nodecontroller doesn't flip readiness on pods if kubeletVersion < 1.2.0
This commit is contained in:
@@ -1398,6 +1398,9 @@ func TestMonitorNodeStatusMarkPodsNotReady(t *testing.T) {
|
||||
CreationTimestamp: unversioned.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{
|
||||
KubeletVersion: "v1.2.0",
|
||||
},
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Type: api.NodeReady,
|
||||
@@ -1428,6 +1431,9 @@ func TestMonitorNodeStatusMarkPodsNotReady(t *testing.T) {
|
||||
},
|
||||
timeToPass: 1 * time.Minute,
|
||||
newNodeStatus: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{
|
||||
KubeletVersion: "v1.2.0",
|
||||
},
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Type: api.NodeReady,
|
||||
@@ -1451,6 +1457,76 @@ func TestMonitorNodeStatusMarkPodsNotReady(t *testing.T) {
|
||||
},
|
||||
expectedPodStatusUpdate: true,
|
||||
},
|
||||
// Node created long time ago, with outdated kubelet version 1.1.0 and status
|
||||
// updated by kubelet exceeds grace period. Expect no action from node controller.
|
||||
{
|
||||
fakeNodeHandler: &FakeNodeHandler{
|
||||
Existing: []*api.Node{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "node0",
|
||||
CreationTimestamp: unversioned.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
|
||||
},
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{
|
||||
KubeletVersion: "v1.1.0",
|
||||
},
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionTrue,
|
||||
// Node status hasn't been updated for 1hr.
|
||||
LastHeartbeatTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
LastTransitionTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
},
|
||||
{
|
||||
Type: api.NodeOutOfDisk,
|
||||
Status: api.ConditionFalse,
|
||||
// Node status hasn't been updated for 1hr.
|
||||
LastHeartbeatTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
LastTransitionTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
Capacity: api.ResourceList{
|
||||
api.ResourceName(api.ResourceCPU): resource.MustParse("10"),
|
||||
api.ResourceName(api.ResourceMemory): resource.MustParse("10G"),
|
||||
},
|
||||
},
|
||||
Spec: api.NodeSpec{
|
||||
ExternalID: "node0",
|
||||
},
|
||||
},
|
||||
},
|
||||
Clientset: fake.NewSimpleClientset(&api.PodList{Items: []api.Pod{*newPod("pod0", "node0")}}),
|
||||
},
|
||||
timeToPass: 1 * time.Minute,
|
||||
newNodeStatus: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{
|
||||
KubeletVersion: "v1.1.0",
|
||||
},
|
||||
Conditions: []api.NodeCondition{
|
||||
{
|
||||
Type: api.NodeReady,
|
||||
Status: api.ConditionTrue,
|
||||
// Node status hasn't been updated for 1hr.
|
||||
LastHeartbeatTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
LastTransitionTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
},
|
||||
{
|
||||
Type: api.NodeOutOfDisk,
|
||||
Status: api.ConditionFalse,
|
||||
// Node status hasn't been updated for 1hr.
|
||||
LastHeartbeatTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
LastTransitionTime: unversioned.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
Capacity: api.ResourceList{
|
||||
api.ResourceName(api.ResourceCPU): resource.MustParse("10"),
|
||||
api.ResourceName(api.ResourceMemory): resource.MustParse("10G"),
|
||||
},
|
||||
},
|
||||
expectedPodStatusUpdate: false,
|
||||
},
|
||||
}
|
||||
|
||||
for i, item := range table {
|
||||
@@ -1799,3 +1875,63 @@ func TestCleanupOrphanedPods(t *testing.T) {
|
||||
t.Fatalf("expected deleted pod name to be 'c', but got: %q", deletedPodName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckNodeKubeletVersionParsing(t *testing.T) {
|
||||
tests := []struct {
|
||||
version string
|
||||
outdated bool
|
||||
}{
|
||||
{
|
||||
version: "",
|
||||
outdated: true,
|
||||
},
|
||||
{
|
||||
version: "v0.21.4",
|
||||
outdated: true,
|
||||
},
|
||||
{
|
||||
version: "v1.0.0",
|
||||
outdated: true,
|
||||
},
|
||||
{
|
||||
version: "v1.1.0",
|
||||
outdated: true,
|
||||
},
|
||||
{
|
||||
version: "v1.1.0-alpha.2.961+9d4c6846fc03b9-dirty",
|
||||
outdated: true,
|
||||
},
|
||||
{
|
||||
version: "v1.2.0",
|
||||
outdated: false,
|
||||
},
|
||||
{
|
||||
version: "v1.3.3",
|
||||
outdated: false,
|
||||
},
|
||||
{
|
||||
version: "v1.4.0-alpha.2.961+9d4c6846fc03b9-dirty",
|
||||
outdated: false,
|
||||
},
|
||||
{
|
||||
version: "v2.0.0",
|
||||
outdated: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, ov := range tests {
|
||||
n := &api.Node{
|
||||
Status: api.NodeStatus{
|
||||
NodeInfo: api.NodeSystemInfo{
|
||||
KubeletVersion: ov.version,
|
||||
},
|
||||
},
|
||||
}
|
||||
isOutdated := nodeRunningOutdatedKubelet(n)
|
||||
if ov.outdated != isOutdated {
|
||||
t.Errorf("Version %v doesn't match test expectation. Expected outdated %v got %v", n.Status.NodeInfo.KubeletVersion, ov.outdated, isOutdated)
|
||||
} else {
|
||||
t.Logf("Version %v outdated %v", ov.version, isOutdated)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user