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

runtime: Replace "process is stopped" with "process exits" #465

Merged
merged 1 commit into from
Jan 22, 2017

Conversation

wking
Copy link
Contributor

@wking wking commented May 27, 2016

proc(5) describes the following state entries in
proc/[pid]/stat (for modern kernels):

  • R Running
  • S Sleeping in an interruptible wait
  • D Waiting in uninterruptible disk sleep
  • Z Zombie
  • T Stopped (on a signal)
  • t Tracing stop
  • X Dead

and ps(1) has a bit more context (for modern kernels):

  • D uninterruptible sleep (usually IO)
  • R running or runnable (on run queue)
  • S interruptible sleep (waiting for an event to complete)
  • T stopped by job control signal
  • t stopped by debugger during the tracing
  • X dead (should never be seen)
  • Z defunct ("zombie") process, terminated but not reaped by its
    parent

So I expect "stopped" to mean "process still exists but is paused,
e.g. by SIGSTOP". And I expect "exited" to mean "process has finished
and is either a zombie or dead".

After this commit, git grep -i stop only turns up poststop-hook
stuff, a reference in principles.md, a "stoppage" in LICENSE, and some
ChangeLog entries.

This also replaces "container's process" with "container process" to
match usage in the rest of the repository. After this commit:

$ git grep -i "container process" | wc -l
13
$ git grep -i "container's process" | wc -l
1

@hqhq
Copy link
Contributor

hqhq commented May 28, 2016

LGTM

Approved with PullApprove

@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

Looks fine. Needs rebase.

@wking
Copy link
Contributor Author

wking commented May 31, 2016

On Tue, May 31, 2016 at 09:41:40AM -0700, Mrunal Patel wrote:

Looks fine. Needs rebase.

Rebased with 23009bba95eb3b, although again 1 I don't see any changes
to the patch.

@wking
Copy link
Contributor Author

wking commented May 31, 2016

Maybe needs a reroll with my suggested updates to #462.

@wking
Copy link
Contributor Author

wking commented Jun 3, 2016 via email

* `running` : the container has been created and the user-specified code is running
* `stopped` : the container has been created and the user-specified code has been executed but is no longer running
* `created` : the container process has neither exited nor executed the user-specified code
* `running` : the container process has executed the user-specified code but has not exited
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning of user-specified code vs container process here seems confusing to me. For example, if container process is some init piece of the runtime, does this mean that the init piece has to be run for the lifetime of the user process because stopped only happens when the container process has exited ? Or did I understand this incorrectly ?

What do you think about replacing user-specified code with container process completely. Something like

* `created` : the container has been created but the container process has not yet been executed.
* `running`: the container process has been executed but has not exited.
* `stopped`: the container process has exited.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Wed, Jul 13, 2016 at 09:43:58AM -0700, Daniel, Dao Quang Minh wrote:

@@ -15,9 +15,9 @@ This MUST be unique across all containers on this host.
There is no requirement that it be unique across hosts.

  • status: (string) is the runtime state of the container.
    The value MAY be one of:
    • * created : the container has been created but the user-specified code has not yet been executed
    • * running : the container has been created and the user-specified code is running
    • * stopped : the container has been created and the user-specified code has been executed but is no longer running
    • * created : the container process has neither exited nor executed the user-specified code
    • * running : the container process has executed the user-specified code but has not exited

meaning of user-specified code vs container process here seems
confusing to me.

This terminology issue is being hashed out in #466. Maybe we should
handle that first?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wking Since #466 is closed, I think most of the maintainers like container process more than user-specified code, but I think we can handle that in a separate PR.

@wking
Copy link
Contributor Author

wking commented Nov 5, 2016

Rebased onto master with 5816f317797b33.

* `stopped`: the container has been created and the user-specified code has been executed but is no longer running
* `created`: the container process has neither exited nor executed the user-specified code
* `running`: the container process has executed the user-specified code but has not exited
* `stopped`: the container process has exited
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the container has been created phrase? I don't think that redundant, especially for the created status.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the container process crashed during creation, in which case we're stopped before the container has been fully created. And see #507, which builds on this PR and adds creating. In the absence of a creating status (this PR before #507), I think we're created even before creation has finished.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to state that in the stopped state the container has ran the container's main process and it has exited leaving the container in the stopped state

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If create fails the container should be destroyed and will be by the runtimes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to state that in the stopped state the container has ran the container's main process…

This is not necessarily true, since the container process may have died during creation or between creation and the start call.

If create fails the container should be destroyed and will be by the runtimes.

Agreed, but we need to define the status passed to any post-stop hooks, which run after the container process exits. That happens even if the container process dies during creation.

