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 lifecycle for containers #231

Merged
merged 1 commit into from
Dec 9, 2015
Merged

Conversation

mrunalp
Copy link
Contributor

@mrunalp mrunalp commented Oct 22, 2015

The lifecycle described is generic and should apply to all platforms.
It provides leeway for the runtimes to be flexible in how they
implement it.

Signed-off-by: Mrunal Patel mrunalp@gmail.com

Thanks to @crosbymichael for the feedback!


* OCI compliant runtime is invoked by passing the bundle path as argument.
* The container's runtime environment is created.
* The prestart hooks are invoked in the host environment by the runtime.
Copy link
Contributor

Choose a reason for hiding this comment

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

@mrunalp: If we split creation from start, then why can't users directly invoke the hooks?
I'm thinking something on the lines of

./oci-impl create foo <spec>
./my-pre-start-hook $(oci-impl state foo)
./oci-impl start foo
./my-post-start-hook $(oci-impl state foo)
./oci-impl stop foo # or my container exits / dies
./my-post-stop-hook $(oci-impl state foo)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vishh This is just a timeline of container lifecycle. For some runtimes like runc, this would be an internal implementation detail of what happens during start. I think we can tackle whether we want a separate create when we discuss the actions/API/interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mrunalp: But isn't that part of the lifecycle? When I think of a container in the OCI context, I assume this PR will describe its lifecycle.
Can you explain why you think this is an implementation detail?

@mrunalp
Copy link
Contributor Author

mrunalp commented Oct 23, 2015

Updated.

2. The container's runtime environment is created.
3. The container's state is written to the filesystem.
4. The prestart hooks are invoked by the runtime.
If any prestart hook fails, then the container is killed (step 8) and an error code is returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is just “the container is killed and the lifecycle continues at step 8”. Actually killing the container would be part of step 7 (where you talk about signaling the container), and the rest of the activity after step 8 would happen in the “failed pre-start hook” case too.

@mrunalp
Copy link
Contributor Author

mrunalp commented Oct 27, 2015

@philips @vishh @vbatts PTAL

@mrunalp
Copy link
Contributor Author

mrunalp commented Oct 27, 2015

@LK4D4 PTAL

The container could also error out or crash.
8. The container is destroyed by undoing the steps performed during create phase if required.
9. The poststop hooks are invoked by the runtime and errors, if any, are logged.
10. The state associated with the container is removed and the return code of the container is returned or logged.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/of the container/of the container's user specific process/

Copy link
Contributor

Choose a reason for hiding this comment

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

s/state/state file (state.json)/

Copy link
Contributor

Choose a reason for hiding this comment

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

While we're tweaking the text, both of @duglin's suggestions look good to me too.

Copy link
Contributor

Choose a reason for hiding this comment

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

By state I assume you are only referring to the internal state. Any changes that the spawned processed introduced to the root filesystem will not be cleaned up right?

Copy link
Contributor

Choose a reason for hiding this comment

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

On Tue, Nov 17, 2015 at 05:41:08PM -0800, Vish Kannan wrote:

+10. The state associated with the container is removed and the
return code of the container is returned or logged.

By state I assume you are only referring to the internal
state. Any changes that the spawned processed introduced to the
root filesystem will not be cleaned up right?

+1 to not cleaning up bundle-side filesystem changes, and another
reason why @duglin's state.json clarification is useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated state to state.json

@duglin
Copy link
Contributor

duglin commented Oct 28, 2015

In order to avoid things getting out of sync, and duplicating information, I think it would make sense to combine the lifecycle information here with the definition of our ops, from runtime.md. Unless there's a reason to keep them separated? But they seem pretty tightly linked to me, at least until we get to the point where "ops" are exposed via some API/cmd-line spec, which we're not doing yet.

@duglin
Copy link
Contributor

duglin commented Oct 28, 2015

In particular, I think it would make sense to pull in the lower-level details mentioned in #225. So each step could have a one-liner summary followed but a more detailed list of the technical details. Seeing it all in one spot keeps it simple, aligned and easier to follow.

@wking
Copy link
Contributor

wking commented Oct 28, 2015

On Wed, Oct 28, 2015 at 07:52:11AM -0700, Doug Davis wrote:

In particular, I think it would make sense to pull in the
lower-level details mentioned in #225. So each step could have a
one-liner summary followed but a more detailed list of the technical
details. Seeing it all in one spot keeps it simple, aligned and
easier to follow.

