Skip to content

Commit 19e653f

Browse files
committed
runtime: Transition from Markdown to AsciiDoc
There's a bit of hoop-jumping here for syntax highlighting. asciidoc (the command) can generate highted HTML (and the source-highlighter line in oci-runtime-spec.asc sets it up to use Pygments). However, asciidoc's direct HTML output does not support xref default captions [1]. asciidoc's DocBook output, on the other hand, *does* support default captions [1]. Unfortunately, in this case asciidoc punts the syntax highlighting to DocBook as well, passing through a programlisting tag [2,3]. Unfortunately, syntax highlighting there depends on an XSLTHL extension module which is only implemented in Java [4,5], and that's not worth the trouble ;). Highlighting is a bit easier for the PDF output, because while asciidoc is still delegating to DocBook, DocBook is in turn delegating to LaTeX and listings. Listings v1.6 doesn't support JavaScript or JSON, but it does support Python [6], and Python's dict, list, string, and number syntax is very close to JSON's object, array, string, and number syntax. To setup that mapping, we copy the usual asciidoc-dblatex.sty from the system, add a json -> python alias, and tell dblatex to use our amended style. Also bump the section numbering depth back up to DocBook's default 8 [7]. For some reason, the default a2x output seems to set this to 2. And bump the number of ToC levels up from two to four [8]. An anchor's default captions [9] seem to be treated literally without further parsing. So [[created,`created`]] will lead to references like a regularly-styled "`created`" instead of the intended monospace "created". Monospace isn't worth jumping through lots of hoops for though, so I've just left the backticks off and leaned on the link highlighting to set the should-be-literals off from surrounding text. The [[create,create]] anchors avoid auto-generated captions like: Section 5.4.2, "Create" because we usually use those references as stand-ins for an invokable command (e.g. `funC create ...`). [1]: http://asciidoc.org/userguide.html#_xref [2]: http://asciidoc.org/source-highlight-filter.html#_docbook_outputs [3]: http://docbook.org/tdg/en/html/programlisting.html [4]: http://docbook.sourceforge.net/release/xsl/1.79.1/doc/html/highlight.source.html [5]: https://sourceforge.net/p/xslthl/wiki/Home/ [6]: http://mirrors.ctan.org/macros/latex/contrib/listings/listings.pdf#page=13 [7]: http://docbook.sourceforge.net/release/xsl/1.79.1/doc/html/section.autolabel.max.depth.html [8]: http://asciidoc.org/faq.html#_the_asciidoc_toclevels_attribute_does_not_work_with_docbook_outputs_why [9]: http://asciidoc.org/userguide.html#X30 anchor Signed-off-by: W. Trevor King <[email protected]>
1 parent b8b91c6 commit 19e653f

File tree

9 files changed

+216
-140
lines changed

9 files changed

+216
-140
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
output
22
schema/validate
3+
asciidoc-dblatex-json.sty
34
code-of-conduct.md
45
version.md

Makefile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ OUTPUT_DIRNAME ?= output
44
DOC_FILENAME ?= oci-runtime-spec
55
A2X ?= $(shell command -v a2x 2>/dev/null)
66
DBLATEX ?= $(shell command -v dblatex 2>/dev/null)
7+
DBLATEX_DIR ?= /usr/share/asciidoc/dblatex
78

89
# These docs are in an order that determines how they show up in the PDF/HTML docs.
910
DOC_FILES := $(wildcard *.asc)
@@ -17,9 +18,13 @@ ifeq "$(strip $(A2X) $(DBLATEX))" ''
1718
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf:
1819
$(error cannot build $@ without a2x and dblatex)
1920
else
20-
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES)
21+
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES) asciidoc-dblatex.sty
2122
mkdir -p $(OUTPUT_DIRNAME)
22-
$(A2X) -f pdf --no-xmllint $(ASCIIDOC_SRC)$(DOC_FILENAME).asc
23+
$(A2X) -f pdf --no-xmllint \
24+
--xsltproc-opts '--stringparam section.autolabel.max.depth 8' \
25+
--dblatex-opts '-s $(ASCIIDOC_SRC)asciidoc-dblatex.sty' \
26+
--dblatex-opts '--param toc.section.depth=4' \
27+
$(ASCIIDOC_SRC)$(DOC_FILENAME).asc
2328
mv $(ASCIIDOC_SRC)$(DOC_FILENAME).pdf $@
2429
endif
2530

@@ -29,9 +34,18 @@ $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html:
2934
else
3035
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: $(DOC_FILES)
3136
mkdir -p $(OUTPUT_DIRNAME)
32-
$(A2X) -f xhtml --no-xmllint -D $(OUTPUT_DIRNAME) $(ASCIIDOC_SRC)$(DOC_FILENAME).asc
37+
$(A2X) -f xhtml --no-xmllint \
38+
--xsltproc-opts '--stringparam section.autolabel.max.depth 8' \
39+
--xsltproc-opts '--stringparam toc.section.depth 4' \
40+
-D $(OUTPUT_DIRNAME) \
41+
$(ASCIIDOC_SRC)$(DOC_FILENAME).asc
3342
endif
3443

