Commit Graph

67 Commits

Author SHA1 Message Date
W. Trevor King f636808bfd *: Restore hook lifecycle information removed by create/start split
I expect the lifecycle information was removed accidentally in
be594153 (Split create and start, 2016-04-01, #384), because for a
time it seemed like that PR would also be removing hooks.  Putting the
lifecycle information back in, I made some tweaks to adjust to the new
environment, for example:

* Put the pre-start hooks after the 'start' call, but before the meat
  of the start call (the container-process exec trigger).  Folks who
  want a post-create hook can add one with that name.  I'd like to
  have renamed poststop to post-delete to avoid confusion like [1].
  But the motivation for keeping hooks was backwards compatibility [2]
  so I've left the name alone.

* Put each "...command is invoked..." lifecycle entry in its own list
  entry, to match the 'create' list entry.

* Move the rules about what happens on hook failure into the
  lifecycle.  This matches pre-split entries like:

    If any prestart hook fails, then the container MUST be stopped and
    the lifecycle continues at step 7.

  and avoids respecifying that information in a second location
  (config.md).

* I added the warning section to try and follow post-split's generic
  "generates an error" approach while respecting the pre-split desire
  to see what failed (we had "then an error including the exit code
  and the stderr is returned to the caller" and "then an error is
  logged").

* I left the state 'id' context out, since Michael didn't want it [3].

* Make runtime.md references to "generate an error" and "log a
  warning" links, so readers have an easier time finding more detail
  on that wording.

Where I reference a section, I'm still using the auto-generated anchor
for that header and not the anchors which were added in 41839d7 (Merge
pull request #707 from mrunalp/anchor_tags, 2017-03-03) and similar.
Mrunal suggested that the manually-added anchors were mainly intended
for the validation tooling [4].

[1]: https://github.com/opencontainers/runtime-spec/pull/395
     Subject: Run post-stop hooks before the container sandbox is deleted.
[2]: https://github.com/opencontainers/runtime-spec/pull/483#issuecomment-240568422
     Subject: *: Remove hooks
[3]: https://github.com/opencontainers/runtime-spec/pull/532#discussion_r99232480
     Subject: Restore hook language removed by create/start split
[4]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/%23opencontainers.2017-03-03.log.html#t2017-03-03T18:02:12

Signed-off-by: W. Trevor King <wking@tremily.us>
2017-03-03 10:04:23 -08:00
Mrunal Patel 4b0755490e Add anchors to runtime
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2017-03-02 11:00:53 -08:00
Mrunal Patel 1f408dc1db Merge pull request #507 from wking/add-creating-status
runtime: Add 'creating' to state status
2017-02-08 11:46:50 -08:00
Michael Crosby 5d3f1674e6 Rename bundlePath to bundle
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-02-02 13:10:54 -08:00
Michael Crosby 8df60240c3 Merge pull request #664 from wking/state-required-optional
runtime: Only require 'pid' in the state for created/running statuses
2017-01-23 10:34:26 -08:00
W. Trevor King 65d9d6b885 runtime: Add 'creating' to state status
To distinguish between "we're still setting this container up" and
"we're finished setting up; you can call 'start' if you like".

Also reference the lifecycle steps, because you can't be too explicit

Signed-off-by: W. Trevor King <wking@tremily.us>
2017-01-22 16:46:29 -08:00
W. Trevor King 70ee91c6e3 runtime: Only require 'pid' in the state for created/running statuses
Because during creation (before 'created') we may not have a container
process yet (e.g. if we're still reading the configuration or setting
up cgroups), and in the 'stopped' phase the PID is no longer
meaningful.

Also add OPTIONAL/REQUIRED and remove colons for consistency with the
config.md.

Signed-off-by: W. Trevor King <wking@tremily.us>
2017-01-21 20:36:59 -08:00
W. Trevor King 9eb32c0e81 runtime: Replace "process is stopped" with "process exits"
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 be594153 (Split create and start, 2016-04-01, #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>
2017-01-05 22:45:45 -08:00
W. Trevor King 5ed105996e runtime: Fix config.md -> config.json typo
From 766abd6f (runtime.md: Require 'create' to fail if config.json
asks for the impossible, 2016-09-08, #559).

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-12-07 10:02:58 -08:00
W. Trevor King c45ffb4ce7 *: Replace "user-specified code" with "user-specified program"
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 dd0cd210 (Add a 'status' field to our state struct,
2016-05-26, #462).

This PR attempts to find a common ground between "process" (preferred
by maintainers in #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]: https://github.com/opencontainers/runtime-spec/pull/466
     Subject: runtime: Replace "user-specified process" with "user-specified code" in 'create'
[2]: https://github.com/opencontainers/runtime-spec/pull/466#r64982402
[3]: https://github.com/opencontainers/runtime-spec/pull/466#issuecomment-223132793
[4]: https://github.com/opencontainers/runtime-spec/pull/466#issuecomment-258563220
[5]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_295
[6]: https://github.com/opencontainers/runtime-spec/pull/466#r64982165
[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>
2016-11-18 03:42:10 -08:00
W. Trevor King bf9694db6e config: Change "Process configuration" -> "Process" header
All of these sections are about configuration, and we don't usually
use "{Whatever} configuration" in the headers.

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-11-10 20:43:51 -08:00
Qiang Huang 661314a926 Fix several format issues found by pdf and html
This carries #578 and fixes some other format issues.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-11-03 09:33:51 +08:00
Lei Jitang a83c0965b2 typo: fix missing `)`
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-10-28 03:41:44 -04:00
Michael Crosby 1e7faf0c4c Merge pull request #596 from WeiZhang555/add-related-links
Add some related docs links
2016-10-25 09:11:38 -07:00
Zhang Wei 98f0bdfe70 Add some related docs links
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-10-25 20:52:31 +08:00
Zhang Wei 932fba6802 Fix typo
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-10-25 16:59:26 +08:00
W. Trevor King 766abd6f54 runtime.md: Require 'create' to fail if config.json asks for the impossible
We don't want to silently ignore settings that we understand but
cannot implement [1] (we *do* want to ignore settings that we don't
understand [2], but that's a separate issue).

This raises a slightly sticky certification issue.  If a runtime
*always* exits 'create' with an error:

  func create() err {
    return fmt.Errorf("nope, I cannot create that container either.")
  }

it would be neither complaint nor non-compliant.  It would not fail
any MUSTs, but availing itself of the "cannot create the maintainer"
option specified in this commit would mean the test suite could not
test the deeper requirements around the config properties themselves.

So with this change, making Microsoft certifiable will still need an
explicit weakening around root.path.  The easiest way to do that might
be to have separate annotations for whether a setting is optional for
config authors and whether it's optional for runtime authors
(supported):

  * **`readonly`** (bool, config:optional, support:optional) ...

But I'll leave hashing that out to a later commit.  Regardless of the
certification impact, we want to be clear that silently ignoring known
parameters is wrong.

[1]: 9b8e21826c (r65400731)
     Subject: [ Config | Root Config ] Clarify readonly
[2]: https://github.com/opencontainers/runtime-spec/pull/510
     Subject: Add text about extensions

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-09-16 08:08:05 -07:00
W. Trevor King a2d07dcfda Replace " : " with ": "
There's an outside change that these are intentional, since I pointed
one of these out earlier [1] and it wasn't fixed.  But I haven't seen
" : " used intentionally outside of this project, and don't think we
want to break ground in that direction ;).

[1]: https://github.com/opencontainers/runtime-spec/pull/510#discussion_r77291554

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-09-06 22:21:33 -07:00
W. Trevor King 9500be8470 Replace "container's main process" with "container process"
We use both forms, but the latter was more popular.  Before this
branch:

  $ git grep -i 'container process' origin/master | wc -l
  13
  $ git grep -i 'main process' origin/master | wc -l
  4

Also fix "process id" -> "process ID" in one of the lines I touched,
to match fork(2) [1].

[1]: http://man7.org/linux/man-pages/man2/fork.2.html

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-08-03 00:10:52 -07:00
Graham Whaley 7795661d84 runtime.md: Fix sub-bullet indentation
The indentation of the sub bullets for the status entries under State were not
indented by the 4 spaces required by markdown. They did not render well in
the pdf, at least with my native build with pandoc v1.13.2. Change them to 4
spaces, which now renders well.

Signed-off-by: Graham Whaley <graham.whaley@linux.intel.com>
2016-06-08 19:05:08 +01:00
Vincent Batts 831d961964 Merge pull request #397 from cyphar/add-cgroup-namespace
*: add support for cgroup namespace
2016-06-03 13:45:27 -04:00
Mrunal Patel 34901c10b3 Merge pull request #484 from duglin/ShowAnnot
Add annotations to the state json
2016-06-03 10:43:59 -07:00
Aleksa Sarai d514aad1bc runtime: lifecycle: environment must match config.json
Make it clear that if a runtime cannot set up an environment that
*precisely* matches the config.json provided, it must generate an error.
This is important because not doing this can cause security issues.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-06-04 00:14:39 +10:00
Qiang Huang fddb3e5527 Merge pull request #468 from wking/start-does-not-confirm-success
runtime: Remove start's "fails to run" monitoring
2016-06-03 10:20:05 +08:00
Doug Davis 9cb0c7fa6c Add annotations to the state json
Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-06-02 13:31:09 -07:00
Doug Davis dd0cd2102b Add a 'status' field to our state struct
Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-05-31 10:42:05 -07:00
W. Trevor King 7b28a16f7a runtime: Consistent indent for "However, some actions..."
The shorter-than-normal (for the rest of this list) indent landed with
the line in be594153 (Split create and start, 2016-04-01, #384).

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-05-31 10:25:48 -07:00
W. Trevor King 78d37e9ddf runtime: Restore leading blank line before lifecycle list
Restore the line removed by be594153 (Split create and start,
2016-04-01, #384).  Without this, GitHub renders the list as a single
paragraph.

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-05-28 13:06:21 -07:00
W. Trevor King 9b47c1241c runtime: Remove start's "fails to run" monitoring
The in-flight runC implementation just fires a signal at the container
[1,2].  It doesn't wait around to see if the signal has an effect, or if
it causes the container to crash, etc., etc.

[1]: 28126f8039/start.go (L29-L30)
[2]: 28126f8039/libcontainer/container_linux.go (L253-L258)

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-05-26 23:13:25 -07:00
W. Trevor King 05a548f135 runtime: Drop create-specific API caveat from lifecycle
This wording is descended from 7117ede7 (Expand on the definition of
our ops, 2015-10-13, #225), but the idea is covered generically by
e53a72b (Clarify the operation is not for command-line api,
2016-05-24, #450), so we no longer need a create-specific note.
Especially in the lifecycle docs, where there's already enough going
on without this low-level detail.

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-05-26 22:37:50 -07:00
Doug Davis be594153b5 Split create and start
Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-05-26 16:52:18 -07:00
Mrunal Patel 32601fbb80 Merge pull request #446 from hqhq/hq_remove_MUST_JSON
Remove one JSON related MUST requirement
2016-05-26 08:06:06 -07:00
Qiang Huang e53a72b7c9 Clarify the operation is not for command-line api
Replace: https://github.com/opencontainers/runtime-spec/pull/447

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-05-24 15:12:36 +08:00
Qiang Huang 95f106ed9d Remove one JSON related MUST requirement
JSON is not a mandatory format, we should not use MUST
requirement on this.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-05-23 16:13:53 +08:00
Qiang Huang 6d879c81d5 Move errors section out of operations
The `Errors` section is more like a general description about
runtime, if it's a sub-section of `Operations`, it'll be hard
for both implementations and tests to define what this
`errors` operation really is.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-05-23 15:48:20 +08:00
Michael Crosby 4436094090 Merge pull request #418 from wking/optional-start-validation
runtime: Explicitly allow 'start' to not validate config.json
2016-05-18 10:30:56 -07:00
W. Trevor King d7b5e15566 runtime: Explicitly allow 'start' to not validate config.json
This spec places RFC-2119 requirements on both bundles (bundle.md,
config.md, ...)  and runtimes (runtime.md, runtime-linux.md).  While
it's possible to envision a system where bundle validation is required
before container setup begins, it is also possible to decoupled
validation and allow the runtime to blindly stumble through as far as
it can.

We already link to ocitools and OCT for testing both runtimes and
bundles [1], so users interested in pre-start validation can use those
tools.

This commit explicitly documents the non-requirement and links to
those tools, to make life less surprising for everybody.

[1]: https://github.com/opencontainers/runtime-spec/blob/v0.5.0/implementations.md#testing--tools

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-05-02 11:58:31 -07:00
W. Trevor King 0382257baf runtime: Fix 'step 8' -> 'step 7' references
This slipped through the renumbering in 7117ede7 (Expand on the
definition of our ops, 2015-10-13, #225).

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-05-02 11:40:48 -07:00
Rob Dolin (MSFT) 9630bf7acb [ Lifecycle ] Increase importance of logging errors (#410)
"errors, if any, MAY be logged" --> "errors, if any, SHOULD be logged"

Signed-off-by: Rob Dolin <RobDolin@microsoft.com>
2016-05-02 14:09:25 -04:00
Rob Dolin (MSFT) 063eb099ac [ Runtime | State] Fix typo
propeties --> properties

Signed-off-by: Rob Dolin <RobDolin@microsoft.com>
2016-04-26 17:49:31 -07:00
Vishnu kannan a7a366b334 Remove exec from required runtime functionalities.
Signed-off-by: Vishnu kannan <vishnuk@google.com>
2016-04-19 15:27:23 -07:00
Vincent Batts 547e00b42e *.md: normalize the "example" anchors
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-08 10:01:45 -04:00
Giuseppe Scrivano f4950a17c2 specs: fix typo
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-21 11:33:43 +01:00
Doug Davis 7117ede74b Expand on the definition of our ops
Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-02-22 06:43:28 -08:00
W. Trevor King cb2da5430a config: Single, unified config file
Reverting 7232e4b1 (specs: introduce the concept of a runtime.json,
2015-07-30, #88) after discussion on the mailing list [1].  The main
reason is that it's hard to draw a clear line around "inherently
runtime-specific" or "non-portable", so we shouldn't try to do that in
the spec.  Folks who want to flag settings as non-portable for their
own system are welcome to do so (e.g. "we will clobber 'hooks' in
bundles we run") are welcome to do so, but we don't have to have
to split the config into multiple files to do that.

There have been a number of additional changes since #88, so this
isn't a pure Git reversion.  Besides copy-pasting and the associated
link-target updates, I've:

* Restored path -> destination, now that the mount type contains both
  source and target paths again.  I'd prefer 'target' to 'destination'
  to match mount(2), but the pre-7232e4b1 phrasing was 'destination'
  (possibly due to Windows using 'target' for the source?).

* Restored the Windows mount example to its pre-7232e4b1 content.

* Removed required mounts from the config example (requirements landed
  in 3848a238, config-linux: specify the default devices/filesystems
  available, 2015-09-09, #164), because specifying those mounts in the
  config is now redundant.

* Used headers (vs. bold paragraphs) to set off mount examples so we
  get link anchors in the rendered Markdown.

* Replaced references to runtime.json with references to config.json.

[1]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/0QbyJDM9fWY
     Subject: Single, unified config file (i.e. rolling back specs#88)
     Date: Wed, 4 Nov 2015 09:53:20 -0800
     Message-ID: <20151104175320.GC24652@odin.tremily.us>

Signed-off-by: W. Trevor King <wking@tremily.us>
2016-01-27 09:51:54 -08:00
W. Trevor King 0a55d5ca5a lifecycle: Mention runtime.json
As discussed earlier [1,2].  I'm in favor of rolling it back into
config.json [3], but we aren't there yet [4].

[1]: https://github.com/opencontainers/specs/pull/231#discussion_r43262848
[2]: https://github.com/opencontainers/specs/pull/231/files#r46735828
[3]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/0QbyJDM9fWY
     Subject: Single, unified config file (i.e. rolling back specs#88)
     Date: Wed, 4 Nov 2015 09:53:20 -0800
     Message-ID: <20151104175320.GC24652@odin.tremily.us>
[4]: 4a63e81a80/bundle.md (container-format)

Signed-off-by: W. Trevor King <wking@tremily.us>
2015-12-16 09:41:45 -08:00
W. Trevor King f89cb852ae lifecycle: Don't require /run/opencontainer/<runtime>/containers
We already require it for Linux/Unix-based systems [1], so we don't
have to repeat it here.  And other systems will use different paths,
which we haven't specified yet.  When I asked why we didn't specify a
path for Windows [2], Vincent said we were waiting on help from PoC
implementations [3].  So this commit punts the location to the "State"
section, and lets the "Lifecycle" section just focus on when the
write-to-filesystem happens.

There's also discussion about removing the filesystem state registry
completely [4], in which case we'd want to remove the whole line from
the lifecycle.

[1]: 7713efc1be (diff-b84a8d65d8ed53f4794cd2db7e8ea731L7)
[2]: https://github.com/opencontainers/specs/pull/211#discussion_r41066673
[3]: https://github.com/opencontainers/specs/pull/211#discussion_r41067134
[4]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/q6TYqVZOcX8
     Subject: removal of /run/opencontainer/containers
     Date: Wed, 25 Nov 2015 14:29:35 +0000
     Message-ID: <CAD2oYtNipt3i_C6=J4Bc-jwauo5YAvKXUqTROnPNP3vZ9+C5Vw@mail.gmail.com>

Signed-off-by: W. Trevor King <wking@tremily.us>
2015-12-14 10:46:21 -08:00
Vincent Batts 82cfe56140 Merge pull request #231 from mrunalp/lifecycle
Add lifecycle for containers
2015-12-09 13:03:29 -05:00
Mrunal Patel 4a63e81a80 Merge pull request #144 from wking/state-version-example
runtime: Add 'version' to the state.json example
2015-12-04 13:12:12 -08:00
Mrunal Patel 7713efc1be Add lifecycle for containers
The lifecycle described is generic and should apply all platforms.
It provides leeway for the runtimes to be flexible in how they
implement it.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2015-12-04 15:52:39 -05:00