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

config: Add Windows Devices to Schema #976

Merged
merged 3 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions config-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ The Windows container specification uses APIs provided by the Windows Host Compu
}
```

## <a name="configWindowsDevices" />Devices

**`devices`** (array of objects, OPTIONAL) lists devices that MUST be available in the container.

Each entry has the following structure:

* **`id`** *(string, REQUIRED)* - specifies the device which the runtime MUST make available in the container.
* **`id_type`** *(string, REQUIRED)* - tells the runtime how to interpret `id`. Today, Windows only supports a value of `class`, which identifies `id` as a [device interface class GUID][interfaceGUID].
Copy link
Member

@crosbymichael crosbymichael Jul 10, 2018

Choose a reason for hiding this comment

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

Are there going to be other types other than class?

Also this should be idType not id_type

Copy link
Member

Choose a reason for hiding this comment

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

I also wonder if this is really flexible enough for future needs -- will all future resources that might count as devices have some kind of ID? (I guess it's Windows we're talking about, so everything has a GUID of some kind?)

Being able to attach all sound devices to a container is neat, but if you want something like raw hard drive or USB drive access you'd have to attach all drives, which isn't great, right? (I'm guessing that's why idType is included here -- so id could instead point to the GUID of an individual device at some point in the future?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@crosbymichael Thanks for catching the typo, let me commit a fix. In the future, we'll certainly have more types.

That's correct, @tianon. Each device in Windows is guaranteed to have a unique device instance path ID. In the future it would be easy to extend so that id= and idType="instance" or some other label. Given this, I think what we have is extensible to give finer granularity in defining a device for a Windows container in the future.


[interfaceGUID]: https://docs.microsoft.com/en-us/windows-hardware/drivers/install/overview-of-device-interface-classes

### Example

```json
"windows": {
"devices": [
{
"id": "24E552D7-6523-47F7-A647-D3465BF1F5CA",
"id_type": "class"
},
{
"id": "5175d334-c371-4806-b3ba-71fd53c9258d",
"id_type": "class"
}
]
}
```

## <a name="configWindowsResources" />Resources

You can configure a container's resource limits via the OPTIONAL `resources` field of the Windows configuration.
Expand Down
1 change: 1 addition & 0 deletions schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The layout of the files is as follows:
* [state-schema.json](state-schema.json) - the primary entrypoint for the [state JSON](../runtime.md#state) schema
* [defs.json](defs.json) - definitions for general types
* [defs-linux.json](defs-linux.json) - definitions for Linux-specific types
* [defs-windows.json](defs-windows.json) - definitions for Windows-specific types
* [validate.go](validate.go) - validation utility source code


Expand Down
6 changes: 6 additions & 0 deletions schema/config-windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
},
"minItems": 1
},
"devices": {
"type": "array",
"items": {
"$ref": "defs-windows.json#/definitions/Device"
}
},
"resources": {
"type": "object",
"properties": {
Expand Down
22 changes: 22 additions & 0 deletions schema/defs-windows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"definitions": {
"Device": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"id_type": {
"type": "string",
"enum": [
"class"
]
}
},
"required": [
"id",
"id_type"
Copy link
Contributor

@wking wking Jun 20, 2018

Choose a reason for hiding this comment

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

I think you should define these as strings as well as marking them required. Alternatively, id_type could be an enum.

]
}
}
}
10 changes: 10 additions & 0 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ type SolarisAnet struct {
type Windows struct {
// LayerFolders contains a list of absolute paths to directories containing image layers.
LayerFolders []string `json:"layerFolders"`
// Devices are a list of interface class GUIDs for which device objects need to be mapped into the container.
Devices []WindowsDevice `json:"devices,omitempty"`
// Resources contains information for handling resource constraints for the container.
Resources *WindowsResources `json:"resources,omitempty"`
// CredentialSpec contains a JSON object describing a group Managed Service Account (gMSA) specification.
Expand All @@ -447,6 +449,14 @@ type Windows struct {
Network *WindowsNetwork `json:"network,omitempty"`
}

// WindowsDevice represents information about a host device to be mapped into the container.
type WindowsDevice struct {
// Device identifier: interface class GUID, etc.
Id string `json:"id"`
// Device identifier type: "class", etc.
IdType string `json:"id_type"`
}

// WindowsResources has container runtime resource constraints for containers running on Windows.
type WindowsResources struct {
// Memory restriction configuration.
Expand Down