44+
asciidoc-dblatex.sty: $(DBLATEX_DIR)/asciidoc-dblatex.sty
45+
cp $< $@
46+
echo '\usepackage{listings}' >>$@
47+
echo '\lstalias{json}{python}' >>$@
48+
3549
code-of-conduct.md:
3650
curl -o $@ https://raw.githubusercontent.com/opencontainers/tob/d2f9d68c1332870e40693fe077d311e0742bc73d/code-of-conduct.md
3751

@@ -83,5 +97,5 @@ endif
8397
.PHONY: clean
8498
clean:
8599
rm -rf $(OUTPUT_DIRNAME) *~
86-
rm -f code-of-conduct.md version.md
100+
rm -f asciidoc-dblatex-json.sty code-of-conduct.md version.md
87101

File renamed without changes.

oci-runtime-spec.asc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ include::definitions.asc[]
1919
include::protocols.asc[]
2020

2121
include::bundle.asc[]
22+
23+
include::runtime.asc[]

protocols.asc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ Protocols
33

44
Protocols defined by this specification are:
55

6-
* Linux containers: `<<runtime>>`, `<<runtime-linux>>`, `<<config>>`, and `<<config-linux>>`.
7-
* Solaris containers: `<<runtime>>`, `<<config>>`, and `<<config-solaris>>`.
8-
* Windows containers: `<<runtime>>`, `<<config>>`, and `<<config-windows>>`.
6+
* Linux containers: <<runtime>>, `<<runtime-linux>>`, `<<config>>`, and `<<config-linux>>`.
7+
* Solaris containers: <<runtime>>, `<<config>>`, and `<<config-solaris>>`.
8+
* Windows containers: <<runtime>>, `<<config>>`, and `<<config-windows>>`.

