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 support for Windows based containers #573

Merged
merged 1 commit into from
Sep 26, 2016

Conversation

lowenna
Copy link
Contributor

@lowenna lowenna commented Sep 17, 2016

Signed-off-by: John Howard jhoward@microsoft.com

This adds Windows support to the OCI runtime-spec: code, JSON schema and markdown documentation. Note that the support has been added using 'aggressive namespacing', the matching changes of which for Linux and Solaris being currently out for review in #567.

This is a formal follow-on the the previous proof-of-concept PR to add support for Windows, #504

@lowenna lowenna changed the title In progress - adding Windows Add support for Windows based containers Sep 17, 2016

* **`bps`** *(uint64, optional)* - specifies the maximum bytes per second for the system drive of the container.

* **`sandboxSize`** *(uint64, optional)* - specifies the size to expand the system drive of the container to if it is currently smaller.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe:

specifies the minimum size of the system drive in bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Far more succinct. Will be in next push.

Copy link
Contributor

@wking wking left a comment

Choose a reason for hiding this comment

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

Also needs the README bits from #554.

"network": {
"egressBandwidth": 1048577
}
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Trailing newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next push.

@@ -25,6 +25,8 @@ type Spec struct {
Linux *Linux `json:"linux,omitempty" platform:"linux"`
// Solaris is platform specific configuration for Solaris containers.
Solaris *Solaris `json:"solaris,omitempty" platform:"solaris"`
// Windows is platform specific configuration for Windows based containers, including Hyper-V containers.
Windows *Windows `json:"solaris,omitempty" platform:"windows"`
Copy link
Contributor

Choose a reason for hiding this comment

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

solaris -> windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Embarrassing copy/paste error! Yes, that one is definitely fixed in the upcoming push.

@lowenna
Copy link
Contributor Author

lowenna commented Sep 18, 2016

@wking - comments addressed. And updated README from #554.


#### Memory

`memory` is used to set limits on the container's memory usage.
Copy link
Contributor

Choose a reason for hiding this comment

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

The existing spec is not very consistent about this, but I'd like to see an OPTIONAL dropped into this sentence. Maybe:

memory is an OPTIONAL configuration for the container's memory usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No objection at all. Modified memory, CPU, storage, and networking to all match this pattern.

type Windows struct {
// Resources contains information for handling resource constraints for the container.
Resources *WindowsResources `json:"resources,omitempty"`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't seem to define this in the Markdown. If you really want:

{
  
  "windows": {
    "resources": {
      "memory": {}
    }
  }
}

instead of:

{
  
  "windows": {
    "memory": {}
  }
}

You should drop a resources note in the Markdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, done.

@wking
Copy link
Contributor

wking commented Sep 18, 2016

On Sat, Sep 17, 2016 at 09:21:03PM -0700, John Howard wrote:

+#### Memory
+
+memory is used to set limits on the container's memory usage.

No objection at all. Modified memory, CPU, storage, and networking
to all match this pattern.

I think we want all-caps OPTIONAL to trigger the RFC 2119 semantics
1. I'll file a separate PR to update the existing instances.

@lowenna lowenna force-pushed the jjh/addwindows branch 2 times, most recently from ecae27f to 1ac354b Compare September 18, 2016 04:28

* **`limit`** *(uint64, optional)* - sets limit of memory usage in bytes

* **`reservation`** *(uint64, optional)* - sets soft limit of memory usage in bytes
Copy link
Contributor

Choose a reason for hiding this comment

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

Linux has resource limits with soft and hard settings:

The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit: an unprivileged process may set only its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit. A privileged process (under Linux: one with the CAP_SYS_RESOURCE capability) may make arbitrary changes to either limit value.

So when you say “soft limit”, that's what I'm thinking. However, “reservation” sounds more like “I need at least this much”. Is this setting a minimum amount required by the container? Or an initial limit on the amount that the container can consume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Memory management is very different between Linux and Windows. Here, it means a guaranteed minimum amount of memory. I used the existing terminology though. Perhaps incorrectly?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't realize we already had that language, and think it needs to be clarified for the Linux case too. Grepping through runC shows that reservation is backed by memory.soft_limit_in_bytes. Kernel docs for that have the following to say about soft limits:

.7. Soft limits

Soft limits allow for greater sharing of memory. The idea behind soft limits
is to allow control groups to use as much of the memory as needed, provided

a. There is no memory contention
b. They do not exceed their hard limit

When the system detects memory contention or low memory, control groups
are pushed back to their soft limits. If the soft limit of each control
group is very high, they are pushed back as much as possible to make
sure that one control group does not starve the others of memory.

Please note that soft limits is a best-effort feature; it comes with
no guarantees, but it does its best to make sure that when memory is
heavily contended for, memory is allocated based on the soft limit
hints/setup. Currently soft limit based reclaim is set up such that
it gets invoked from balance_pgdat (kswapd).

So in your case I think reservation makes a lot of sense for the property name, but you should reroll the description to say something like “guaranteed minimum amount of memory”.

@lowenna
Copy link
Contributor Author

lowenna commented Sep 18, 2016

@wking And final update for now - change optional to OPTIONAL per your latest comment. Didn't realise you meant the capitalisation the previous time.


```json
"windows": {
"resources" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a colon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed (all 4 occurances)

"limit": 2097152,
"reservation": 524288
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like an extra level of indents for these two closing braces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Tab rather than 4 spaces. Blame editor 😇

@lowenna lowenna force-pushed the jjh/addwindows branch 4 times, most recently from fc3ec5d to 6e02225 Compare September 18, 2016 04:38
The Windows container specification uses APIs provided by the Windows Host Compute Service (HCS) to fulfill the spec.

You can configure a container's resource limits via the `resources` field of the Windows configuration.
Do not specify `resources` unless required.
Copy link
Contributor

Choose a reason for hiding this comment

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

This last line seems overly strict. How about dropping it and using “…the OPTIONAL resources…” in the preceding line?

Copy link
Contributor

Choose a reason for hiding this comment

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

And probably worth a ## Resources before this paragraph so you can link to it specifically after the Windows-specific file grows other types of configurations (which is presumably why you have a resources level at all ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re wording - I pulled that wording from the Linux spec, or so I thought, so I must have been a little over-keen modifying for the Windows version. So yes, have toned down the verbiage accordingly. Will be in next push.

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 to include ## Resources too. Update pushed.

Do not specify `resources` unless required.


#### Memory
Copy link
Contributor

Choose a reason for hiding this comment

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

With ## Resources above, this one should be an h3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Have fixed the h1..h4s to be consistent throughout.

@wking
Copy link
Contributor

wking commented Sep 18, 2016 via email

@lowenna lowenna force-pushed the jjh/addwindows branch 4 times, most recently from b476ef3 to e4bcc04 Compare September 19, 2016 21:10
@lowenna
Copy link
Contributor Author

lowenna commented Sep 19, 2016

Now with JSON schema 😄

@wking
Copy link
Contributor

wking commented Sep 19, 2016

On Mon, Sep 19, 2016 at 01:36:21PM -0700, John Howard wrote:

+You can configure a container's resource limits via the resources field of the Windows configuration.
+Do not specify resources unless required.

Re wording - I pulled that wording from the Linux spec…

Looks like you did ;). I've filed #576 to adjust this language on
Linux.

},
"percent": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/percent",
"$ref": "defs.json#/definitions/uint8Pointer"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we want to use defs.json#/definitions/percentPointer backed by something like:

"percent": {
  "type": "integer",
  "minimum": 0,
  "maximum": 100
},
"percentPointer": {
  "oneOf": [
    {
      "$ref": "#/definitions/percent"
    },
    {
      "type": "null"
    }
  ]
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch - didn't think of that. Will update.

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 in 40bf0b7


The following parameters can be specified:

* **`count`** *(uint64, optional)* - specifies the number of CPUs available to the container.
Copy link
Contributor

@wking wking Sep 19, 2016

Choose a reason for hiding this comment

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

I'm fine with uint64 here, but am enjoying a mental image of a container that needs 4.3 billion CPUs ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Future proofing :)


* **`count`** *(uint64, optional)* - specifies the number of CPUs available to the container.

* **`shares`** *(uint64, optional)* - specifies the relative weight to other containers with CPU shares. The range is from 1 to 10000.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we know the cap is 10000, we can use a uint16.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed to cpuShares type.

"shares": {
"id": "https://opencontainers.org/schema/bundle/windows/resources/cpu/shares",
"$ref": "defs.json#/definitions/uint64Pointer"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably needs defs-windows.json for CPUShares so we can check the 1–10k range.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, will update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wking - Updated in d73cf3e


The following parameters can be specified:

* **`limit`** *(uint64, optional)* - sets limit of memory usage in bytes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is limit being over-committed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. More information on overall memory management of containers on Windows (which is different between Windows Server and Hyper-V containers) will eventually make it into the documentation on microsoft.com, but for now there's nothing published as such.


* **`shares`** *(uint64, optional)* - specifies the relative weight to other containers with CPU shares. The range is from 1 to 10000.

* **`percent`** *(uint, optional)* - specifies the percentage of available CPUs usable by the container.
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume the CPU object is essentially a union across three parameters?

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 Well yes, but bearing in mind any or all of them are optional.

"cpuSharesPointer": {
"oneOf": [
{
"$ref": "#/definitions/CPUShares"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have much of a preference between cpuShares and CPUShares, but we should pick one and stick to it ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll stick with camelCase. Mea culpa

"cpuShares": {
"description": "Relative weight to other containers with CPU Shares defined",
"type": "integer",
"minimum": 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

The Markdown docs say the minimum is 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And they're right, this is incorrect. Thanks for catching. Updated in 6c66d16

@lowenna lowenna force-pushed the jjh/addwindows branch 2 times, most recently from 6c66d16 to d57e63f Compare September 19, 2016 22:30
@wking
Copy link
Contributor

wking commented Sep 19, 2016 via email


* **`limit`** *(uint64, optional)* - sets limit of memory usage in bytes.

* **`reservation`** *(uint64, optional)* - sets the guaranteed minimum amount of memory for a container in bytes.
Copy link
Contributor

Choose a reason for hiding this comment

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

optional -> OPTIONAL

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make similar changes throughout this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrunalp Yes, of course. Done and pushed.


The following parameters can be specified:

* **`iops`** *(uint64, optional)* - specifies the maximum Iops for the system drive of the container.
Copy link
Contributor

Choose a reason for hiding this comment

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

Iops --> IO operations or iops?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrunalp Updated to IO operations per seconds.

Signed-off-by: John Howard <jhoward@microsoft.com>
@mrunalp
Copy link
Contributor

mrunalp commented Sep 22, 2016

LGTM

Approved with PullApprove

@RobDolinMS
Copy link
Collaborator

@vbatts Would you please give this a look?

@vbatts
Copy link
Member

vbatts commented Sep 26, 2016

Good stuff. Thanks @jhowardmsft

LGTM

Approved with PullApprove

@vbatts vbatts merged commit 1c7c27d into opencontainers:master Sep 26, 2016
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Nov 14, 2016
The shift happened in c35cf57 (config: Replace "optional" with
"OPTIONAL", 2016-09-17, opencontainers#574) and the 'windows' entry landed in
parallel with dc8f2c2 (Add support for Windows-based containers,
2016-09-16, opencontainers#573).

Signed-off-by: W. Trevor King <wking@tremily.us>
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Nov 14, 2016
The shift happened in c35cf57 (config: Replace "optional" with
"OPTIONAL", 2016-09-17, opencontainers#574) and the 'windows' entry landed in
parallel with dc8f2c2 (Add support for Windows-based containers,
2016-09-16, opencontainers#573).

Signed-off-by: W. Trevor King <wking@tremily.us>
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.

6 participants