Remove /run mount for backward compatibility with docker.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu 2017-09-09 07:34:00 +00:00
parent 159fa903cf
commit 0bfcdd39ab
3 changed files with 30 additions and 2 deletions

View File

@ -233,7 +233,7 @@ func (c *criContainerdService) CreateContainer(ctx context.Context, r *runtime.C
func (c *criContainerdService) generateContainerSpec(id string, sandboxPid uint32, config *runtime.ContainerConfig,
sandboxConfig *runtime.PodSandboxConfig, imageConfig *imagespec.ImageConfig, extraMounts []*runtime.Mount) (*runtimespec.Spec, error) {
// Creates a spec Generator with the default spec.
spec, err := containerd.GenerateSpec(context.Background(), nil, nil)
spec, err := defaultRuntimeSpec()
if err != nil {
return nil, err
}
@ -609,3 +609,23 @@ func setOCINamespaces(g *generate.Generator, namespaces *runtime.NamespaceOption
g.RemoveLinuxNamespace(string(runtimespec.PIDNamespace)) // nolint: errcheck
}
}
// defaultRuntimeSpec returns a default runtime spec used in cri-containerd.
func defaultRuntimeSpec() (*runtimespec.Spec, error) {
spec, err := containerd.GenerateSpec(context.Background(), nil, nil)
if err != nil {
return nil, err
}
// Remove `/run` mount
// TODO(random-liu): Mount tmpfs for /run and handle copy-up.
var mounts []runtimespec.Mount
for _, mount := range spec.Mounts {
if mount.Destination == "/run" {
continue
}
mounts = append(mounts, mount)
}
spec.Mounts = mounts
return spec, nil
}

View File

@ -555,3 +555,11 @@ func TestPidNamespace(t *testing.T) {
Type: runtimespec.PIDNamespace,
})
}
func TestDefaultRuntimeSpec(t *testing.T) {
spec, err := defaultRuntimeSpec()
assert.NoError(t, err)
for _, mount := range spec.Mounts {
assert.NotEqual(t, "/run", mount.Destination)
}
}

View File

@ -212,7 +212,7 @@ func (c *criContainerdService) generateSandboxContainerSpec(id string, config *r
imageConfig *imagespec.ImageConfig, nsPath string) (*runtimespec.Spec, error) {
// Creates a spec Generator with the default spec.
// TODO(random-liu): [P1] Compare the default settings with docker and containerd default.
spec, err := containerd.GenerateSpec(context.Background(), nil, nil)
spec, err := defaultRuntimeSpec()
if err != nil {
return nil, err
}