Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit init-process when all services have died #18

Closed
gdraheim opened this issue Nov 24, 2017 · 4 comments
Closed

exit init-process when all services have died #18

gdraheim opened this issue Nov 24, 2017 · 4 comments
Milestone

Comments

@gdraheim
Copy link
Owner

As an alternative to #14 where one will automatically restart the services inside a container:

There are cloud services like a kubernetes service which will watch over the status of the containers. If any container has stopped/failed then it will restart the container whereas actually restarting the service inside the container.

In order to cooperate with external docker container managers the "--init" function of systemctl.py should not loop infinitely. Instead if no controlled service is in the "running" status anymore then the PID-1 systemctl.py should exit. This might be just done after some timeout (waiting for the startup of a service) but atleast it should always be done. Even when not using an external docker container manager the status of the container gets more visible if "docker ps" shows it as having exited when all services in the container have exited one way or the other.

@gdraheim
Copy link
Owner Author

Note however that the kubernetes restart-policy includes livenessProbe / readinessProbe actions that do not rely on the existance of a PID-1

https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy

@antoinetran
Copy link

I can add that

  1. the timeout is useful to debug (otherwise, a restart policy set to always will loop and one cannot enter in the container to do some debug).
  2. when there is an error, init should return not 0.

gdraheim added a commit that referenced this issue Apr 21, 2018
@gdraheim
Copy link
Owner Author

gdraheim commented Apr 21, 2018

Instead of checking for dead services I have impemented atleast the most basic condition for an exit - if the systemctl.py init process finds itself to be alone in a container then it will exit. In the case that all the "systemctl halt" services have correctly stopped, thereby killing all its children, then the systemctl.py will stop as well.

That's also okay for a debugging POV as there is nothing left to attach to.

The only missing point is the exit status of PID 1. What shall it return? A forking service will not transmit an exit code. Neither oneshot - basically it does only make sense when there is a type=simple service and one would ask systemctl.py to mimic the behaviour as if someone has been extracting the ExecStart statement to make a docker-entrypoint.sh with a final exec-$cmd. Or is there more to it?

@gdraheim
Copy link
Owner Author

I have cut out the remaining features to "exit init-process when the required services have died" #27 ... while I am closing this ticket for the current milestone. In most situation it will do what is expected.

Note that I was rethinking it also as may be one could use /usr/bin/systemctl as the main process before running an actual service. In reality I found that simulations of an operating system in a container had the "cron" and possibly "sshd" running. So the list of processes is not empty.

@gdraheim gdraheim added this to the M1.2 milestone Apr 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants