Merge pull request #233 from Random-Liu/remove-run-mount
Remove `/run` mount for backward compatibility with docker.
This commit is contained in:
commit
9558ff2001
@ -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,
|
func (c *criContainerdService) generateContainerSpec(id string, sandboxPid uint32, config *runtime.ContainerConfig,
|
||||||
sandboxConfig *runtime.PodSandboxConfig, imageConfig *imagespec.ImageConfig, extraMounts []*runtime.Mount) (*runtimespec.Spec, error) {
|
sandboxConfig *runtime.PodSandboxConfig, imageConfig *imagespec.ImageConfig, extraMounts []*runtime.Mount) (*runtimespec.Spec, error) {
|
||||||
// Creates a spec Generator with the default spec.
|
// Creates a spec Generator with the default spec.
|
||||||
spec, err := containerd.GenerateSpec(context.Background(), nil, nil)
|
spec, err := defaultRuntimeSpec()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -609,3 +609,23 @@ func setOCINamespaces(g *generate.Generator, namespaces *runtime.NamespaceOption
|
|||||||
g.RemoveLinuxNamespace(string(runtimespec.PIDNamespace)) // nolint: errcheck
|
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
|
||||||
|
}
|
||||||
|
@ -555,3 +555,11 @@ func TestPidNamespace(t *testing.T) {
|
|||||||
Type: runtimespec.PIDNamespace,
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -212,7 +212,7 @@ func (c *criContainerdService) generateSandboxContainerSpec(id string, config *r
|
|||||||
imageConfig *imagespec.ImageConfig, nsPath string) (*runtimespec.Spec, error) {
|
imageConfig *imagespec.ImageConfig, nsPath string) (*runtimespec.Spec, error) {
|
||||||
// Creates a spec Generator with the default spec.
|
// Creates a spec Generator with the default spec.
|
||||||
// TODO(random-liu): [P1] Compare the default settings with docker and containerd default.
|
// 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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user