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

[Windows] Support for isolation mode on container spec #2342

Merged
merged 2 commits into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions agent/exec/dockerapi/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ func (c *containerConfig) portBindings() nat.PortMap {
return portBindings
}

func (c *containerConfig) isolation() enginecontainer.Isolation {
switch c.spec().Isolation {
case api.ContainerIsolationDefault:
return enginecontainer.Isolation("default")
case api.ContainerIsolationHyperV:
return enginecontainer.Isolation("hyperv")
case api.ContainerIsolationProcess:
return enginecontainer.Isolation("process")
}
return enginecontainer.Isolation("")
}

func (c *containerConfig) exposedPorts() map[nat.Port]struct{} {
exposedPorts := make(map[nat.Port]struct{})
if c.task.Endpoint == nil {
Expand Down Expand Up @@ -196,6 +208,7 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
GroupAdd: c.spec().Groups,
PortBindings: c.portBindings(),
Init: c.init(),
Isolation: c.isolation(),
}

// The format of extra hosts on swarmkit is specified in:
Expand Down
20 changes: 20 additions & 0 deletions agent/exec/dockerapi/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,23 @@ func TestInit(t *testing.T) {
t.Fatalf("expected &true, got %v", actual)
}
}

func TestIsolation(t *testing.T) {
c := containerConfig{
task: &api.Task{
Spec: api.TaskSpec{
Runtime: &api.TaskSpec_Container{
Container: &api.ContainerSpec{
Isolation: api.ContainerIsolationHyperV,
},
},
},
},
}

expected := "hyperv"
actual := string(c.hostConfig().Isolation)
if actual != expected {
t.Fatalf("expected %s, got %s", expected, actual)
}
}
50 changes: 50 additions & 0 deletions api/api.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,13 @@ file {
type: TYPE_STRING
json_name: "swiftPrefix"
}
field {
name: "php_class_prefix"
number: 40
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "phpClassPrefix"
}
field {
name: "uninterpreted_option"
number: 999
Expand Down Expand Up @@ -791,6 +798,10 @@ file {
start: 8
end: 9
}
reserved_range {
start: 9
end: 10
}
}
message_type {
name: "FieldOptions"
Expand Down Expand Up @@ -934,6 +945,10 @@ file {
start: 1000
end: 536870912
}
reserved_range {
start: 5
end: 6
}
}
message_type {
name: "EnumValueOptions"
Expand Down Expand Up @@ -4728,6 +4743,14 @@ file {
type_name: ".docker.swarmkit.v1.HealthConfig"
json_name: "healthcheck"
}
field {
name: "isolation"
number: 24
label: LABEL_OPTIONAL
type: TYPE_ENUM
type_name: ".docker.swarmkit.v1.ContainerSpec.Isolation"
json_name: "isolation"
}
nested_type {
name: "LabelsEntry"
field {
Expand Down Expand Up @@ -4782,6 +4805,33 @@ file {
json_name: "options"
}
}
enum_type {
name: "Isolation"
value {
name: "ISOLATION_DEFAULT"
number: 0
options {
66001: "ContainerIsolationDefault"
}
}
value {
name: "ISOLATION_PROCESS"
number: 1
options {
66001: "ContainerIsolationProcess"
}
}
value {
name: "ISOLATION_HYPERV"
number: 2
options {
66001: "ContainerIsolationHyperV"
}
}
options {
62001: 0
}
}
}
message_type {
name: "EndpointSpec"
Expand Down
Loading