Skip to content

Commit 0535808

Browse files
committed
Add type field for mounts
This change adds a type field for mounts to the CDI spec. This is required to allow for non-bind mounts (e.g. tmpfs) in the OCI runtime spec. Signed-off-by: Evan Lezar <[email protected]>
1 parent 2d64bbb commit 0535808

File tree

6 files changed

+33
-2
lines changed

6 files changed

+33
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ $ cat > /etc/cdi/vendor.json <<EOF
4848
],
4949
"mounts": [
5050
{"hostPath": "/bin/vendorBin", "containerPath": "/bin/vendorBin"},
51-
{"hostPath": "/usr/lib/libVendor.so.0", "containerPath": "/usr/lib/libVendor.so.0"}
51+
{"hostPath": "/usr/lib/libVendor.so.0", "containerPath": "/usr/lib/libVendor.so.0"},
52+
{"hostPath": "tmpfs", "containerPath": "/tmp/data", "type": "tmpfs", "options": ["nosuid","strictatime","mode=755","size=65536k"]}
5253
],
5354
"hooks": [
5455
{"createContainer": {"path": "/bin/vendor-hook"} },

SPEC.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ The key words "must", "must not", "required", "shall", "shall not", "should", "s
111111
{
112112
"hostPath": "<source>",
113113
"containerPath": "<destination>",
114-
"options": "<OCI Mount Options>", (optional)
114+
"type": "<OCI Mount Type>", (optional)
115+
"options": "<OCI Mount Options>" (optional)
115116
}
116117
],
117118
"hooks": [ (optional)
@@ -183,6 +184,7 @@ The `containerEdits` field has the following definition:
183184
* `mounts` (array of objects, OPTIONAL) describes the mounts that should be mounted:
184185
* `hostPath` (string, REQUIRED) path of the device on the host.
185186
* `containerPath` (string, REQUIRED) path of the device within the container.
187+
* `type` (string, OPTIONAL) the type of the filesystem to be mounted. For bind mounts (when options include either bind or rbind), the type is a dummy, often "none" (not listed in /proc/filesystems).
186188
* `options` (array of strings, OPTIONAL) Mount options of the filesystem to be used.
187189
* `hooks` (array of objects, OPTIONAL) describes the hooks that should be ran:
188190
* `hookName` is the name of the hook to invoke, if the runtime is OCI compliant it should be one of {createRuntime, createContainer, startContainer, poststart, poststop}.

pkg/cdi/spec_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,29 @@ devices:
293293
containerEdits:
294294
env:
295295
- "FOO=BAR"
296+
`,
297+
vendor: "vendor.com",
298+
class: "device",
299+
},
300+
{
301+
name: "valid",
302+
priority: 1,
303+
data: `
304+
cdiVersion: "0.4.0"
305+
kind: vendor.com/device
306+
devices:
307+
- name: "dev1"
308+
containerEdits:
309+
mounts:
310+
- hostPath: "tmpfs"
311+
containerPath: "/usr/local/container"
312+
type: "tmpfs"
313+
options:
314+
- "ro"
315+
- "mode=755"
316+
- "size=65536k"
317+
env:
318+
- "FOO=BAR"
296319
`,
297320
vendor: "vendor.com",
298321
class: "device",

schema/defs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
},
6464
"options": {
6565
"$ref": "#/definitions/ArrayOfStrings"
66+
},
67+
"type": {
68+
"type": "string"
6669
}
6770
},
6871
"required": [

specs-go/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Mount struct {
4545
HostPath string `json:"hostPath"`
4646
ContainerPath string `json:"containerPath"`
4747
Options []string `json:"options,omitempty"`
48+
Type string `json:"type,omitempty"`
4849
}
4950

5051
// Hook represents a hook that needs to be added to the OCI spec.

specs-go/oci.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (m *Mount) ToOCI() spec.Mount {
9595
Source: m.HostPath,
9696
Destination: m.ContainerPath,
9797
Options: m.Options,
98+
Type: m.Type,
9899
}
99100
}
100101

0 commit comments

Comments
 (0)