Adds Windows resource limits support

This will allow running Windows Containers to have their resource
limits updated through containerd. The CPU resource limits support
has been added for Windows Server 20H2 and newer, on older versions
hcsshim will raise an Unimplemented error.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu
2021-07-21 19:41:59 -07:00
parent 5b29542cbe
commit 2bc77b8a28
10 changed files with 233 additions and 159 deletions

View File

@@ -111,12 +111,15 @@ func TestTruncIndex(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, cn, cStats.Attributes.Id)
t.Logf("Update container memory limit after started")
if goruntime.GOOS != "windows" {
// TODO(claudiub): remove this when UpdateContainerResources works on running Windows Containers.
// https://github.com/containerd/containerd/issues/5187
t.Logf("Update container memory limit after started")
err = runtimeService.UpdateContainerResources(cnTruncIndex, &runtimeapi.LinuxContainerResources{
MemoryLimitInBytes: 50 * 1024 * 1024,
}, nil)
assert.NoError(t, err)
} else {
err = runtimeService.UpdateContainerResources(cnTruncIndex, nil, &runtimeapi.WindowsContainerResources{
MemoryLimitInBytes: 50 * 1024 * 1024,
})
assert.NoError(t, err)
}