runtime.asc

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
[[runtime]]
2+
Runtime and Lifecycle
3+
---------------------
4+
5+
:implementation-testing: https://github.com/opencontainers/runtime-spec/blob/master/implementations.md#testing--tools
6+
7+
Scope of a Container
8+
~~~~~~~~~~~~~~~~~~~~
9+
10+
Barring access control concerns, the entity using a runtime to create a container MUST be able to use the operations defined in this specification against that same container.
11+
Whether other entities using the same, or other, instance of the runtime can see that container is out of scope of this specification.
12+
13+
[[state]]
14+
State
15+
^^^^^
16+
17+
The state of a container MUST include, at least, the following properties:
18+
19+
[[ociVersion-state,ociVersion]]
20+
`ociVersion`::
21+
(string) is the OCI specification version `<<ociVersion-config,used when creating the container>>`.
22+
23+
[[id,id]] `id`::
24+
(string) is the container's ID.
25+
This MUST be unique across all containers on this host.
26+
There is no requirement that it be unique across hosts.
27+
28+
[[status,status]] `status`::
29+
(string) is the runtime state of the container.
30+
The value MAY be one of:
31+
+
32+
--
33+
[[created,created]] `created`:::
34+
The container has been created but the user-specified code has not yet been executed.
35+
36+
[[running,running]] `running`:::
37+
The container has been created and the user-specified code is running.
38+
39+
[[stopped,stopped]] `stopped`:::
40+
The container has been created and the user-specified code has been executed but is no longer running.
41+
42+
Additional values MAY be defined by the runtime, however, they MUST be used to represent new runtime states not defined above.
43+
--
44+
45+
[[pid,pid]] `pid`::
46+
(int) is the ID of the container process, as seen by the host.
47+
48+
[[bundlePath,bundlePath]] `bundlePath`::
49+
(string) is the absolute path to the container's bundle directory.
50+
This is provided so that consumers can find the container's configuration and root filesystem on the host.
51+
52+
[[state-annotations,state annotations]] `annotations`::
53+
(map) contains the list of annotations associated with the container.
54+
If no annotations were provided then this property MAY either be absent or an empty map.
55+
56+
When serialized in JSON, the format MUST adhere to the following pattern:
57+
58+
[source,json]
59+
{
60+
"ociVersion": "0.2.0",
61+
"id": "oci-container1",
62+
"status": "running",
63+
"pid": 4422,
64+
"bundlePath": "/containers/redis",
65+
"annotations": {
66+
"myKey": "myValue"
67+
}
68+
}
69+
70+
See <<state-operation>> for information on retrieving the state of a container.
71+
72+
Lifecycle
73+
~~~~~~~~~
74+
75+
The lifecycle describes the timeline of events that happen from when a container is created to when it ceases to exist.
76+
77+
. [[lifecycle-create-call, step 1]]
78+
OCI compliant runtime's <<create>> command is invoked with a reference to the location of the bundle and a unique identifier.
79+
80+
. [[lifecycle-create,step 2]]
81+
The container's runtime environment MUST be created according to the configuration in `<<config>>`.
82+
If the runtime is unable to create the environment specified in the `<<config>>`, it MUST generate an error.
83+
While the resources requested in the `<<config>>` MUST be created, the user-specified code (from `<<process>>`) MUST NOT be run at this time.
84+
Any updates to `<<config>>` after this step MUST NOT affect the container.
85+
86+
. [[lifecycle-pre-start,step 3]]
87+
Once the container is created additional actions MAY be performed based on the features the runtime chooses to support.
88+
However, some actions might only be available based on the current state of the container (e.g. only available while it is started).
89+
90+
. [[lifecycle-start,step 4]]
91+
Runtime's <<start>> command is invoked with the unique identifier of the container.
92+
The runtime MUST run the user-specified code, as specified by `<<process>>`.
93+
94+
. [[lifecycle-exit,step 5]]
95+
The container's process is stopped.
96+
This MAY happen due to them erroring out, exiting, crashing or the runtime's <<kill>> operation being invoked.
97+
98+
99+
. [[lifecycle-delete,step 6]]
100+
Runtime's <<delete>> command is invoked with the unique identifier of the container.
101+
The container MUST be destroyed by undoing the steps performed during create phase (<<lifecycle-create>>).
102+
103+
Errors
104+
~~~~~~
105+
106+
In cases where the specified operation generates an error, this specification does not mandate how, or even if, that error is returned or exposed to the user of an implementation.
107+
Unless otherwise stated, generating an error MUST leave the state of the environment as if the operation were never attempted - modulo any possible trivial ancillary changes such as logging.
108+
109+
Operations
110+
~~~~~~~~~~
111+
112+
OCI compliant runtimes MUST support the following operations, unless the operation is not supported by the base operating system.
113+
114+
[NOTE]
115+
These operations are not specifying any command line APIs, and the parameters are inputs for general operations.
116+
117+
[[state-operation]]
118+
[caption="foo bar"]
119+
State
120+
^^^^^
121+
122+
`state <container-id>`
123+
124+
This operation MUST generate an error if it is not provided the ID of a container.
125+
Attempting to query a container that does not exist MUST generate an error.
126+
This operation MUST return the state of a container as specified in <<state>>.
127+
128+
[[create,create]]
129+
Create
130+
^^^^^^
131+
132+
`create <container-id> <path-to-bundle>`
133+
134+
This operation MUST generate an error if it is not provided a path to the bundle and the container ID to associate with the container.
135+
If the ID provided is not unique across all containers within the scope of the runtime, or is not valid in any other way, the implementation MUST generate an error and a new container MUST NOT be created.
136+
Using the data in `<<config,config.json>>`, this operation MUST create a new container.
137+
This means that all of the resources associated with the container MUST be created, however, the user-specified code MUST NOT be run at this time.
138+
If the runtime cannot create the container as specified in `<<config,config.json>>`, it MUST generate an error and a new container MUST NOT be created.
139+
140+
Upon successful completion of this operation the <<status>> property of this container MUST be <<created>>.
141+
142+
The runtime MAY validate `config.json` against this spec, either generically or with respect to the local system capabilities, before creating the container (<<lifecycle-create>>).
143+
Runtime callers who are interested in pre-create validation can run {implementation-testing}[bundle-validation tools] before invoking the create operation.
144+
145+
Any changes made to the `<<config>>` after this operation will not have an effect on the container.
146+
147+
[[start,start]]
148+
Start
149+
^^^^^
150+
151+
`start <container-id>`
152+
153+
This operation MUST generate an error if it is not provided the container ID.
154+
Attempting to start a container that does not exist MUST generate an error.
155+
Attempting to start an already started container MUST have no effect on the container and MUST generate an error.
156+
This operation MUST run the user-specified code as specified by `<<process>>`.
157+
158+
Upon successful completion of this operation the <<status>> property of this container MUST be <<running>>.
159+
160+
[[kill,kill]]
161+
Kill
162+
^^^^
163+
164+
`kill <container-id> <signal>`
165+
166+
This operation MUST generate an error if it is not provided the container ID.
167+
Attempting to send a signal to a container that is not running MUST have no effect on the container and MUST generate an error.
168+
This operation MUST send the specified signal to the process in the container.
169+
170+
When the process in the container is stopped, irrespective of it being as a result of a `kill` operation or any other reason, the <<status>> property of this container MUST be <<stopped>>.
171+
172+
[[delete,delete]]
173+
Delete
174+
^^^^^^
175+
176+
`delete <container-id>`
177+
178+
This operation MUST generate an error if it is not provided the container ID.
179+
Attempting to delete a container that does not exist MUST generate an error.
180+
Attempting to delete a container whose process is still running MUST generate an error.
181+
Deleting a container MUST delete the resources that were created during <<lifecycle-create>>.
182+
Note that resources associated with the container, but not created by this container, MUST NOT be deleted.
183+
Once a container is deleted its ID MAY be used by a subsequent container.
184+
185+
[[runtime-hooks]]
186+
Hooks
187+
^^^^^
188+
189+
Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation.
190+
See `<<hooks>>` for more information.

runtime.md

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)