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

Add a 'status' field to our state struct #462

Merged
merged 1 commit into from
May 31, 2016

Conversation

duglin
Copy link
Contributor

@duglin duglin commented May 27, 2016

When thinking about kill() vs delete(), a client needs to know (gracefully - w/o errors) when to call each. Which means it needs to be able to query the container to know what its current state is (running vs stopped). This defines a property in our 'state' struct to convey that info.

Signed-off-by: Doug Davis dug@us.ibm.com

@@ -23,6 +30,7 @@ When serialized in JSON, the format MUST adhere to the following pattern:
{
"ociVersion": "0.2.0",
"id": "oci-container1",
"status": "running",
Copy link
Member

Choose a reason for hiding this comment

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

formatting issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tabs... the root of all evil

@crosbymichael
Copy link
Member

crosbymichael commented May 27, 2016

LGTM

Approved with PullApprove

@wking
Copy link
Contributor

wking commented May 27, 2016

I commented via email last night, but GitHub seems to have eaten my
comment. Here it is again:

I'm opposed.

There is no race-free way to do this gracefully without errors, since
“‘state’, process changes, take action based on stale state” is always
possible. If a client wants to start a container, just run ‘start’
and catch errors. The same approach works for the other commands,
with the additional complication of a wait-before-delete dance like
@julz outlined in 1.

@duglin
Copy link
Contributor Author

duglin commented May 27, 2016

@wking the intent isn't to remove any chance of an error, the intent is to make it so that an error isn't part of the normal workflow just to figure out the state of a container.

@wking
Copy link
Contributor

wking commented May 27, 2016

On Fri, May 27, 2016 at 02:08:03PM -0700, Doug Davis wrote:

@wking the intent isn't to remove any chance of an error, the intent
is to make it so that an error isn't part of the normal workflow
just to figure out the state of a container.

So “decrease the likelyhood of generating errors” (and I agree that
this change would do that). Why is that useful? Is there a problem
with errors?

I think that the runtime needs to be careful in this case (e.g. I
don't like this risk of sending the ‘start’ signal to user-specified
code 1), but at the level of abstraction exposed by the spec
operations I see no such risks. That doesn't mean that the risk isn't
there, but I think we should identify it (or some other use-case) more
clearly before landing a new field in the state.

@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

I would prefer a status operation over a field in the state file.

@duglin
Copy link
Contributor Author

duglin commented May 31, 2016

@mrunalp we already have one: https://github.com/duglin/runtime-spec/blob/master/runtime.md#query-state
The problem is that it doesn't return enough info and I doubt we want 2 ops that return almost the same info.

@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

I meant status as a separate op that just returns the current run status of the container.

Sent from my iPhone

On May 31, 2016, at 9:49 AM, Doug Davis notifications@github.com wrote:

@mrunalp we already have one: https://github.com/duglin/runtime-spec/blob/master/runtime.md#query-state
The problem is that it doesn't return enough info and I doubt we want 2 ops that return almost the same info.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@dqminh
Copy link
Contributor

dqminh commented May 31, 2016

LGTM.

@duglin @wking AFAIK this is most useful when use for things like inspect, not really for When thinking about kill() vs delete(), a client needs to know (gracefully - w/o errors) when to call each. though, as runtime should try to make those operations idempotent.

Approved with PullApprove

@crosbymichael
Copy link
Member

@mrunalp why would another op that just returned the status be better than the state op that returns status along with the other info?

@wking
Copy link
Contributor

wking commented May 31, 2016

On Tue, May 31, 2016 at 10:02:56AM -0700, Daniel, Dao Quang Minh wrote:

@duglin @wking AFAIK this is most useful when use for things like
inspect

This is getting into very fuzzy territory to me. “I want to know
$PROPERTY because I want to know $PROPERTY” is hard to argue
for/against ;). I'd rather keep the spec restricted to “I want to
know $PROPERTY because I neet it to take $ACTION” is much easier to
reason about (do we want to support $ACTION? Do you really need
$PROPERTY to do it?). So, what sort of actions does this information
let you take?

