Skip to content

Commit

Permalink
Merge pull request #2342 from simonferquel/swarm-service-isolation
Browse files Browse the repository at this point in the history
[Windows]  Support for isolation mode on container spec
  • Loading branch information
nishanttotla committed Oct 6, 2017
2 parents b38eda1 + 7d10d60 commit a05f661
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 127 deletions.
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

0 comments on commit a05f661

Please sign in to comment.