@wking wking closed this Nov 10, 2016
@wking wking reopened this Nov 10, 2016
* `created`: the container has been created but the user-specified code has not yet been executed
* `running`: the container has been created and the user-specified code is running
* `stopped`: the container has been created and the user-specified code has been executed but is no longer running
* `created`: the container process has neither exited nor executed the user-specified code
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not user-specified code, we went over this many times.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good description of the created state. The container is in a created state when it has been fully initialized but is not yet running the containers main process

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not user-specified code, we went over this many times.

As I pointed out after #466 was closed, all of the changes proposed by #466 are already live. So I'd rather keep the currently-live “user-specified code” language. If you feel like that language is unclear, adjusting to something else seems orthogonal to the stopped → exists fix that this PR is focused on. Maybe open a different PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container is in a created state when it has been fully initialized but is not yet running the containers main process.

#507 addresses this by adding a creating state, and that seems orthogonal to the stopped → exists fix which I'm focusing on here. Until then, created seems like the best stand in (a container being created is certainly not running or stopped).

* `running`: the container has been created and the user-specified code is running
* `stopped`: the container has been created and the user-specified code has been executed but is no longer running
* `created`: the container process has neither exited nor executed the user-specified code
* `running`: the container process has executed the user-specified code but has not exited
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

container process not user-specified code

* `stopped`: the container has been created and the user-specified code has been executed but is no longer running
* `created`: the container process has neither exited nor executed the user-specified code
* `running`: the container process has executed the user-specified code but has not exited
* `stopped`: the container process has exited
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to state that in the stopped state the container has ran the container's main process and it has exited leaving the container in the stopped state

* `stopped`: the container has been created and the user-specified code has been executed but is no longer running
* `created`: the container process has neither exited nor executed the user-specified code
* `running`: the container process has executed the user-specified code but has not exited
* `stopped`: the container process has exited
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If create fails the container should be destroyed and will be by the runtimes.

5. The container's process is stopped.
This MAY happen due to them erroring out, exiting, crashing or the runtime's [`kill`](runtime.md#kill) operation being invoked.
5. The container process exits.
This MAY happen due to erroring out, exiting, crashing or the runtime's [`kill`](runtime.md#kill) operation being invoked.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct as the runtime's kill command can sent non terminating signals.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct as the runtime's kill command can sent non terminating signals.

I agree, but this MAY does not list all possible triggers nor does it require listed triggers to cause container exit. And it's the existing language and is orthogonal to the stopped → exited I'm focusing on here. Maybe file a new PR with your suggested wording?

proc(5) describes the following state entries in proc/[pid]/stat [1]
(for modern kernels):

* R Running
* S Sleeping in an interruptible wait
* D Waiting in uninterruptible disk sleep
* Z Zombie
* T Stopped (on a signal)
* t Tracing stop
* X Dead

and ps(1) has a bit more context [2] (for modern kernels):

* D uninterruptible sleep (usually IO)
* R running or runnable (on run queue)
* S interruptible sleep (waiting for an event to complete)
* T stopped by job control signal
* t stopped by debugger during the tracing
* X dead (should never be seen)
* Z defunct ("zombie") process, terminated but not reaped by its
  parent

So I expect "stopped" to mean "process still exists but is paused,
e.g. by SIGSTOP".  And I expect "exited" to mean "process has finished
and is either a zombie or dead".

After this commit, 'git grep -i stop' only turns up the "stopped"
state (which I've left alone for backwards compat), some poststop-hook
stuff, a reference in principles.md, a "stoppage" in LICENSE, and some
ChangeLog entries.

Also replace "container's process" with "container process" to match
usage in the rest of the repository.  After this commit:

  $ git grep -i "container process" | wc -l
  20
  $ git grep -i "container's process" | wc -l
  1

Also reword status entries to avoid "running", which is less precise
in our spec (e.g. it also includes "sleeping", "waiting", ...).

Also removes a "them" leftover from a partial plural -> singular
reroll of be59415 (Split create and start, 2016-04-01, opencontainers#384).

[1]: http://man7.org/linux/man-pages/man5/proc.5.html
[2]: http://man7.org/linux/man-pages/man1/ps.1.html

Signed-off-by: W. Trevor King <wking@tremily.us>
@wking
Copy link
Contributor Author

wking commented Jan 6, 2017 via email

@mrunalp
Copy link
Contributor

mrunalp commented Jan 18, 2017

@crosbymichael PTAL

Copy link
Member

@crosbymichael crosbymichael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crosbymichael
Copy link
Member

crosbymichael commented Jan 18, 2017

LGTM

Approved with PullApprove

@wking
Copy link
Contributor Author

wking commented Jan 22, 2017

@hqhq, @mrunalp, now that @crosbymichael has LGTMed this, do either of you want to re-approve it?

@hqhq
Copy link
Contributor

hqhq commented Jan 22, 2017

LGTM

Approved with PullApprove

@hqhq hqhq merged commit 579548a into opencontainers:master Jan 22, 2017
@wking wking deleted the stop-to-exit branch January 27, 2017 21:07
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

Successfully merging this pull request may close these issues.

5 participants