mirror of
https://github.com/containerd/containerd.git
synced 2026-08-09 01:21:15 +00:00
Merge pull request #13661 from akerouanton/default-unix-spec
oci: use path.Join to fill CgroupsPath
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"path"
|
||||
"runtime"
|
||||
|
||||
"github.com/opencontainers/go-digest"
|
||||
@@ -206,7 +206,7 @@ func populateDefaultUnixSpec(ctx context.Context, s *Spec, id string) error {
|
||||
"/proc/sys",
|
||||
"/proc/sysrq-trigger",
|
||||
},
|
||||
CgroupsPath: filepath.Join("/", ns, id),
|
||||
CgroupsPath: path.Join("/", ns, id),
|
||||
Resources: &specs.LinuxResources{
|
||||
Devices: []specs.LinuxDeviceCgroup{
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/containerd/v2/core/containers"
|
||||
@@ -253,6 +254,12 @@ func TestPopulateDefaultUnixSpec(t *testing.T) {
|
||||
if expected.Linux == nil {
|
||||
t.Error("Cannot populate Unix Spec")
|
||||
}
|
||||
|
||||
// CgroupsPath should never contain backslashes when the spec is generated
|
||||
// on Windows.
|
||||
if strings.Contains(expected.Linux.CgroupsPath, "\\") {
|
||||
t.Errorf("CgroupsPath contains backslashes: %s", expected.Linux.CgroupsPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithPrivileged(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user