I like the approach with a one-liner overview linking out to more
details for each step (which is how I setup #207 1). That makes it
easy to get the big picture and still drill down into the individual
entries for more detail.

@crosbymichael
Copy link
Member

LGTM

@mrunalp
Copy link
Contributor Author

mrunalp commented Nov 9, 2015

@vishh @LK4D4 PTAL. As discussed in the call last week, we can start with something simple here that we can refine.

Process is killed from the outside.

This event needs to be captured by runc to run onstop event handlers.
The lifecycle describes the timeline of events that happen from when a container is started to when it is stopped or crashes unexpectedly.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: to when it ceases to exist maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: How about container is created instead of started?

Copy link
Contributor

Choose a reason for hiding this comment

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

On Tue, Nov 17, 2015 at 04:21:21PM -0800, Vish Kannan wrote:

-This event needs to be captured by runc to run onstop event handlers.
+The lifecycle describes the timeline of events that happen from when a container is started to when it is stopped or crashes unexpectedly.

nit: How about container is created instead of started?

Both of Vish's suggestions sound like improvements to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

1. OCI compliant runtime is invoked by passing the bundle path as argument.
2. The container's runtime environment is created.
3. The container's state is written to the filesystem.
4. The prestart hooks are invoked by the runtime.
Copy link
Contributor

Choose a reason for hiding this comment

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

This step is subject to change based on namespaces pinning POC right? Shall we explicitly mention that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a note at the bottom to this effect.

@vishh vishh self-assigned this Nov 18, 2015
@mrunalp mrunalp force-pushed the lifecycle branch 2 times, most recently from 5d07ec8 to bd549a2 Compare November 20, 2015 23:20
@mrunalp
Copy link
Contributor Author

mrunalp commented Nov 20, 2015

Pushed updates to address comments.

1. OCI compliant runtime is invoked by passing the bundle path as argument.
2. The container's runtime environment is created according to the configuration in config.json.
Any updates to config.json after container is running do not affect the container.
3. The container's state.json file is written to the filesystem under /run/opencontainer/<runtime>/containers/<id>/.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not specify the path here (just stop after “to the filesystem”). See @vbatts here in response to a comment on an outdated diff.

5. The user specified process is executed in the container.
6. The poststart hooks are invoked by the runtime.
If any poststart hook fails, then the container is killed and the lifecycle continues at step 8.
7. Additional actions such as pausing the container, resuming the container or signaling the container may be performed using the runtime interface.
Copy link
Contributor

Choose a reason for hiding this comment

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

With ec85489bd549a2 you dropped “checkpointing the container”, but left in pause/resume/signalling. @vishh didn't call those out in his original comment, but they also seem like something we'd want to address after landing a simpler start/cleanup lifecycle. As it stands, this is the only reference to pausing in the spec, and it doesn't look detailed enough to be useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

runtime interface --> runtime interfaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hqhq interface would support multiple operations so I think singular form is fine here.

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>
wking referenced this pull request in mrunalp/specs Dec 4, 2015
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>
5. The user specified process is executed in the container.
6. The poststart hooks are invoked by the runtime.
If any poststart hook fails, then the container is stopped and the lifecycle continues at step 8.
7. Additional actions such as pausing the container, resuming the container or signaling the container may be performed using the runtime interface.
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think we want to drop pause/resume/signal until we have more clarity on how they will work. For more background here, especially around complications with shared state on Linux, see wking/oci-command-line-api#3. Alternatively, if we already have a clear idea of how these will work in the absence of /run/opencontainer, I'd appreciate some comments in the CLI-spec PR explaining what the CLI should look like.

@wking wking mentioned this pull request Dec 5, 2015
@dqminh
Copy link
Contributor

dqminh commented Dec 8, 2015

LGTM

I think this is a great first step, we can further discuss the details for each individual actions, but the overall flow and structure looks right.

@vbatts
Copy link
Member

vbatts commented Dec 9, 2015

LGTM

vbatts added a commit that referenced this pull request Dec 9, 2015
Add lifecycle for containers
@vbatts vbatts merged commit 82cfe56 into opencontainers:master Dec 9, 2015
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Dec 11, 2015
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]: opencontainers#231 (comment)
[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]: https://github.com/opencontainers/specs/blob/4a63e81a807edec3d67ed2b6bd99a6c2b288676f/bundle.md#container-format

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Dec 11, 2015
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]: opencontainers#231 (comment)
[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]: https://github.com/opencontainers/specs/blob/4a63e81a807edec3d67ed2b6bd99a6c2b288676f/bundle.md#container-format

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Dec 16, 2015
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]: opencontainers#231 (comment)
[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]: https://github.com/opencontainers/specs/blob/4a63e81a807edec3d67ed2b6bd99a6c2b288676f/bundle.md#container-format

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/nmbug-oci that referenced this pull request Dec 29, 2015
Initial work landed in [1], but it doesn't get into the order of the
setup process or explain how pause/resume/signalling work [2].  If we
don't figure these things out ahead of time, I expect we'll have to
figure them out in order to land compliance testing.

