diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-11-13 03:14:41 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-13 03:14:41 +0000 |
commit | cba40228f795bbfa55c0137cd54e1623be522a65 (patch) | |
tree | 5c21a792e766294a9be4886184463628bc599ad8 /pkg/shim/v1 | |
parent | 77f5e9c854ade3ac6c0b602ed338800f61bd6184 (diff) | |
parent | cf47c8b4a5d22f317cb88ee1c11b5c695c508d1f (diff) |
Merge release-20201030.0-81-gcf47c8b4a (automated)
Diffstat (limited to 'pkg/shim/v1')
-rw-r--r-- | pkg/shim/v1/proc/init.go | 2 | ||||
-rw-r--r-- | pkg/shim/v1/proc/init_state.go | 4 | ||||
-rw-r--r-- | pkg/shim/v1/proc/types.go | 1 | ||||
-rw-r--r-- | pkg/shim/v1/proc/utils.go | 18 | ||||
-rw-r--r-- | pkg/shim/v1/shim/service.go | 19 |
5 files changed, 12 insertions, 32 deletions
diff --git a/pkg/shim/v1/proc/init.go b/pkg/shim/v1/proc/init.go index dab3123d6..9fd7d978c 100644 --- a/pkg/shim/v1/proc/init.go +++ b/pkg/shim/v1/proc/init.go @@ -397,7 +397,7 @@ func (p *Init) Exec(ctx context.Context, path string, r *ExecConfig) (process.Pr } // exec returns a new exec'd process. -func (p *Init) exec(ctx context.Context, path string, r *ExecConfig) (process.Process, error) { +func (p *Init) exec(path string, r *ExecConfig) (process.Process, error) { // process exec request var spec specs.Process if err := json.Unmarshal(r.Spec.Value, &spec); err != nil { diff --git a/pkg/shim/v1/proc/init_state.go b/pkg/shim/v1/proc/init_state.go index 9233ecc85..0065fc385 100644 --- a/pkg/shim/v1/proc/init_state.go +++ b/pkg/shim/v1/proc/init_state.go @@ -95,7 +95,7 @@ func (s *createdState) SetExited(status int) { } func (s *createdState) Exec(ctx context.Context, path string, r *ExecConfig) (process.Process, error) { - return s.p.exec(ctx, path, r) + return s.p.exec(path, r) } type runningState struct { @@ -137,7 +137,7 @@ func (s *runningState) SetExited(status int) { } func (s *runningState) Exec(ctx context.Context, path string, r *ExecConfig) (process.Process, error) { - return s.p.exec(ctx, path, r) + return s.p.exec(path, r) } type stoppedState struct { diff --git a/pkg/shim/v1/proc/types.go b/pkg/shim/v1/proc/types.go index 2b0df4663..fc182cf5e 100644 --- a/pkg/shim/v1/proc/types.go +++ b/pkg/shim/v1/proc/types.go @@ -40,7 +40,6 @@ type CreateConfig struct { Stdin string Stdout string Stderr string - Options *types.Any } // ExecConfig holds exec creation configuration. diff --git a/pkg/shim/v1/proc/utils.go b/pkg/shim/v1/proc/utils.go index 716de2f59..7c2c409af 100644 --- a/pkg/shim/v1/proc/utils.go +++ b/pkg/shim/v1/proc/utils.go @@ -67,24 +67,6 @@ func getLastRuntimeError(r *runsc.Runsc) (string, error) { return errMsg, nil } -func copyFile(to, from string) error { - ff, err := os.Open(from) - if err != nil { - return err - } - defer ff.Close() - tt, err := os.Create(to) - if err != nil { - return err - } - defer tt.Close() - - p := bufPool.Get().(*[]byte) - defer bufPool.Put(p) - _, err = io.CopyBuffer(tt, ff, *p) - return err -} - func hasNoIO(r *CreateConfig) bool { return r.Stdin == "" && r.Stdout == "" && r.Stderr == "" } diff --git a/pkg/shim/v1/shim/service.go b/pkg/shim/v1/shim/service.go index 84a810cb2..80aa59b33 100644 --- a/pkg/shim/v1/shim/service.go +++ b/pkg/shim/v1/shim/service.go @@ -130,7 +130,6 @@ func (s *Service) Create(ctx context.Context, r *shim.CreateTaskRequest) (_ *shi Stdin: r.Stdin, Stdout: r.Stdout, Stderr: r.Stderr, - Options: r.Options, } defer func() { if err != nil { @@ -150,7 +149,6 @@ func (s *Service) Create(ctx context.Context, r *shim.CreateTaskRequest) (_ *shi } } process, err := newInit( - ctx, s.config.Path, s.config.WorkDir, s.config.RuntimeRoot, @@ -158,6 +156,7 @@ func (s *Service) Create(ctx context.Context, r *shim.CreateTaskRequest) (_ *shi s.config.RunscConfig, s.platform, config, + r.Options, ) if err := process.Create(ctx, config); err != nil { return nil, errdefs.ToGRPC(err) @@ -533,14 +532,14 @@ func getTopic(ctx context.Context, e interface{}) string { return runtime.TaskUnknownTopic } -func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace string, config map[string]string, platform stdio.Platform, r *proc.CreateConfig) (*proc.Init, error) { - var options runctypes.CreateOptions - if r.Options != nil { - v, err := typeurl.UnmarshalAny(r.Options) +func newInit(path, workDir, runtimeRoot, namespace string, config map[string]string, platform stdio.Platform, r *proc.CreateConfig, options *types.Any) (*proc.Init, error) { + var opts runctypes.CreateOptions + if options != nil { + v, err := typeurl.UnmarshalAny(options) if err != nil { return nil, err } - options = *v.(*runctypes.CreateOptions) + opts = *v.(*runctypes.CreateOptions) } spec, err := utils.ReadSpec(r.Bundle) @@ -551,7 +550,7 @@ func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace string, return nil, fmt.Errorf("update volume annotations: %w", err) } - runsc.FormatLogPath(r.ID, config) + runsc.FormatRunscLogPath(r.ID, config) rootfs := filepath.Join(path, "rootfs") runtime := proc.NewRunsc(runtimeRoot, path, namespace, r.Runtime, config) p := proc.New(r.ID, runtime, stdio.Stdio{ @@ -564,8 +563,8 @@ func newInit(ctx context.Context, path, workDir, runtimeRoot, namespace string, p.Platform = platform p.Rootfs = rootfs p.WorkDir = workDir - p.IoUID = int(options.IoUid) - p.IoGID = int(options.IoGid) + p.IoUID = int(opts.IoUid) + p.IoGID = int(opts.IoGid) p.Sandbox = utils.IsSandbox(spec) p.UserLog = utils.UserLogPath(spec) p.Monitor = reaper.Default |