summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/go-runsc/utils.go12
-rw-r--r--pkg/v1/shim/service.go4
-rw-r--r--pkg/v1/utils/utils.go9
-rw-r--r--pkg/v2/service.go4
4 files changed, 14 insertions, 15 deletions
diff --git a/pkg/go-runsc/utils.go b/pkg/go-runsc/utils.go
index c78d0c162..e4c3c937a 100644
--- a/pkg/go-runsc/utils.go
+++ b/pkg/go-runsc/utils.go
@@ -39,18 +39,8 @@ func putBuf(b *bytes.Buffer) {
}
// FormatLogPath parses runsc config, and fill in %ID% in the log path.
-// * For debug-log, it fills in the id in place;
-// * For user-log, it fills in the id, returns the user log path, and deletes
-// the `user-log` entry from the config, because it will only be added to runsc
-// calls that create a new sandbox.
-func FormatLogPath(id string, config map[string]string) string {
+func FormatLogPath(id string, config map[string]string) {
if path, ok := config["debug-log"]; ok {
config["debug-log"] = strings.Replace(path, "%ID%", id, -1)
}
- var userLog string
- if path, ok := config["user-log"]; ok {
- userLog = strings.Replace(path, "%ID%", id, -1)
- delete(config, "user-log")
- }
- return userLog
}
diff --git a/pkg/v1/shim/service.go b/pkg/v1/shim/service.go
index e23bf957a..083dfa534 100644
--- a/pkg/v1/shim/service.go
+++ b/pkg/v1/shim/service.go
@@ -551,7 +551,7 @@ func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace string,
if err != nil {
return nil, errors.Wrap(err, "read oci spec")
}
- userLog := runsc.FormatLogPath(r.ID, config)
+ runsc.FormatLogPath(r.ID, config)
rootfs := filepath.Join(path, "rootfs")
runtime := proc.NewRunsc(runtimeRoot, path, namespace, r.Runtime, config)
p := proc.New(r.ID, runtime, rproc.Stdio{
@@ -567,7 +567,7 @@ func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace string,
p.IoUID = int(options.IoUid)
p.IoGID = int(options.IoGid)
p.Sandbox = utils.IsSandbox(spec)
- p.UserLog = userLog
+ p.UserLog = utils.UserLogPath(spec)
p.Monitor = shim.Default
return p, nil
}
diff --git a/pkg/v1/utils/utils.go b/pkg/v1/utils/utils.go
index b89edb064..83840c047 100644
--- a/pkg/v1/utils/utils.go
+++ b/pkg/v1/utils/utils.go
@@ -48,3 +48,12 @@ func IsSandbox(spec *specs.Spec) bool {
t, ok := spec.Annotations[annotations.ContainerType]
return !ok || t == annotations.ContainerTypeSandbox
}
+
+// UserLogPath gets user log path from OCI annotation.
+func UserLogPath(spec *specs.Spec) string {
+ sandboxLogDir := spec.Annotations[annotations.SandboxLogDir]
+ if sandboxLogDir == "" {
+ return ""
+ }
+ return filepath.Join(sandboxLogDir, "gvisor.log")
+}
diff --git a/pkg/v2/service.go b/pkg/v2/service.go
index 0a5054e22..912798e23 100644
--- a/pkg/v2/service.go
+++ b/pkg/v2/service.go
@@ -696,7 +696,7 @@ func newInit(ctx context.Context, path, workDir, namespace string, platform rpro
if err != nil {
return nil, errors.Wrap(err, "read oci spec")
}
- userLog := runsc.FormatLogPath(r.ID, options.RunscConfig)
+ runsc.FormatLogPath(r.ID, options.RunscConfig)
rootfs := filepath.Join(path, "rootfs")
runtime := proc.NewRunsc(options.Root, path, namespace, options.BinaryName, options.RunscConfig)
p := proc.New(r.ID, runtime, rproc.Stdio{
@@ -712,7 +712,7 @@ func newInit(ctx context.Context, path, workDir, namespace string, platform rpro
p.IoUID = int(options.IoUid)
p.IoGID = int(options.IoGid)
p.Sandbox = utils.IsSandbox(spec)
- p.UserLog = userLog
+ p.UserLog = utils.UserLogPath(spec)
p.Monitor = shim.Default
return p, nil
}