{"action":"created","comment":{"url":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/comments/62918042","id":62918042,"diff_hunk":"@@ -34,22 +32,25 @@ See [Query State](#query-state) for information on retrieving the state of a con\n \n ## Lifecycle\n The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist.\n-\n-1. OCI compliant runtime is invoked with a reference to the location of the bundle.\n-   How this reference is passed to the runtime is an implementation detail.\n-2. The container's runtime environment MUST be created according to the configuration in [`config.json`](config.md).\n-   Any updates to `config.json` after container is running MUST not affect the container.\n-3. The prestart hooks MUST be invoked by the runtime.\n-   If any prestart hook fails, then the container MUST be stopped and the lifecycle continues at step 7.\n-4. The user specified process MUST be executed in the container.\n-5. The poststart hooks MUST be invoked by the runtime.\n-   If any poststart hook fails, then the container MUST be stopped and the lifecycle continues at step 7.\n-6. Additional actions such as pausing the container, resuming the container or signaling the container MAY be performed using the runtime interface.\n-   The container MAY also error out, exit or crash.\n-7. The container MUST be destroyed by undoing the steps performed during create phase (step 2).\n-8. The poststop hooks MUST be invoked by the runtime and errors, if any, SHOULD be logged.\n-\n-Note: The lifecycle is a WIP and it will evolve as we have more use cases and more information on the viability of a separate create phase.\n+1. OCI compliant runtime's `create` command is invoked with a reference to the location of the bundle and a unique identifier.\n+   How these references are passed to the runtime is an implementation detail.\n+2. The container's runtime environment (namespaces, mounts, etc.) MUST be created according to the configuration in [`config.json`](config.md).\n+   If a new PID namespace is requested in the [`config.json`](config.md), a PID namespace MUST created at this time.\n+   However, the user-specified code (from [`process`](config.md#process-configuration) MUST NOT be run at this time.\n+   With the exception of the user-specified process, any updates to `config.json` after container is created MUST NOT affect the container.\n+3. Once the container is created additional actions MAY be performed based on the features the runtime chooses to support.\n+  However, some actions might only be available based on the current state of the container (e.g. only available while it is started).\n+4. Runtime's `start` command is invoked with the unique identifier of the container.\n+   The runtime MUST run the user-specified code, as specified by [`process`](config.md#process-configuration), in the container's PID namespace.\n+   Any updates to the user-specified code in [`process`](config.md#process-configuration) after this point MUST NOT have any effect on the container.\n+5. The container's processes are stopped.\n+   This MAY happen due to them erroring out, exiting or crashing.\n+   The runtime's `stop` operation MAY also be used to stop the processes running within the container.\n+6. If the [`autoremove`](config.md#root-configuration) property is present with a value of `true` the runtime's `delete` operation is automatically invoked.\n+6. Runtime's `delete` command is invoked with the identifier of the container.\n+   The container MUST be destroyed by undoing the steps performed during create phase (step 2).\n+   For clarity, the runtime MUST make a best-effort attempt to delete all resources that were create in step 2.\n+   The phrase \"best-effort\" is to allow for situations where some other processes, or container, is \"holding on\" to a resource and the runtime is therefore unable to delete it.","path":"runtime.md","position":47,"original_position":47,"commit_id":"0430aaf1dc22da65b66c28e8ba7ffb5ed912774a","original_commit_id":"0430aaf1dc22da65b66c28e8ba7ffb5ed912774a","user":{"login":"wking","id":209920,"avatar_url":"https://avatars.githubusercontent.com/u/209920?v=3","gravatar_id":"","url":"https://api.github.com/users/wking","html_url":"https://github.com/wking","followers_url":"https://api.github.com/users/wking/followers","following_url":"https://api.github.com/users/wking/following{/other_user}","gists_url":"https://api.github.com/users/wking/gists{/gist_id}","starred_url":"https://api.github.com/users/wking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wking/subscriptions","organizations_url":"https://api.github.com/users/wking/orgs","repos_url":"https://api.github.com/users/wking/repos","events_url":"https://api.github.com/users/wking/events{/privacy}","received_events_url":"https://api.github.com/users/wking/received_events","type":"User","site_admin":false},"body":"On Wed, May 11, 2016 at 10:14:30AM -0700, Daniel, Dao Quang Minh wrote:\n> > +   The container MUST be destroyed by undoing the steps performed during create phase (step 2).\n> > +   For clarity, the runtime MUST make a best-effort attempt to delete all resources that were create in step 2.\n> > +   The phrase \"best-effort\" is to allow for situations where some other processes, or container, is \"holding on\" to a resource and the runtime is therefore unable to delete it.\n> \n> I dont really like \"best-effort\" approach here. I think we should\n> just return an error for each resource that we can't delete and let\n> the runtime caller decide.  Or perhaps we should reword this as\n> `MUST delete all unreferenced resources that was created`.\n\nYeah, we can probably do better.  How about something like:\n\n  The container MUST be destroyed by undoing the steps performed during create phase (step 2).\n  For clarity, the runtime MUST remove any references to system resources that it created.\n  The runtime MUST NOT remove any references to system resources created by others.\n  For example, a namespace created by the runtime during the create phase may have been bind mounted by the user before the delete phase.\n  In that case, the namespace will still exist after delete, but the runtime itself will no longer hold any references to the namespace.\n\nI think that could still be improved, but it's a bit less wiggly than\n“best effort”.  On the other hand, I don't think getting the right\nwording around this case is important enough to block this PR; we're\nall circling around the same idea.\n","created_at":"2016-05-11T20:13:53Z","updated_at":"2016-05-11T20:13:53Z","html_url":"https://github.com/opencontainers/runtime-spec/pull/384#discussion_r62918042","pull_request_url":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384","_links":{"self":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/comments/62918042"},"html":{"href":"https://github.com/opencontainers/runtime-spec/pull/384#discussion_r62918042"},"pull_request":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384"}}},"pull_request":{"url":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384","id":66282883,"html_url":"https://github.com/opencontainers/runtime-spec/pull/384","diff_url":"https://github.com/opencontainers/runtime-spec/pull/384.diff","patch_url":"https://github.com/opencontainers/runtime-spec/pull/384.patch","issue_url":"https://api.github.com/repos/opencontainers/runtime-spec/issues/384","number":384,"state":"open","locked":false,"title":"Split create and start","user":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"body":"## This PR does the following:\r\n- splits `start` into `create` and `start`\r\n- adds a `run` operation which is a merging of `create` and `start`.\r\n- adds a `stop` operation to allow for the stopping of the user-defined process, and deletion of the PID NS, but not a deletion of all other resources associated with the container.\r\n- adds an `autoremove` property to the config.json so that once the PID NS is deleted the `delete` operation is automatically called so the user doesn't need to do it manually.\r\n\r\n## Lifecycle flow after with this PR:\r\n- `create()` is invoked to setup the container's NSs, cgroups, etc., but the user process is not yet started. The PID NS is created but paused waiting for the `start()` operation to be invoked. Control is returned to the caller.\r\n- At this point any additional processing (e.g. pre-start hooks) can be invoked by the management/orchestration tooling.\r\n- `start()` is invoked. The config.json's `process` property is used to start the user-defined process that is to be executed in the PID NS. Whether control is returned to the caller or not will depend on whether a `--detach` type of option was specified - so this is runtime dependent.\r\n- Note that there is a `run()` operation that can be used instead - this is a merging of `create()` and `start()`.\r\n- The user-defined process will eventually stop - either by exiting or via some external action (like the `stop()` operation being invoked).\r\n- Once the PID NS is deleted, ie. the user-defined process stops, if the `autoremove` property is `true` then the `delete()` operation is invoked.\r\n- If the `autoremove` property is `false`, or not defined, then processing is returned to the caller and any additional processing (e.g. pre-delete hooks) can be invoked by the management/orchestration tooling.\r\n- `delete()` is invoked, which removes all resources (NS, cgroups, etc.) created for this container. Note that any resources used by the container but not created during the `create()` phase are not deleted as they are owned by some other container.\r\n\r\n## Motivating usecases:\r\n- to simplify the flows/interaction patterns by removing hooks, but still allow for the same functionality\r\n- allow for the container's resources to be created prior to defining the user-defined process being defined/run\r\n- allow a single orchestrator process to set up the container before the user process starts. Avoid needing to persist potentially private information to disk to make it available to args/env vars of hooks since now the hooks can be within the orchestrator, thus have access to its in-memory state.\r\n- allow for a cleaner \"sandbox\" model where one container (and its resources) are created for the purpose of then being used by other (subordinate) containers. \r\n\r\n\r\nSigned-off-by: Doug Davis <dug@us.ibm.com>","created_at":"2016-04-13T08:26:51Z","updated_at":"2016-05-11T20:13:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e077bd0be51e8e9ed4cc39279cdd49521bd32002","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384/commits","review_comments_url":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384/comments","review_comment_url":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opencontainers/runtime-spec/issues/384/comments","statuses_url":"https://api.github.com/repos/opencontainers/runtime-spec/statuses/0430aaf1dc22da65b66c28e8ba7ffb5ed912774a","head":{"label":"duglin:SplitCreate","ref":"SplitCreate","sha":"0430aaf1dc22da65b66c28e8ba7ffb5ed912774a","user":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"repo":{"id":43553626,"name":"runtime-spec","full_name":"duglin/runtime-spec","owner":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/duglin/runtime-spec","description":"Open Container Specifications","fork":true,"url":"https://api.github.com/repos/duglin/runtime-spec","forks_url":"https://api.github.com/repos/duglin/runtime-spec/forks","keys_url":"https://api.github.com/repos/duglin/runtime-spec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duglin/runtime-spec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duglin/runtime-spec/teams","hooks_url":"https://api.github.com/repos/duglin/runtime-spec/hooks","issue_events_url":"https://api.github.com/repos/duglin/runtime-spec/issues/events{/number}","events_url":"https://api.github.com/repos/duglin/runtime-spec/events","assignees_url":"https://api.github.com/repos/duglin/runtime-spec/assignees{/user}","branches_url":"https://api.github.com/repos/duglin/runtime-spec/branches{/branch}","tags_url":"https://api.github.com/repos/duglin/runtime-spec/tags","blobs_url":"https://api.github.com/repos/duglin/runtime-spec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duglin/runtime-spec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duglin/runtime-spec/git/refs{/sha}","trees_url":"https://api.github.com/repos/duglin/runtime-spec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duglin/runtime-spec/statuses/{sha}","languages_url":"https://api.github.com/repos/duglin/runtime-spec/languages","stargazers_url":"https://api.github.com/repos/duglin/runtime-spec/stargazers","contributors_url":"https://api.github.com/repos/duglin/runtime-spec/contributors","subscribers_url":"https://api.github.com/repos/duglin/runtime-spec/subscribers","subscription_url":"https://api.github.com/repos/duglin/runtime-spec/subscription","commits_url":"https://api.github.com/repos/duglin/runtime-spec/commits{/sha}","git_commits_url":"https://api.github.com/repos/duglin/runtime-spec/git/commits{/sha}","comments_url":"https://api.github.com/repos/duglin/runtime-spec/comments{/number}","issue_comment_url":"https://api.github.com/repos/duglin/runtime-spec/issues/comments{/number}","contents_url":"https://api.github.com/repos/duglin/runtime-spec/contents/{+path}","compare_url":"https://api.github.com/repos/duglin/runtime-spec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duglin/runtime-spec/merges","archive_url":"https://api.github.com/repos/duglin/runtime-spec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duglin/runtime-spec/downloads","issues_url":"https://api.github.com/repos/duglin/runtime-spec/issues{/number}","pulls_url":"https://api.github.com/repos/duglin/runtime-spec/pulls{/number}","milestones_url":"https://api.github.com/repos/duglin/runtime-spec/milestones{/number}","notifications_url":"https://api.github.com/repos/duglin/runtime-spec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duglin/runtime-spec/labels{/name}","releases_url":"https://api.github.com/repos/duglin/runtime-spec/releases{/id}","deployments_url":"https://api.github.com/repos/duglin/runtime-spec/deployments","created_at":"2015-10-02T13:15:03Z","updated_at":"2016-03-31T12:00:32Z","pushed_at":"2016-05-05T17:05:33Z","git_url":"git://github.com/duglin/runtime-spec.git","ssh_url":"git@github.com:duglin/runtime-spec.git","clone_url":"https://github.com/duglin/runtime-spec.git","svn_url":"https://github.com/duglin/runtime-spec","homepage":"http://www.opencontainers.org","size":487,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opencontainers:master","ref":"master","sha":"38dd2fdc30e8c30100cc99b6c13d3f1d5c6e59c8","user":{"login":"opencontainers","id":12563465,"avatar_url":"https://avatars.githubusercontent.com/u/12563465?v=3","gravatar_id":"","url":"https://api.github.com/users/opencontainers","html_url":"https://github.com/opencontainers","followers_url":"https://api.github.com/users/opencontainers/followers","following_url":"https://api.github.com/users/opencontainers/following{/other_user}","gists_url":"https://api.github.com/users/opencontainers/gists{/gist_id}","starred_url":"https://api.github.com/users/opencontainers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencontainers/subscriptions","organizations_url":"https://api.github.com/users/opencontainers/orgs","repos_url":"https://api.github.com/users/opencontainers/repos","events_url":"https://api.github.com/users/opencontainers/events{/privacy}","received_events_url":"https://api.github.com/users/opencontainers/received_events","type":"Organization","site_admin":false},"repo":{"id":36960293,"name":"runtime-spec","full_name":"opencontainers/runtime-spec","owner":{"login":"opencontainers","id":12563465,"avatar_url":"https://avatars.githubusercontent.com/u/12563465?v=3","gravatar_id":"","url":"https://api.github.com/users/opencontainers","html_url":"https://github.com/opencontainers","followers_url":"https://api.github.com/users/opencontainers/followers","following_url":"https://api.github.com/users/opencontainers/following{/other_user}","gists_url":"https://api.github.com/users/opencontainers/gists{/gist_id}","starred_url":"https://api.github.com/users/opencontainers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencontainers/subscriptions","organizations_url":"https://api.github.com/users/opencontainers/orgs","repos_url":"https://api.github.com/users/opencontainers/repos","events_url":"https://api.github.com/users/opencontainers/events{/privacy}","received_events_url":"https://api.github.com/users/opencontainers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opencontainers/runtime-spec","description":"Open Container Specifications","fork":false,"url":"https://api.github.com/repos/opencontainers/runtime-spec","forks_url":"https://api.github.com/repos/opencontainers/runtime-spec/forks","keys_url":"https://api.github.com/repos/opencontainers/runtime-spec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opencontainers/runtime-spec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opencontainers/runtime-spec/teams","hooks_url":"https://api.github.com/repos/opencontainers/runtime-spec/hooks","issue_events_url":"https://api.github.com/repos/opencontainers/runtime-spec/issues/events{/number}","events_url":"https://api.github.com/repos/opencontainers/runtime-spec/events","assignees_url":"https://api.github.com/repos/opencontainers/runtime-spec/assignees{/user}","branches_url":"https://api.github.com/repos/opencontainers/runtime-spec/branches{/branch}","tags_url":"https://api.github.com/repos/opencontainers/runtime-spec/tags","blobs_url":"https://api.github.com/repos/opencontainers/runtime-spec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opencontainers/runtime-spec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opencontainers/runtime-spec/git/refs{/sha}","trees_url":"https://api.github.com/repos/opencontainers/runtime-spec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opencontainers/runtime-spec/statuses/{sha}","languages_url":"https://api.github.com/repos/opencontainers/runtime-spec/languages","stargazers_url":"https://api.github.com/repos/opencontainers/runtime-spec/stargazers","contributors_url":"https://api.github.com/repos/opencontainers/runtime-spec/contributors","subscribers_url":"https://api.github.com/repos/opencontainers/runtime-spec/subscribers","subscription_url":"https://api.github.com/repos/opencontainers/runtime-spec/subscription","commits_url":"https://api.github.com/repos/opencontainers/runtime-spec/commits{/sha}","git_commits_url":"https://api.github.com/repos/opencontainers/runtime-spec/git/commits{/sha}","comments_url":"https://api.github.com/repos/opencontainers/runtime-spec/comments{/number}","issue_comment_url":"https://api.github.com/repos/opencontainers/runtime-spec/issues/comments{/number}","contents_url":"https://api.github.com/repos/opencontainers/runtime-spec/contents/{+path}","compare_url":"https://api.github.com/repos/opencontainers/runtime-spec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opencontainers/runtime-spec/merges","archive_url":"https://api.github.com/repos/opencontainers/runtime-spec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opencontainers/runtime-spec/downloads","issues_url":"https://api.github.com/repos/opencontainers/runtime-spec/issues{/number}","pulls_url":"https://api.github.com/repos/opencontainers/runtime-spec/pulls{/number}","milestones_url":"https://api.github.com/repos/opencontainers/runtime-spec/milestones{/number}","notifications_url":"https://api.github.com/repos/opencontainers/runtime-spec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opencontainers/runtime-spec/labels{/name}","releases_url":"https://api.github.com/repos/opencontainers/runtime-spec/releases{/id}","deployments_url":"https://api.github.com/repos/opencontainers/runtime-spec/deployments","created_at":"2015-06-05T23:30:10Z","updated_at":"2016-05-10T10:55:29Z","pushed_at":"2016-05-11T09:10:07Z","git_url":"git://github.com/opencontainers/runtime-spec.git","ssh_url":"git@github.com:opencontainers/runtime-spec.git","clone_url":"https://github.com/opencontainers/runtime-spec.git","svn_url":"https://github.com/opencontainers/runtime-spec","homepage":"http://www.opencontainers.org","size":1861,"stargazers_count":689,"watchers_count":689,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":114,"mirror_url":null,"open_issues_count":23,"forks":114,"open_issues":23,"watchers":689,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384"},"html":{"href":"https://github.com/opencontainers/runtime-spec/pull/384"},"issue":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/issues/384"},"comments":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/issues/384/comments"},"review_comments":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384/comments"},"review_comment":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/pulls/384/commits"},"statuses":{"href":"https://api.github.com/repos/opencontainers/runtime-spec/statuses/0430aaf1dc22da65b66c28e8ba7ffb5ed912774a"}}}}