getExecConfig looks up the exec instance by name. If the container associated with the exec instance is stopped or paused, it will return an error.
(name string)
| 43 | // getExecConfig looks up the exec instance by name. If the container associated |
| 44 | // with the exec instance is stopped or paused, it will return an error. |
| 45 | func (daemon *Daemon) getExecConfig(name string) (*container.ExecConfig, error) { |
| 46 | ec := daemon.execCommands.Get(name) |
| 47 | if ec == nil { |
| 48 | return nil, errExecNotFound(name) |
| 49 | } |
| 50 | |
| 51 | // If the exec is found but its container is not in the daemon's list of |
| 52 | // containers then it must have been deleted, in which case instead of |
| 53 | // saying the container isn't running, we should return a 404 so that |
| 54 | // the user sees the same error now that they will after the |
| 55 | // 5 minute clean-up loop is run which erases old/dead execs. |
| 56 | ctr := daemon.containers.Get(ec.Container.ID) |
| 57 | if ctr == nil { |
| 58 | return nil, containerNotFound(name) |
| 59 | } |
| 60 | if !ctr.State.IsRunning() { |
| 61 | return nil, errNotRunning(ctr.ID) |
| 62 | } |
| 63 | if ctr.State.IsPaused() { |
| 64 | return nil, errExecPaused(ctr.ID) |
| 65 | } |
| 66 | if ctr.State.IsRestarting() { |
| 67 | return nil, errContainerIsRestarting(ctr.ID) |
| 68 | } |
| 69 | return ec, nil |
| 70 | } |
| 71 | |
| 72 | func (daemon *Daemon) unregisterExecCommand(container *container.Container, execConfig *container.ExecConfig) { |
| 73 | container.ExecCommands.Delete(execConfig.ID) |
no test coverage detected