[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: What if a container dies in OpenShift?



On Wed, Nov 25, 2015 at 2:23 PM, Den Cowboy <dencowboy hotmail com> wrote:
Hmm, okay so restartpolicty will be set 'always'. And when it's 'always' it will be defined by the replication controller. But the RC is only working on pod-level. So new pods will be recreated thanks to the RC. But the RC describes nothing about containers? So when A pod is still running but the container in it is dead, than there will happen nothing?

I'm sorry, I'm probably wrong but I do not understand it at the moment.
Thanks


By default the restartpolicy is set to always. That applies to both pods and their containers.
Maybe I'll illustrate with an example I just ran locally:


[vagrant openshiftdev ~]$ oc project default
Now using project "default" on server "https://10.0.2.15:8443".
[vagrant openshiftdev ~]$ oc get pods
NAME                      READY     STATUS    RESTARTS   AGE
docker-registry-1-mqqmk   1/1       Running   0          33s
[vagrant openshiftdev ~]$ docker ps | grep registry
ef318d7839f8        openshift/origin-docker-registry:v1.1   "/bin/sh -c 'REGISTRY"   49 seconds ago      Up 48 seconds                           k8s_registry.ea5217cb_docker-registry-1-mqqmk_default_64a5c92c-937a-11e5-b5a1-080027c5bfa9_18eb84e5
65e675979b64        openshift/origin-pod:v1.1               "/pod"                   50 seconds ago      Up 49 seconds                           k8s_POD.cc3ffd58_docker-registry-1-mqqmk_default_64a5c92c-937a-11e5-b5a1-080027c5bfa9_21e3cc20
[vagrant openshiftdev ~]$ docker kill ef318d7839f8
ef318d7839f8
[vagrant openshiftdev ~]$ oc get pods
NAME                      READY     STATUS    RESTARTS   AGE
docker-registry-1-mqqmk   1/1       Running   1          1m
[vagrant openshiftdev ~]$ docker ps | grep registry
fd08b9cdfd90        openshift/origin-docker-registry:v1.1   "/bin/sh -c 'REGISTRY"   15 seconds ago      Up 13 seconds                           k8s_registry.ea5217cb_docker-registry-1-mqqmk_default_64a5c92c-937a-11e5-b5a1-080027c5bfa9_0ab0a013
65e675979b64        openshift/origin-pod:v1.1               "/pod"                   2 minutes ago       Up About a minute                       k8s_POD.cc3ffd58_docker-registry-1-mqqmk_default_64a5c92c-937a-11e5-b5a1-080027c5bfa9_21e3cc20



I killed a container that was running my registry, and the container was restarted. Note that the container name changed, but the pod did not change.


I don't know for sure about the implementation, but since Docker 1.2 there's an option to configure container restart policy.
https://blog.docker.com/2014/08/announcing-docker-1-2-0/

It's either that, or the statement "the RC is only working on pod-level" is not entirely true.

Either way, you have a guarantee that pod and container restarts obey the same policy, set on the pod level.


HTH,

--
Rodolfo Carvalho

OpenShift Developer Experience

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]