Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 3517908

Browse files
authored
Merge pull request #652 from diegs/checkpointer-no-is-running-check
pod-checkpointer: remove isRunning check.
2 parents e5f5dde + 20a9e0b commit 3517908

File tree

2 files changed

+0
-74
lines changed

2 files changed

+0
-74
lines changed

cmd/checkpoint/main.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,6 @@ func process(localRunningPods, localParentPods, apiParentPods, activeCheckpoints
326326
//TODO(aaron): Add support for checkpointing configMaps
327327
func createCheckpointsForValidParents(client kubernetes.Interface, pods map[string]*v1.Pod) {
328328
for _, pod := range pods {
329-
// This merely check that the last kubelet pod state thinks this pod was running. It's possible that
330-
// state is actually stale (only as recent as last successful contact with api-server). However, this
331-
// does contain the full podSpec -- so we can still attempt to checkpoint with this "last known good state".
332-
//
333-
// We do not use the `localPodRunning` state, because while the runtime may think the pod/containers are running -
334-
// they may actually be in a failing state - and we've not successfully sent that podStatus to any api-server.
335-
if !isRunning(pod) {
336-
continue
337-
}
338329
id := PodFullName(pod)
339330

340331
cp, err := copyPod(pod)
@@ -692,18 +683,6 @@ func handleStart(start []string) {
692683
}
693684
}
694685

695-
func isRunning(pod *v1.Pod) bool {
696-
// Determine if a pod is "running" by checking if each container status is in a "ready" state
697-
// TODO(aaron): Figure out best sets of data to inspect. PodConditions, PodPhase, containerStatus, containerState, etc.
698-
for _, containerStatus := range pod.Status.ContainerStatuses {
699-
if !containerStatus.Ready {
700-
glog.Infof("Container %s in pod %s not ready. Will not checkpoint", containerStatus.Name, pod.Name)
701-
return false
702-
}
703-
}
704-
return true
705-
}
706-
707686
func podListToParentPods(pl *v1.PodList) map[string]*v1.Pod {
708687
return podListToMap(pl, isValidParent)
709688
}

cmd/checkpoint/main_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -472,59 +472,6 @@ func TestPodListToParentPods(t *testing.T) {
472472
}
473473
}
474474

475-
func TestIsRunning(t *testing.T) {
476-
type testCase struct {
477-
desc string
478-
pod *v1.Pod
479-
expected bool
480-
}
481-
482-
cases := []testCase{
483-
{
484-
desc: "Single container ready",
485-
pod: &v1.Pod{
486-
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: true}}},
487-
},
488-
expected: true,
489-
},
490-
{
491-
desc: "Multiple containers, all ready",
492-
pod: &v1.Pod{
493-
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: true}, {Ready: true}}},
494-
},
495-
expected: true,
496-
},
497-
{
498-
desc: "Single container not ready",
499-
pod: &v1.Pod{
500-
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: false}}},
501-
},
502-
expected: false,
503-
},
504-
{
505-
desc: "Multiple containers, some not ready",
506-
pod: &v1.Pod{
507-
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: true}, {Ready: false}}},
508-
},
509-
expected: false,
510-
},
511-
{
512-
desc: "Multiple containers, all not ready",
513-
pod: &v1.Pod{
514-
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: false}, {Ready: false}}},
515-
},
516-
expected: false,
517-
},
518-
}
519-
520-
for _, tc := range cases {
521-
got := isRunning(tc.pod)
522-
if tc.expected != got {
523-
t.Errorf("Expected: %t Got: %t for test: %s", tc.expected, got, tc.desc)
524-
}
525-
}
526-
}
527-
528475
func podWithAnnotations(a map[string]string) *v1.Pod {
529476
return &v1.Pod{
530477
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)