… not really for When thinking about kill() vs delete()… though,
as runtime should try to make those operations idempotent.

At least with the current spec, delete is not idempotent 1:

Attempting to delete a container that does not exist MUST generate
an error.

@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

@crosbymichael state is static whereas the running status of a process is more dynamic. The information in the state file could get stale.

@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

I think it will be hard to keep the status field in the state file correct and queries race free.

@crosbymichael
Copy link
Member

@mrunalp we are not talking about cat'ing a file. The state response is dynamic as well and the status is correct it is returned. Nothing static about it in the spec or in the runc implementation.

@duglin
Copy link
Contributor Author

duglin commented May 31, 2016

the spec doesn't mention state files any more - we put it all behind an op.

@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

@crosbymichael Agree if the state isn't persisted in a file in a implementation (but anyway that is up to the implementation).

@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

@duglin Needs rebase.

@duglin
Copy link
Contributor Author

duglin commented May 31, 2016

I think git is acting up again - there were not conflicts at all so the rebase shouldn't have been necessary. Very odd.

The value MAY be one of:
* `created` : the container has been created but the user-specified process has not yet been executed
* `running` : the container has been created and the user-specified process is running
* `stopped` : the container has been created and the user-specified process has been executed but is no longer running
Copy link
Contributor

Choose a reason for hiding this comment

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

