Skip to content

Commit

Permalink
virtcontainers: reimplement sandbox cgroup
Browse files Browse the repository at this point in the history
All containers run in different cgroups even the sandbox, with this new
implementation the sandbox cpu cgroup wil be equal to the sum of all its
containers and the hypervisor process will be placed there impacting to the
containers running in the sandbox (VM). The default number of vcpus is
used when the sandbox has no constraints. For example, if default_vcpus
is 2, then quota will be 200000 and period 100000.

**c-ray test**
http://www.futuretech.blinkenlights.nl/c-ray.html

```
+=============================================+
|         | 6 threads 6cpus | 1 thread 1 cpu  |
+=============================================+
| current |   40 seconds    |   122 seconds   |
+==============================================
|   new   |   37 seconds    |   124 seconds   |
+==============================================
```

current = current cgroups implementation
new = new cgroups implementation

**workload**

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: c-ray
  annotations:
    io.kubernetes.cri.untrusted-workload: "true"
spec:
  restartPolicy: Never
  containers:
  - name: c-ray-1
    image: docker.io/devimc/c-ray:latest
    imagePullPolicy: IfNotPresent
    args: ["-t", "6", "-s", "1600x1200", "-r", "8", "-i",
          "/c-ray-1.1/sphfract", "-o", "/tmp/output.ppm"]
    resources:
      limits:
        cpu: 6
  - name: c-ray-2
    image: docker.io/devimc/c-ray:latest
    imagePullPolicy: IfNotPresent
    args: ["-t", "1", "-s", "1600x1200", "-r", "8", "-i",
          "/c-ray-1.1/sphfract", "-o", "/tmp/output.ppm"]
    resources:
      limits:
        cpu: 1
```

fixes kata-containers#1153

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Feb 13, 2019
1 parent c797974 commit a58d076
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 330 deletions.
5 changes: 0 additions & 5 deletions virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
return nil, err
}

// Setup host cgroups
if err = s.setupCgroups(); err != nil {
return nil, err
}

return s, nil
}

Expand Down
11 changes: 7 additions & 4 deletions virtcontainers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"testing"

"github.com/containernetworking/plugins/pkg/ns"
"github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
"github.com/kata-containers/runtime/virtcontainers/store"
Expand All @@ -31,13 +32,15 @@ const (
)

var sandboxAnnotations = map[string]string{
"sandbox.foo": "sandbox.bar",
"sandbox.hello": "sandbox.world",
"sandbox.foo": "sandbox.bar",
"sandbox.hello": "sandbox.world",
annotations.ConfigJSONKey: `{"linux":{"resources":{}}}`,
}

var containerAnnotations = map[string]string{
"container.foo": "container.bar",
"container.hello": "container.world",
"container.foo": "container.bar",
"container.hello": "container.world",
annotations.ConfigJSONKey: `{"linux":{"resources":{}}}`,
}

func newBasicTestCmd() types.Cmd {
Expand Down

0 comments on commit a58d076

Please sign in to comment.