Unexpected primary election when shutdown primary node in k8s update

In docker containers, once the process that is set to run at the start shutdowns itself, the container will also be terminated.

preStop hook helps with this: it tells mongod to shutdown itself, it does so gracefully (unless timed out), and once mongod is stopped the container also shuts down itself.

Though I hoped to be wrong, as you too mentioned in your github follow up post, it seems container’s network is cut off early. This might be a bug in k8s, or it might be set somewhere else in it so pod resources stay up until main container process exits/dies.

Please keep us updated.