Skip to content

Commit 0c2e37e

Browse files
committed
validation/util/container: Use a local UUID for stdout/stderr
So validation/create.t gives: ok 4 - create MUST generate an error if the ID provided is not unique --- { "error": "exit status 1", "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/runtime.md#create", "stderr": "container with id exists: 4a142dd0-e5bc-48b3-9abd-49c1a8f7c498\n" } ... instead of: ok 4 - create MUST generate an error if the ID provided is not unique --- { "error": "open /tmp/ocitest842577116/stdout-178f8311-9cc7-42c5-b91e-abbe29eaf582: file exists", "reference": "https://github.com/opencontainers/runtime-spec/blob/v1.0.0/runtime.md#create" } ... The old code hit the internal error, while the new code is checking for a runtime error. Signed-off-by: W. Trevor King <[email protected]>
1 parent a12de42 commit 0c2e37e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

validation/util/container.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
rspecs "github.com/opencontainers/runtime-spec/specs-go"
1414
"github.com/opencontainers/runtime-tools/generate"
15+
"github.com/satori/go.uuid"
1516
)
1617

1718
// Runtime represents the basic requirement of a container runtime
@@ -63,12 +64,13 @@ func (r *Runtime) Create() (stderr []byte, err error) {
6364
// }
6465
cmd := exec.Command(r.RuntimeCommand, args...)
6566
cmd.Dir = r.BundleDir
66-
r.stdout, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stdout-%s", r.ID)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
67+
id := uuid.NewV4().String()
68+
r.stdout, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stdout-%s", id)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
6769
if err != nil {
6870
return []byte(""), err
6971
}
7072
cmd.Stdout = r.stdout
71-
r.stderr, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stderr-%s", r.ID)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
73+
r.stderr, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stderr-%s", id)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
7274
if err != nil {
7375
return []byte(""), err
7476
}

0 commit comments

Comments
 (0)