Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #218 from miaoyq/fixes-185
Browse files Browse the repository at this point in the history
Update kubernetes version and support mount propagation
  • Loading branch information
Random-Liu authored Sep 7, 2017
2 parents a316d15 + 9da460e commit 3e4b423
Show file tree
Hide file tree
Showing 7 changed files with 451 additions and 271 deletions.
14 changes: 13 additions & 1 deletion pkg/server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,19 @@ func addOCIBindMounts(g *generate.Generator, mounts []*runtime.Mount, mountLabel
for _, mount := range mounts {
dst := mount.GetContainerPath()
src := mount.GetHostPath()
options := []string{"rbind", "rprivate"}
options := []string{"rbind"}
switch mount.GetPropagation() {
case runtime.MountPropagation_PROPAGATION_PRIVATE:
options = append(options, "rprivate")
case runtime.MountPropagation_PROPAGATION_BIDIRECTIONAL:
options = append(options, "rshared")
case runtime.MountPropagation_PROPAGATION_HOST_TO_CONTAINER:
options = append(options, "rslave")
default:
glog.Warningf("Unknown propagation mode for hostPath %q", mount.HostPath)
options = append(options, "rprivate")
}

if mount.GetReadonly() {
options = append(options, "ro")
} else {
Expand Down
38 changes: 38 additions & 0 deletions pkg/server/container_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,48 @@ func getCreateContainerTestData() (*runtime.ContainerConfig, *runtime.PodSandbox
{Key: "k4", Value: "v4=v4bis=foop"},
},
Mounts: []*runtime.Mount{
// everything default
{
ContainerPath: "container-path-1",
HostPath: "host-path-1",
},
// readOnly
{
ContainerPath: "container-path-2",
HostPath: "host-path-2",
Readonly: true,
},
// Propagation private
{
ContainerPath: "container-path-3",
HostPath: "host-path-3",
Propagation: runtime.MountPropagation_PROPAGATION_PRIVATE,
},
// Propagation rslave
{
ContainerPath: "container-path-4",
HostPath: "host-path-4",
Propagation: runtime.MountPropagation_PROPAGATION_HOST_TO_CONTAINER,
},
// Propagation rshared
{
ContainerPath: "container-path-5",
HostPath: "host-path-5",
Propagation: runtime.MountPropagation_PROPAGATION_BIDIRECTIONAL,
},
// Propagation unknown (falls back to private)
{
ContainerPath: "container-path-6",
HostPath: "host-path-6",
Propagation: runtime.MountPropagation(42),
},
// Everything
{
ContainerPath: "container-path-7",
HostPath: "host-path-7",
Readonly: true,
Propagation: runtime.MountPropagation_PROPAGATION_BIDIRECTIONAL,
},
},
Labels: map[string]string{"a": "b"},
Annotations: map[string]string{"c": "d"},
Expand Down Expand Up @@ -124,6 +157,11 @@ func getCreateContainerTestData() (*runtime.ContainerConfig, *runtime.PodSandbox
t.Logf("Check bind mount")
checkMount(t, spec.Mounts, "host-path-1", "container-path-1", "bind", []string{"rbind", "rprivate", "rw"}, nil)
checkMount(t, spec.Mounts, "host-path-2", "container-path-2", "bind", []string{"rbind", "rprivate", "ro"}, nil)
checkMount(t, spec.Mounts, "host-path-3", "container-path-3", "bind", []string{"rbind", "rprivate", "rw"}, nil)
checkMount(t, spec.Mounts, "host-path-4", "container-path-4", "bind", []string{"rbind", "rslave", "rw"}, nil)
checkMount(t, spec.Mounts, "host-path-5", "container-path-5", "bind", []string{"rbind", "rshared", "rw"}, nil)
checkMount(t, spec.Mounts, "host-path-6", "container-path-6", "bind", []string{"rbind", "rprivate", "rw"}, nil)
checkMount(t, spec.Mounts, "host-path-7", "container-path-7", "bind", []string{"rbind", "rshared", "ro"}, nil)

t.Logf("Check resource limits")
assert.EqualValues(t, *spec.Linux.Resources.CPU.Period, 100)
Expand Down
2 changes: 1 addition & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ k8s.io/api f30e293246921de7f4ee46bb65b8762b2f890fc4
k8s.io/apimachinery b166f81f5c4c88402ae23a0d0944c6ad08bffd3b
k8s.io/apiserver b2a8ad67a002d27c8945573abb80b4be543f2a1f
k8s.io/client-go db8228460e2de17f5d3a9a453f61dde0ba86545a
k8s.io/kubernetes 759ba487b33a7566111622e19de607aba45a7342
k8s.io/kubernetes 11a836078d0c78a4253a77a3ff6f4a555c4121f9
k8s.io/utils 1f5ba483856f60b34bb29864d4129a8065d1c83b
k8s.io/kube-openapi 2fbf05e337e56c983d9df1220b9e67cf132a1669
30 changes: 28 additions & 2 deletions vendor/k8s.io/kubernetes/pkg/api/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions vendor/k8s.io/kubernetes/pkg/api/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3e4b423

Please sign in to comment.