GoogleCloudPlatform/kubernetes — pull request #1147 by dchen1107 (2014-09-03 04:57:35+00:00)
Title: Introduce the simplest RestartPolicy and handling.

I am still adding unittests to the PR. But since I have hold this PR for too long, and know someone are waiting for this, I decided to cut it simple and sent it out for the initial review. I ran manual tests with all three different restart policy: Never, Always, and OnFailure, all are working.

Besides unittests, to make sure the whole workflow with restart work fine, there are TODOs listed below, and I will include them in separate PRs:

1) Status defined for Pod only have 3 types: Running, Waiting and Terminated. When a container in Pod are failed, and shouldn't restart based on RestartPolicy, the Status of Pod is changed to Waiting from Running, which is wrong. Should we introduce a new Status type, such as Error here?

2) GetPodStatus only gets current running Container info from Docker. We should include previous failed container info too.

3) Pod's CurrentState should have how many attempts on restart.

4) When kubecfg delete pods, it should call DockerClient.RemoveContainer too; otherwise the GetRecentDockerContainersWithName will include previous dead containers, and mess up maxAttempts logic.

5) DelaySeconds should be checked before running a container