[1]: opencontainers/runtime-spec#231
[2]: https://github.com/opencontainers/specs/pull/231/files#r46735313
@wking wking mentioned this pull request Mar 16, 2016
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request May 13, 2016
I think this is resolved since 7713efc (Add lifecycle for containers,
2015-10-22, opencontainers#231), which was committed on the same day as the ROADMAP
entry (4859f6d, Add initial roadmap, 2015-10-22, opencontainers#230).

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request May 15, 2016
# digest/hashing target

Most of this has spun off with [1], and I haven't heard of anyone
talking about verifying the on-disk filesystem in a while.  My
personal take is on-disk verification doesn't add much over serialized
verification unless you have a local attacker (or unreliable disk),
and you'll need some careful threat modeling if you want to do
anything productive about the local attacker case.  For some more
on-disk verification discussion, see the thread starting with [2].

# distributable-format target

This spun off with [1].

# lifecycle target

I think this is resolved since 7713efc (Add lifecycle for containers,
2015-10-22, opencontainers#231), which was committed on the same day as the ROADMAP
entry (4859f6d, Add initial roadmap, 2015-10-22, opencontainers#230).

# container-action target

Addressed by 7117ede (Expand on the definition of our ops,
2015-10-13, opencontainers#225), although there has been additional discussion in
a7a366b (Remove exec from required runtime functionalities,
2016-04-19, opencontainers#388) and 0430aaf (Split create and start, 2016-04-01,
opencontainers#384).

# validation and testing targets

Validation is partly covered by cdcabde (schema: JSON Schema and
validator for `config.json`, 2016-01-19, opencontainers#313) and subequent JSON
Schema work.  The remainder of these targets are handled by ocitools
[3].

# printable/compiled-spec target

The bulk of this was addressed by 4ee036f (*: printable documents,
2015-12-09, opencontainers#263).  Any remaining polishing of that workflow seems
like a GitHub-issue thing and not a ROADMAP thing.  And publishing
these to opencontainers.org certainly seems like it's outside the
scope of this repository (although I think that such publishing is a
good idea).

[1]: https://github.com/opencontainers/image-spec
[2]: https://groups.google.com/a/opencontainers.org/d/msg/dev/xo4SQ92aWJ8/NHpSQ19KCAAJ
     Subject: OCI Bundle Digests Summary
     Date: Wed, 14 Oct 2015 17:09:15 +0000
     Message-ID: <CAD2oYtN-9yLLhG_STO3F1h58Bn5QovK+u3wOBa=t+7TQi-hP1Q@mail.gmail.com>
[3]: https://github.com/opencontainers/ocitools

Signed-off-by: W. Trevor King <wking@tremily.us>
Mashimiao pushed a commit to Mashimiao/specs that referenced this pull request Aug 19, 2016
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]: opencontainers#231 (comment)
[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]: https://github.com/opencontainers/specs/blob/4a63e81a807edec3d67ed2b6bd99a6c2b288676f/bundle.md#container-format

Signed-off-by: W. Trevor King <wking@tremily.us>
Mashimiao pushed a commit to Mashimiao/specs that referenced this pull request Aug 19, 2016
# digest/hashing target

Most of this has spun off with [1], and I haven't heard of anyone
talking about verifying the on-disk filesystem in a while.  My
personal take is on-disk verification doesn't add much over serialized
verification unless you have a local attacker (or unreliable disk),
and you'll need some careful threat modeling if you want to do
anything productive about the local attacker case.  For some more
on-disk verification discussion, see the thread starting with [2].

# distributable-format target

This spun off with [1].

# lifecycle target

I think this is resolved since 7713efc (Add lifecycle for containers,
2015-10-22, opencontainers#231), which was committed on the same day as the ROADMAP
entry (4859f6d, Add initial roadmap, 2015-10-22, opencontainers#230).

# container-action target

Addressed by 7117ede (Expand on the definition of our ops,
2015-10-13, opencontainers#225), although there has been additional discussion in
a7a366b (Remove exec from required runtime functionalities,
2016-04-19, opencontainers#388) and 0430aaf (Split create and start, 2016-04-01,
opencontainers#384).

# validation and testing targets

Validation is partly covered by cdcabde (schema: JSON Schema and
validator for `config.json`, 2016-01-19, opencontainers#313) and subequent JSON
Schema work.  The remainder of these targets are handled by ocitools
[3].

# printable/compiled-spec target

The bulk of this was addressed by 4ee036f (*: printable documents,
2015-12-09, opencontainers#263).  Any remaining polishing of that workflow seems
like a GitHub-issue thing and not a ROADMAP thing.  And publishing
these to opencontainers.org certainly seems like it's outside the
scope of this repository (although I think that such publishing is a
good idea).

[1]: https://github.com/opencontainers/image-spec
[2]: https://groups.google.com/a/opencontainers.org/d/msg/dev/xo4SQ92aWJ8/NHpSQ19KCAAJ
     Subject: OCI Bundle Digests Summary
     Date: Wed, 14 Oct 2015 17:09:15 +0000
     Message-ID: <CAD2oYtN-9yLLhG_STO3F1h58Bn5QovK+u3wOBa=t+7TQi-hP1Q@mail.gmail.com>
[3]: https://github.com/opencontainers/ocitools

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/nmbug-oci that referenced this pull request Jul 26, 2017
My pull request was rejected on 2015-10-12 [1], but Mrunal filed an
alternative which landed on 2015-12-09 [2].

[1]: opencontainers/runtime-spec#207 (comment)
[2]: opencontainers/runtime-spec#231 (comment)
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

9 participants