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

Commit

Permalink
Merge pull request #652 from diegs/checkpointer-no-is-running-check
Browse files Browse the repository at this point in the history
pod-checkpointer: remove isRunning check.
  • Loading branch information
diegs authored Jul 19, 2017
2 parents e5f5dde + 20a9e0b commit 3517908
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 74 deletions.
21 changes: 0 additions & 21 deletions cmd/checkpoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,6 @@ func process(localRunningPods, localParentPods, apiParentPods, activeCheckpoints
//TODO(aaron): Add support for checkpointing configMaps
func createCheckpointsForValidParents(client kubernetes.Interface, pods map[string]*v1.Pod) {
for _, pod := range pods {
// This merely check that the last kubelet pod state thinks this pod was running. It's possible that
// state is actually stale (only as recent as last successful contact with api-server). However, this
// does contain the full podSpec -- so we can still attempt to checkpoint with this "last known good state".
//
// We do not use the `localPodRunning` state, because while the runtime may think the pod/containers are running -
// they may actually be in a failing state - and we've not successfully sent that podStatus to any api-server.
if !isRunning(pod) {
continue
}
id := PodFullName(pod)

cp, err := copyPod(pod)
Expand Down Expand Up @@ -692,18 +683,6 @@ func handleStart(start []string) {
}
}

func isRunning(pod *v1.Pod) bool {
// Determine if a pod is "running" by checking if each container status is in a "ready" state
// TODO(aaron): Figure out best sets of data to inspect. PodConditions, PodPhase, containerStatus, containerState, etc.
for _, containerStatus := range pod.Status.ContainerStatuses {
if !containerStatus.Ready {
glog.Infof("Container %s in pod %s not ready. Will not checkpoint", containerStatus.Name, pod.Name)
return false
}
}
return true
}

func podListToParentPods(pl *v1.PodList) map[string]*v1.Pod {
return podListToMap(pl, isValidParent)
}
Expand Down
53 changes: 0 additions & 53 deletions cmd/checkpoint/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,59 +472,6 @@ func TestPodListToParentPods(t *testing.T) {
}
}

func TestIsRunning(t *testing.T) {
type testCase struct {
desc string
pod *v1.Pod
expected bool
}

cases := []testCase{
{
desc: "Single container ready",
pod: &v1.Pod{
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: true}}},
},
expected: true,
},
{
desc: "Multiple containers, all ready",
pod: &v1.Pod{
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: true}, {Ready: true}}},
},
expected: true,
},
{
desc: "Single container not ready",
pod: &v1.Pod{
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: false}}},
},
expected: false,
},
{
desc: "Multiple containers, some not ready",
pod: &v1.Pod{
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: true}, {Ready: false}}},
},
expected: false,
},
{
desc: "Multiple containers, all not ready",
pod: &v1.Pod{
Status: v1.PodStatus{ContainerStatuses: []v1.ContainerStatus{{Ready: false}, {Ready: false}}},
},
expected: false,
},
}

for _, tc := range cases {
got := isRunning(tc.pod)
if tc.expected != got {
t.Errorf("Expected: %t Got: %t for test: %s", tc.expected, got, tc.desc)
}
}
}

func podWithAnnotations(a map[string]string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 3517908

Please sign in to comment.