If we land a status property (I'm still opposed), I think we want to use dead here to mirror proc(5) and ps(1). More details on why I don't like “stopped” in #465.

Signed-off-by: Doug Davis <dug@us.ibm.com>
* **`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 process has not yet been executed
* `running` : the container has been created and the user-specified process is running
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather have this be “the container process has executed user-specified code has not exited”. In Linux, in any case “running” is a technical term for one possible process state, and the status you're shooting for here also covers “sleeping”, “waiting”, and “stopped”.

@duglin
Copy link
Contributor Author

duglin commented May 31, 2016

oh man - had to rebase again. Github is really acting up.

@crosbymichael
Copy link
Member

crosbymichael commented May 31, 2016

LGTM

Approved with PullApprove

1 similar comment
@mrunalp
Copy link
Contributor

mrunalp commented May 31, 2016

LGTM

Approved with PullApprove

@mrunalp mrunalp merged commit 8f02d00 into opencontainers:master May 31, 2016
@duglin duglin deleted the AddStatus branch July 20, 2016 10:53
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Aug 17, 2016
…ecycle

After unifying the pre- and post-split hook lifecycle information
(this commit's first parent), merge master to pull in subsequent
mainline evolution.

Conflicts:
    runtime.md

The conflict was a trivial collision with dd0cd21 (Add a 'status'
field to our state struct, 2016-05-26, opencontainers#462).

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Nov 18, 2016
In [1], I'd proposed replacing our old "user-specified process" with
"user-specified code" to help distinguish between 'create' (cloning
the container process) and 'start' (signaling the container process to
execve (or similar) the user-specified $STUFF_FROM_THE_process_CONFIG
rejected, although the renaming proposed there had already landed via
dd0cd21 (Add a 'status' field to our state struct, 2016-05-26, opencontainers#462).

This PR attempts to find a common ground between "process" (preferred
by maintainers in opencontainers#466 [2,3,4], but which I consider incorrect [5])
and "code" (which maintainers found confusing [3,4,6]).  The Linux
execve(2) has says "program" and unpacks that to "a binary executable,
or a script starting with a [shebang]" [7].  proc(5) documents
/proc/[pid]/exe by talking about "the executed command" [8].  The
POSIX exec docs call this the "process image" and talk about loading
it from the "new process image file" [9].

POSIX formally defines "command" [11], "executable file" [12], and
"program" [13].  The only reference to "process image" in the
definitions is in the "executable file" entry.  The "command"
definition is focused on the shell, the "executable file" definition
is focused on files, and the "program" definition talks about a
"prepared sequence of instructions to the system", so "program" seems
like the best fit.

[1]: opencontainers#466
     Subject: runtime: Replace "user-specified process" with "user-specified code" in 'create'
[2]: opencontainers#466 (comment)
[3]: opencontainers#466 (comment)
[4]: opencontainers#466 (comment)
[5]: opencontainers#466 (comment)
[6]: opencontainers#466 (comment)
[7]: http://man7.org/linux/man-pages/man2/execve.2.html
[8]: http://man7.org/linux/man-pages/man5/proc.5.html
[9]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
[10]: https://git.kernel.org/cgit/docs/man-pages/man-pages.git/
[11]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_104
[12]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_154
[13]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_306

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Nov 18, 2016
In [1], I'd proposed replacing our old "user-specified process" with
"user-specified code" to help distinguish between 'create' (cloning
the container process) and 'start' (signaling the container process to
execve or similar the user-specified $STUFF_FROM_THE_process_CONFIG).
That PR was rejected, although the renaming proposed there had already
landed via dd0cd21 (Add a 'status' field to our state struct,
2016-05-26, opencontainers#462).

This PR attempts to find a common ground between "process" (preferred
by maintainers in opencontainers#466 [2,3,4], but which I consider incorrect [5])
and "code" (which maintainers found confusing [3,4,6]).  The Linux
execve(2) has says "program" and unpacks that to "a binary executable,
or a script starting with a [shebang]" [7].  proc(5) documents
/proc/[pid]/exe by talking about "the executed command" [8].  The
POSIX exec docs call this the "process image" and talk about loading
it from the "new process image file" [9].

POSIX formally defines "command" [11], "executable file" [12], and
"program" [13].  The only reference to "process image" in the
definitions is in the "executable file" entry.  The "command"
definition is focused on the shell, the "executable file" definition
is focused on files, and the "program" definition talks about a
"prepared sequence of instructions to the system", so "program" seems
like the best fit.

[1]: opencontainers#466
     Subject: runtime: Replace "user-specified process" with "user-specified code" in 'create'
[2]: opencontainers#466 (comment)
[3]: opencontainers#466 (comment)
[4]: opencontainers#466 (comment)
[5]: opencontainers#466 (comment)
[6]: opencontainers#466 (comment)
[7]: http://man7.org/linux/man-pages/man2/execve.2.html
[8]: http://man7.org/linux/man-pages/man5/proc.5.html
[9]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
[10]: https://git.kernel.org/cgit/docs/man-pages/man-pages.git/
[11]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_104
[12]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_154
[13]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_306

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Nov 18, 2016
In [1], I'd proposed replacing our old "user-specified process" with
"user-specified code" to help distinguish between 'create' (cloning
the container process) and 'start' (signaling the container process to
execve or similar the user-specified $STUFF_FROM_THE_process_CONFIG).
That PR was rejected, although the renaming proposed there had already
landed via dd0cd21 (Add a 'status' field to our state struct,
2016-05-26, opencontainers#462).

This PR attempts to find a common ground between "process" (preferred
by maintainers in opencontainers#466 [2,3,4], but which I consider incorrect [5])
and "code" (which maintainers found confusing [3,4,6]).  The Linux
execve(2) says "program" and unpacks that to "a binary executable, or
a script starting with a [shebang]" [7].  proc(5) documents
/proc/[pid]/exe by talking about "the executed command" [8].  The
POSIX exec docs call this the "process image" and talk about loading
it from the "new process image file" [9].

POSIX formally defines "command" [11], "executable file" [12], and
"program" [13].  The only reference to "process image" in the
definitions is in the "executable file" entry.  The "command"
definition is focused on the shell, the "executable file" definition
is focused on files, and the "program" definition talks about a
"prepared sequence of instructions to the system", so "program" seems
like the best fit.

[1]: opencontainers#466
     Subject: runtime: Replace "user-specified process" with "user-specified code" in 'create'
[2]: opencontainers#466 (comment)
[3]: opencontainers#466 (comment)
[4]: opencontainers#466 (comment)
[5]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_295
[6]: opencontainers#466 (comment)
[7]: http://man7.org/linux/man-pages/man2/execve.2.html
[8]: http://man7.org/linux/man-pages/man5/proc.5.html
[9]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
[10]: https://git.kernel.org/cgit/docs/man-pages/man-pages.git/
[11]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_104
[12]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_154
[13]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_306

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Nov 18, 2016
In [1], I'd proposed replacing our old "user-specified process" with
"user-specified code" to help distinguish between 'create' (cloning
the container process) and 'start' (signaling the container process to
execve or similar the user-specified $STUFF_FROM_THE_process_CONFIG).
That PR was rejected, although the renaming proposed there had already
landed via dd0cd21 (Add a 'status' field to our state struct,
2016-05-26, opencontainers#462).

This PR attempts to find a common ground between "process" (preferred
by maintainers in opencontainers#466 [2,3,4], but which I consider incorrect [5])
and "code" (which maintainers found confusing [3,4,6]).  The Linux
execve(2) says "program" and unpacks that to "a binary executable, or
a script starting with a [shebang]" [7].  proc(5) documents
/proc/[pid]/exe by talking about "the executed command" [8].  The
POSIX exec docs call this the "process image" and talk about loading
it from the "new process image file" (although they also sprinkle in a
number of “program” references, apparently interchangeably with
“process image”) [9].

POSIX formally defines "command" [11], "executable file" [12], and
"program" [13].  The only reference to "process image" in the
definitions is in the "executable file" entry.  The "command"
definition is focused on the shell, the "executable file" definition
is focused on files, and the "program" definition talks about a
"prepared sequence of instructions to the system", so "program" seems
like the best fit.

[1]: opencontainers#466
     Subject: runtime: Replace "user-specified process" with "user-specified code" in 'create'
[2]: opencontainers#466 (comment)
[3]: opencontainers#466 (comment)
[4]: opencontainers#466 (comment)
[5]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_295
[6]: opencontainers#466 (comment)
[7]: http://man7.org/linux/man-pages/man2/execve.2.html
[8]: http://man7.org/linux/man-pages/man5/proc.5.html
[9]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
[10]: https://git.kernel.org/cgit/docs/man-pages/man-pages.git/
[11]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_104
[12]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_154
[13]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_306

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Jan 6, 2017
…ecycle

After unifying the pre- and post-split hook lifecycle information
(this commit's first parent), merge master to pull in subsequent
mainline evolution.

Conflicts:
    runtime.md

The conflicts were primarily due to:

* dd0cd21 (Add a 'status' field to our state struct, 2016-05-26, opencontainers#462).
* 98f0bdf (Add some related docs links, 2016-10-25, opencontainers#596).
* c45ffb4 (*: Replace "user-specified code" with "user-specified
  program", 2016-11-18, opencontainers#629).

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Jan 6, 2017
…ecycle

After unifying the pre- and post-split hook lifecycle information
(this commit's first parent), merge master to pull in subsequent
mainline evolution.

Conflicts:
    runtime.md

The conflicts were primarily due to:

* dd0cd21 (Add a 'status' field to our state struct, 2016-05-26, opencontainers#462).
* 98f0bdf (Add some related docs links, 2016-10-25, opencontainers#596).
* c45ffb4 (*: Replace "user-specified code" with "user-specified
  program", 2016-11-18, opencontainers#629).

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Jan 6, 2017
…ecycle

After unifying the pre- and post-split hook lifecycle information
(this commit's first parent), merge master to pull in subsequent
mainline evolution.

Conflicts:
    runtime.md

The conflicts were primarily due to:

* dd0cd21 (Add a 'status' field to our state struct, 2016-05-26, opencontainers#462).
* 98f0bdf (Add some related docs links, 2016-10-25, opencontainers#596).
* c45ffb4 (*: Replace "user-specified code" with "user-specified
  program", 2016-11-18, opencontainers#629).

Signed-off-by: W. Trevor King <wking@tremily.us>
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.

None yet

5 participants