Remove unreachable code paths
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
parent
bbaba4c081
commit
b477a159db
|
@ -454,10 +454,7 @@ func (c *linuxContainer) newParentProcess(p *Process) (parentProcess, error) {
|
|||
}
|
||||
logFilePair := filePair{parentLogPipe, childLogPipe}
|
||||
|
||||
cmd, err := c.commandTemplate(p, childInitPipe, childLogPipe)
|
||||
if err != nil {
|
||||
return nil, newSystemErrorWithCause(err, "creating new command template")
|
||||
}
|
||||
cmd := c.commandTemplate(p, childInitPipe, childLogPipe)
|
||||
if !p.Init {
|
||||
return c.newSetnsProcess(p, cmd, messageSockPair, logFilePair)
|
||||
}
|
||||
|
@ -473,7 +470,7 @@ func (c *linuxContainer) newParentProcess(p *Process) (parentProcess, error) {
|
|||
return c.newInitProcess(p, cmd, messageSockPair, logFilePair)
|
||||
}
|
||||
|
||||
func (c *linuxContainer) commandTemplate(p *Process, childInitPipe *os.File, childLogPipe *os.File) (*exec.Cmd, error) {
|
||||
func (c *linuxContainer) commandTemplate(p *Process, childInitPipe *os.File, childLogPipe *os.File) *exec.Cmd {
|
||||
cmd := exec.Command(c.initPath, c.initArgs[1:]...)
|
||||
cmd.Args[0] = c.initArgs[0]
|
||||
cmd.Stdin = p.Stdin
|
||||
|
@ -509,7 +506,7 @@ func (c *linuxContainer) commandTemplate(p *Process, childInitPipe *os.File, chi
|
|||
if c.config.ParentDeathSignal > 0 {
|
||||
cmd.SysProcAttr.Pdeathsig = syscall.Signal(c.config.ParentDeathSignal)
|
||||
}
|
||||
return cmd, nil
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c *linuxContainer) newInitProcess(p *Process, cmd *exec.Cmd, messageSockPair, logFilePair filePair) (*initProcess, error) {
|
||||
|
@ -1778,10 +1775,7 @@ func (c *linuxContainer) refreshState() error {
|
|||
if paused {
|
||||
return c.state.transition(&pausedState{c: c})
|
||||
}
|
||||
t, err := c.runType()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
t := c.runType()
|
||||
switch t {
|
||||
case Created:
|
||||
return c.state.transition(&createdState{c: c})
|
||||
|
@ -1791,24 +1785,24 @@ func (c *linuxContainer) refreshState() error {
|
|||
return c.state.transition(&stoppedState{c: c})
|
||||
}
|
||||
|
||||
func (c *linuxContainer) runType() (Status, error) {
|
||||
func (c *linuxContainer) runType() Status {
|
||||
if c.initProcess == nil {
|
||||
return Stopped, nil
|
||||
return Stopped
|
||||
}
|
||||
pid := c.initProcess.pid()
|
||||
stat, err := system.Stat(pid)
|
||||
if err != nil {
|
||||
return Stopped, nil
|
||||
return Stopped
|
||||
}
|
||||
if stat.StartTime != c.initProcessStartTime || stat.State == system.Zombie || stat.State == system.Dead {
|
||||
return Stopped, nil
|
||||
return Stopped
|
||||
}
|
||||
// We'll create exec fifo and blocking on it after container is created,
|
||||
// and delete it after start container.
|
||||
if _, err := os.Stat(filepath.Join(c.root, execFifoFilename)); err == nil {
|
||||
return Created, nil
|
||||
return Created
|
||||
}
|
||||
return Running, nil
|
||||
return Running
|
||||
}
|
||||
|
||||
func (c *linuxContainer) isPaused() (bool, error) {
|
||||
|
|
|
@ -111,11 +111,7 @@ func (r *runningState) status() Status {
|
|||
func (r *runningState) transition(s containerState) error {
|
||||
switch s.(type) {
|
||||
case *stoppedState:
|
||||
t, err := r.c.runType()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t == Running {
|
||||
if r.c.runType() == Running {
|
||||
return newGenericError(fmt.Errorf("container still running"), ContainerNotStopped)
|
||||
}
|
||||
r.c.state = s
|
||||
|
@ -130,11 +126,7 @@ func (r *runningState) transition(s containerState) error {
|
|||
}
|
||||
|
||||
func (r *runningState) destroy() error {
|
||||
t, err := r.c.runType()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t == Running {
|
||||
if r.c.runType() == Running {
|
||||
return newGenericError(fmt.Errorf("container is not destroyed"), ContainerNotStopped)
|
||||
}
|
||||
return destroy(r.c)
|
||||
|
@ -186,10 +178,7 @@ func (p *pausedState) transition(s containerState) error {
|
|||
}
|
||||
|
||||
func (p *pausedState) destroy() error {
|
||||
t, err := p.c.runType()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
t := p.c.runType()
|
||||
if t != Running && t != Created {
|
||||
if err := p.c.cgroupManager.Freeze(configs.Thawed); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue