summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-10-31 13:03:08 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-10-31 14:24:41 +0100
commitdc3e3af25613700bce3a8e2b2ce3e3f978ca0e9f (patch)
tree0f145076bdb5123cdd843dcf6e4d34c4fe5f4b72 /pkg/adapter/containers.go
parent381fa4df875af3d2acee34d4fc1a608b2218b551 (diff)
downloadpodman-dc3e3af25613700bce3a8e2b2ce3e3f978ca0e9f.tar.gz
podman-dc3e3af25613700bce3a8e2b2ce3e3f978ca0e9f.tar.bz2
podman-dc3e3af25613700bce3a8e2b2ce3e3f978ca0e9f.zip
container start: fix regression when using name
When starting a container by using its name as a reference, we should print the name instead of the ID. We regressed on this behaviour with commit b4124485ae7e which made it into Podman v1.6.2. Kudos to openSUSE testing for catching it. To prevent future regressions, extend the e2e tests to check the printed container name/ID. Reported-by: @sysrich Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r--pkg/adapter/containers.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 430b6925d..207cf5c64 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -656,20 +656,25 @@ func (r *LocalRuntime) Start(ctx context.Context, c *cliconfig.StartValues, sigP
return exitCode, nil
}
- if ctrRunning {
- fmt.Println(ctr.ID())
- continue
- }
- // Handle non-attach start
- // If the container is in a pod, also set to recursively start dependencies
- if err := ctr.Start(ctx, ctr.PodID() != ""); err != nil {
- if lastError != nil {
- fmt.Fprintln(os.Stderr, lastError)
+ // Start the container if it's not running already.
+ if !ctrRunning {
+ // Handle non-attach start
+ // If the container is in a pod, also set to recursively start dependencies
+ if err := ctr.Start(ctx, ctr.PodID() != ""); err != nil {
+ if lastError != nil {
+ fmt.Fprintln(os.Stderr, lastError)
+ }
+ lastError = errors.Wrapf(err, "unable to start container %q", container)
+ continue
}
- lastError = errors.Wrapf(err, "unable to start container %q", container)
- continue
}
- fmt.Println(ctr.ID())
+ // Check if the container is referenced by ID or by name and print
+ // it accordingly.
+ if strings.HasPrefix(ctr.ID(), container) {
+ fmt.Println(ctr.ID())
+ } else {
+ fmt.Println(container)
+ }
}
return exitCode, lastError
}