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

Container status wrt reboots and hooks #958

Open
alban opened this issue Mar 12, 2018 · 7 comments
Open

Container status wrt reboots and hooks #958

alban opened this issue Mar 12, 2018 · 7 comments

Comments

@alban
Copy link
Contributor

alban commented Mar 12, 2018

The spec defines 4 statuses:

  • creating
  • created
  • running
  • stopped

What's happening when a container is created and then the machine is rebooted? Should the container be deleted, or should it be in the "stopped" state?

The spec also defines hooks and each hook receives the state of the container from stdin. What should be the status of the container in each hook?

  • prestart hook: I guess the state should be "created"
  • poststart hook: I guess the state should be "running"
  • poststop: since the hook is called after the container is deleted, the state is not "stopped" anymore but maybe some fantoom "deleted" state?

Could the spec clarify those two points?

@cyphar
Copy link
Member

cyphar commented Mar 12, 2018

Your question about rebooting is already covered by the lifecycle and specifically, step 7. A reboot causes the container process to exit, but the delete operation was not executed -- so the container is naturally in the "stopped" state.

  • prestart hook: I guess the state should be "created"
  • poststart hook: I guess the state should be "running"

These are correct in the most obvious cases, but the spec allows runtimes to add additional states which could also be returned.

  • poststop: since the hook is called after the container is deleted, the state is not "stopped" anymore but maybe some fantoom "deleted" state?

I'm not sure about this one, but from memory this is something that some folks from @opencontainers/runtime-tools-maintainers have been working on ironing out. As far as I can tell, runc changes the state to stopped after running the post-stop hooks (which seems wrong to me). Maybe there should be a deleted state.

@crosbymichael
Copy link
Member

How would there be a deleted state...when...it's...deleted?

@crosbymichael
Copy link
Member

On a reboot, it would be gone because the state is kept in /run and /run is in memory.

@wking
Copy link
Contributor

wking commented Mar 12, 2018 via email

@wking
Copy link
Contributor

wking commented Mar 13, 2018

On a reboot, it would be gone because the state is kept in /run and /run is in memory.

This makes sense (for runc), but so does @cyphar's argument for stopped. I think we should add spec wording to explicitly allow runtimes to forget about all of their containets on reboot, so folks relying on post-stop hooks for cleanup know that they might have to handle post-reboot cleanup themselves.

@dongsupark
Copy link
Contributor

I'm just a newcomer, but basically I agree with @alban. Currently it's a little confusing.

At the moment the spec defines an action Delete, and a status stopped.
The stopped status is used in a mixed way, especially by runc, which has only one action Destroy that does actually both killing a process and deleting a container.

So if we add deleted status that is distinguished from stopped, we would also want to add Stop action, so that Stop results in stopped and Delete results in deleted. Also we would need to change runc to make it handle both actions Stop and Delete in a separate way.

@wking
Copy link
Contributor

wking commented Apr 4, 2018 via email

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

5 participants