aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-22 09:38:50 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-22 14:49:36 +0000
commit7a7a6c2d79ebd831acf0321643903136dca7c2cb (patch)
treedaa56af2d043b0c0d30b1d8ec847f3059bfc7a1c /libpod
parentcef3979203ffe6291f9a4d9cac7c0a69566280d0 (diff)
downloadpodman-7a7a6c2d79ebd831acf0321643903136dca7c2cb.tar.gz
podman-7a7a6c2d79ebd831acf0321643903136dca7c2cb.tar.bz2
podman-7a7a6c2d79ebd831acf0321643903136dca7c2cb.zip
Remove unnecessary booleans
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #361 Approved by: rhatdan
Diffstat (limited to 'libpod')
-rw-r--r--libpod/pod.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/libpod/pod.go b/libpod/pod.go
index a2d2204b3..a5b05d090 100644
--- a/libpod/pod.go
+++ b/libpod/pod.go
@@ -107,7 +107,6 @@ func (p *Pod) Start() (map[string]error, error) {
}
}
- errorEncountered := false
ctrErrors := make(map[string]error)
// Start all containers
@@ -119,13 +118,11 @@ func (p *Pod) Start() (map[string]error, error) {
// TODO remove this when we patch conmon to support restarting containers
if ctr.state.State == ContainerStateStopped {
- errorEncountered = true
ctrErrors[ctr.ID()] = errors.Wrapf(ErrNotImplemented, "starting stopped containers is not yet supported")
continue
}
if err := ctr.runtime.ociRuntime.startContainer(ctr); err != nil {
- errorEncountered = true
ctrErrors[ctr.ID()] = err
continue
}
@@ -136,12 +133,11 @@ func (p *Pod) Start() (map[string]error, error) {
ctr.state.State = ContainerStateRunning
if err := ctr.save(); err != nil {
- errorEncountered = true
ctrErrors[ctr.ID()] = err
}
}
- if errorEncountered {
+ if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error starting some containers")
}
@@ -184,7 +180,6 @@ func (p *Pod) Stop() (map[string]error, error) {
}
}
- errorEncountered := false
ctrErrors := make(map[string]error)
// Stop to all containers
@@ -195,7 +190,6 @@ func (p *Pod) Stop() (map[string]error, error) {
}
if err := ctr.runtime.ociRuntime.stopContainer(ctr, ctr.config.StopTimeout); err != nil {
- errorEncountered = true
ctrErrors[ctr.ID()] = err
continue
}
@@ -204,19 +198,17 @@ func (p *Pod) Stop() (map[string]error, error) {
// Sync container state to pick up return code
if err := ctr.runtime.ociRuntime.updateContainerStatus(ctr); err != nil {
- errorEncountered = true
ctrErrors[ctr.ID()] = err
continue
}
// Clean up storage to ensure we don't leave dangling mounts
if err := ctr.cleanupStorage(); err != nil {
- errorEncountered = true
ctrErrors[ctr.ID()] = err
}
}
- if errorEncountered {
+ if len(ctrErrors) > 0 {
return ctrErrors, errors.Wrapf(ErrCtrExists, "error stopping some containers")
}
@@ -258,7 +250,6 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) {
}
ctrErrors := make(map[string]error)
- errorEncountered := false
// Send a signal to all containers
for _, ctr := range allCtrs {
@@ -268,7 +259,6 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) {
}
if err := ctr.runtime.ociRuntime.killContainer(ctr, signal); err != nil {
- errorEncountered = true
ctrErrors[ctr.ID()] = err
continue
}
@@ -276,7 +266,7 @@ func (p *Pod) Kill(signal uint) (map[string]error, error) {
logrus.Debugf("Killed container %s with signal %d", ctr.ID(), signal)
}
- if errorEncountered {
+ if len(ctrErrors) > 0 {
return ctrErrors, nil
}