Check Docker init PID is valid before we use it.

This gives us an error if the PID is not returned as we expect.
This commit is contained in:
Victor Marmol 2015-02-20 13:10:40 -08:00
parent a5fdac2f3f
commit da2f4b6d61
2 changed files with 8 additions and 1 deletions

View File

@ -121,7 +121,10 @@ func (f *FakeDockerClient) StartContainer(id string, hostConfig *docker.HostConf
Name: id, // For testing purpose, we set name to id
Config: &docker.Config{Image: "testimage"},
HostConfig: hostConfig,
State: docker.State{Running: true},
State: docker.State{
Running: true,
Pid: 42,
},
}
return f.Err
}

View File

@ -961,6 +961,10 @@ func (kl *Kubelet) createPodInfraContainer(pod *api.BoundPod) (dockertools.Docke
return "", err
}
// Ensure the PID actually exists, else we'll move ourselves.
if containerInfo.State.Pid == 0 {
return "", fmt.Errorf("failed to get init PID for Docker pod infra container %q", string(id))
}
return id, util.ApplyOomScoreAdj(containerInfo.State.Pid, podOomScoreAdj)
}