summaryrefslogtreecommitdiffhomepage
path: root/pkg/v1/proc/init_state.go
diff options
context:
space:
mode:
authorLantao Liu <taotaotheripper@gmail.com>2019-01-30 09:50:10 -0800
committerGitHub <noreply@github.com>2019-01-30 09:50:10 -0800
commit326bc9f3bac1b89414950772ac0cb87619b847d9 (patch)
tree9cb38bf649fa34a61c43cc9eba877d4beb085af2 /pkg/v1/proc/init_state.go
parent35db607dfccd3c03b69f1a42c58cf58ec8259e37 (diff)
Update to containerd 1.2.2 (#14)
* Update containerd to 1.2.2 Signed-off-by: Lantao Liu <lantaol@google.com> * Port https://github.com/containerd/containerd/pull/2803. Signed-off-by: Lantao Liu <lantaol@google.com>
Diffstat (limited to 'pkg/v1/proc/init_state.go')
-rw-r--r--pkg/v1/proc/init_state.go50
1 files changed, 5 insertions, 45 deletions
diff --git a/pkg/v1/proc/init_state.go b/pkg/v1/proc/init_state.go
index e04eadbc3..f56f6fe28 100644
--- a/pkg/v1/proc/init_state.go
+++ b/pkg/v1/proc/init_state.go
@@ -27,9 +27,12 @@ import (
)
type initState interface {
- proc.State
-
+ Resize(console.WinSize) error
+ Start(context.Context) error
+ Delete(context.Context) error
Exec(context.Context, string, *ExecConfig) (proc.Process, error)
+ Kill(context.Context, uint32, bool) error
+ SetExited(int)
}
type createdState struct {
@@ -51,15 +54,10 @@ func (s *createdState) transition(name string) error {
}
func (s *createdState) Resize(ws console.WinSize) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return s.p.resize(ws)
}
func (s *createdState) Start(ctx context.Context) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
if err := s.p.start(ctx); err != nil {
// Containerd doesn't allow deleting container in created state.
// However, for gvisor, a non-root container in created state can
@@ -80,8 +78,6 @@ func (s *createdState) Start(ctx context.Context) error {
}
func (s *createdState) Delete(ctx context.Context) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
if err := s.p.delete(ctx); err != nil {
return err
}
@@ -89,16 +85,10 @@ func (s *createdState) Delete(ctx context.Context) error {
}
func (s *createdState) Kill(ctx context.Context, sig uint32, all bool) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return s.p.kill(ctx, sig, all)
}
func (s *createdState) SetExited(status int) {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
s.p.setExited(status)
if err := s.transition("stopped"); err != nil {
@@ -107,8 +97,6 @@ func (s *createdState) SetExited(status int) {
}
func (s *createdState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
return s.p.exec(ctx, path, r)
}
@@ -127,37 +115,22 @@ func (s *runningState) transition(name string) error {
}
func (s *runningState) Resize(ws console.WinSize) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return s.p.resize(ws)
}
func (s *runningState) Start(ctx context.Context) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return errors.Errorf("cannot start a running process")
}
func (s *runningState) Delete(ctx context.Context) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return errors.Errorf("cannot delete a running process")
}
func (s *runningState) Kill(ctx context.Context, sig uint32, all bool) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return s.p.kill(ctx, sig, all)
}
func (s *runningState) SetExited(status int) {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
s.p.setExited(status)
if err := s.transition("stopped"); err != nil {
@@ -166,8 +139,6 @@ func (s *runningState) SetExited(status int) {
}
func (s *runningState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
return s.p.exec(ctx, path, r)
}
@@ -186,22 +157,14 @@ func (s *stoppedState) transition(name string) error {
}
func (s *stoppedState) Resize(ws console.WinSize) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return errors.Errorf("cannot resize a stopped container")
}
func (s *stoppedState) Start(ctx context.Context) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return errors.Errorf("cannot start a stopped process")
}
func (s *stoppedState) Delete(ctx context.Context) error {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
if err := s.p.delete(ctx); err != nil {
return err
}
@@ -217,8 +180,5 @@ func (s *stoppedState) SetExited(status int) {
}
func (s *stoppedState) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
- s.p.mu.Lock()
- defer s.p.mu.Unlock()
-
return nil, errors.Errorf("cannot exec in a stopped state")
}