diff options
Diffstat (limited to 'libpod/pod_api.go')
-rw-r--r-- | libpod/pod_api.go | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/libpod/pod_api.go b/libpod/pod_api.go index b913857dd..c7b0353bd 100644 --- a/libpod/pod_api.go +++ b/libpod/pod_api.go @@ -3,6 +3,7 @@ package libpod import ( "context" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/events" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -27,7 +28,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) { defer p.lock.Unlock() if !p.valid { - return nil, ErrPodRemoved + return nil, define.ErrPodRemoved } allCtrs, err := p.runtime.state.PodContainers(p) @@ -47,7 +48,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) { // If there are no containers without dependencies, we can't start // Error out if len(graph.noDepNodes) == 0 { - return nil, errors.Wrapf(ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID()) + return nil, errors.Wrapf(define.ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID()) } // Traverse the graph beginning at nodes with no dependencies @@ -56,7 +57,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, errors.Wrapf(ErrCtrExists, "error starting some containers") + return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error starting some containers") } defer p.newPodEvent(events.Start) return nil, nil @@ -88,7 +89,7 @@ func (p *Pod) StopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m defer p.lock.Unlock() if !p.valid { - return nil, ErrPodRemoved + return nil, define.ErrPodRemoved } allCtrs, err := p.runtime.state.PodContainers(p) @@ -112,7 +113,7 @@ func (p *Pod) StopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m } // Ignore containers that are not running - if ctr.state.State != ContainerStateRunning { + if ctr.state.State != define.ContainerStateRunning { ctr.lock.Unlock() continue } @@ -136,7 +137,7 @@ func (p *Pod) StopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m } if len(ctrErrors) > 0 { - return ctrErrors, errors.Wrapf(ErrCtrExists, "error stopping some containers") + return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error stopping some containers") } defer p.newPodEvent(events.Stop) return nil, nil @@ -159,7 +160,7 @@ func (p *Pod) Pause() (map[string]error, error) { defer p.lock.Unlock() if !p.valid { - return nil, ErrPodRemoved + return nil, define.ErrPodRemoved } allCtrs, err := p.runtime.state.PodContainers(p) @@ -180,7 +181,7 @@ func (p *Pod) Pause() (map[string]error, error) { } // Ignore containers that are not running - if ctr.state.State != ContainerStateRunning { + if ctr.state.State != define.ContainerStateRunning { ctr.lock.Unlock() continue } @@ -195,7 +196,7 @@ func (p *Pod) Pause() (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, errors.Wrapf(ErrCtrExists, "error pausing some containers") + return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error pausing some containers") } defer p.newPodEvent(events.Pause) return nil, nil @@ -218,7 +219,7 @@ func (p *Pod) Unpause() (map[string]error, error) { defer p.lock.Unlock() if !p.valid { - return nil, ErrPodRemoved + return nil, define.ErrPodRemoved } allCtrs, err := p.runtime.state.PodContainers(p) @@ -239,7 +240,7 @@ func (p *Pod) Unpause() (map[string]error, error) { } // Ignore containers that are not paused - if ctr.state.State != ContainerStatePaused { + if ctr.state.State != define.ContainerStatePaused { ctr.lock.Unlock() continue } @@ -254,7 +255,7 @@ func (p *Pod) Unpause() (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, errors.Wrapf(ErrCtrExists, "error unpausing some containers") + return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error unpausing some containers") } defer p.newPodEvent(events.Unpause) @@ -279,7 +280,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) { defer p.lock.Unlock() if !p.valid { - return nil, ErrPodRemoved + return nil, define.ErrPodRemoved } allCtrs, err := p.runtime.state.PodContainers(p) @@ -299,7 +300,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) { // If there are no containers without dependencies, we can't start // Error out if len(graph.noDepNodes) == 0 { - return nil, errors.Wrapf(ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID()) + return nil, errors.Wrapf(define.ErrNoSuchCtr, "no containers in pod %s have no dependencies, cannot start pod", p.ID()) } // Traverse the graph beginning at nodes with no dependencies @@ -308,7 +309,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, errors.Wrapf(ErrCtrExists, "error stopping some containers") + return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error stopping some containers") } p.newPodEvent(events.Stop) p.newPodEvent(events.Start) @@ -331,7 +332,7 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) { defer p.lock.Unlock() if !p.valid { - return nil, ErrPodRemoved + return nil, define.ErrPodRemoved } allCtrs, err := p.runtime.state.PodContainers(p) @@ -352,7 +353,7 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) { } // Ignore containers that are not running - if ctr.state.State != ContainerStateRunning { + if ctr.state.State != define.ContainerStateRunning { ctr.lock.Unlock() continue } @@ -374,7 +375,7 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, errors.Wrapf(ErrCtrExists, "error killing some containers") + return ctrErrors, errors.Wrapf(define.ErrCtrExists, "error killing some containers") } defer p.newPodEvent(events.Kill) return nil, nil @@ -382,12 +383,12 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) { // Status gets the status of all containers in the pod // Returns a map of Container ID to Container Status -func (p *Pod) Status() (map[string]ContainerStatus, error) { +func (p *Pod) Status() (map[string]define.ContainerStatus, error) { p.lock.Lock() defer p.lock.Unlock() if !p.valid { - return nil, ErrPodRemoved + return nil, define.ErrPodRemoved } allCtrs, err := p.runtime.state.PodContainers(p) @@ -402,7 +403,7 @@ func (p *Pod) Status() (map[string]ContainerStatus, error) { } // Now that all containers are locked, get their status - status := make(map[string]ContainerStatus, len(allCtrs)) + status := make(map[string]define.ContainerStatus, len(allCtrs)) for _, ctr := range allCtrs { if err := ctr.syncContainer(); err != nil { return nil, err |