summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/containers/rm.go7
-rw-r--r--pkg/domain/infra/abi/containers.go24
-rw-r--r--pkg/domain/infra/tunnel/containers.go16
3 files changed, 27 insertions, 20 deletions
diff --git a/cmd/podman/containers/rm.go b/cmd/podman/containers/rm.go
index 1e3976389..9c760e752 100644
--- a/cmd/podman/containers/rm.go
+++ b/cmd/podman/containers/rm.go
@@ -149,7 +149,8 @@ func removeContainers(namesOrIDs []string, rmOptions entities.RmOptions, setExit
return err
}
for _, r := range responses {
- if r.Err != nil {
+ switch {
+ case r.Err != nil:
if errors.Is(r.Err, define.ErrWillDeadlock) {
logrus.Errorf("Potential deadlock detected - please run 'podman system renumber' to resolve")
}
@@ -160,8 +161,10 @@ func removeContainers(namesOrIDs []string, rmOptions entities.RmOptions, setExit
setExitCode(r.Err)
}
errs = append(errs, r.Err)
- } else {
+ case r.RawInput != "":
fmt.Println(r.RawInput)
+ default:
+ fmt.Println(r.Id)
}
}
return errs.PrintErrors()
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index 08d845d70..0a8e5bc2f 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -381,7 +381,7 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string,
// this will fail and code will fall through to removing the container from libpod.`
tmpNames := []string{}
for _, ctr := range names {
- report := reports.RmReport{Id: ctr, RawInput: ctr}
+ report := reports.RmReport{Id: ctr}
report.Err = ic.Libpod.RemoveStorageContainer(ctr, options.Force)
//nolint:gocritic
if report.Err == nil {
@@ -938,13 +938,15 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
if err != nil {
return nil, err
}
+ idToRawInput := map[string]string{}
+ if len(rawInputs) == len(ctrs) {
+ for i := range ctrs {
+ idToRawInput[ctrs[i].ID()] = rawInputs[i]
+ }
+ }
// There can only be one container if attach was used
for i := range ctrs {
ctr := ctrs[i]
- rawInput := ctr.ID()
- if !options.All {
- rawInput = rawInputs[i]
- }
ctrState, err := ctr.State()
if err != nil {
return nil, err
@@ -958,7 +960,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
// Exit cleanly immediately
reports = append(reports, &entities.ContainerStartReport{
Id: ctr.ID(),
- RawInput: rawInput,
+ RawInput: idToRawInput[ctr.ID()],
Err: nil,
ExitCode: 0,
})
@@ -969,7 +971,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
logrus.Debugf("Deadlock error: %v", err)
reports = append(reports, &entities.ContainerStartReport{
Id: ctr.ID(),
- RawInput: rawInput,
+ RawInput: idToRawInput[ctr.ID()],
Err: err,
ExitCode: define.ExitCode(err),
})
@@ -979,7 +981,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
if ctrRunning {
reports = append(reports, &entities.ContainerStartReport{
Id: ctr.ID(),
- RawInput: rawInput,
+ RawInput: idToRawInput[ctr.ID()],
Err: nil,
ExitCode: 0,
})
@@ -989,7 +991,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
if err != nil {
reports = append(reports, &entities.ContainerStartReport{
Id: ctr.ID(),
- RawInput: rawInput,
+ RawInput: idToRawInput[ctr.ID()],
Err: err,
ExitCode: exitCode,
})
@@ -1004,7 +1006,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
exitCode = ic.GetContainerExitCode(ctx, ctr)
reports = append(reports, &entities.ContainerStartReport{
Id: ctr.ID(),
- RawInput: rawInput,
+ RawInput: idToRawInput[ctr.ID()],
Err: err,
ExitCode: exitCode,
})
@@ -1017,7 +1019,7 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
// If the container is in a pod, also set to recursively start dependencies
report := &entities.ContainerStartReport{
Id: ctr.ID(),
- RawInput: rawInput,
+ RawInput: idToRawInput[ctr.ID()],
ExitCode: 125,
}
if err := ctr.Start(ctx, true); err != nil {
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 046509140..023bee430 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -672,10 +672,16 @@ func logIfRmError(id string, err error, reports []*reports.RmReport) {
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
reports := []*entities.ContainerStartReport{}
var exitCode = define.ExecErrorCodeGeneric
- ctrs, namesOrIds, err := getContainersAndInputByContext(ic.ClientCtx, options.All, false, namesOrIds, options.Filters)
+ ctrs, rawInputs, err := getContainersAndInputByContext(ic.ClientCtx, options.All, false, namesOrIds, options.Filters)
if err != nil {
return nil, err
}
+ idToRawInput := map[string]string{}
+ if len(rawInputs) == len(ctrs) {
+ for i := range ctrs {
+ idToRawInput[ctrs[i].ID] = rawInputs[i]
+ }
+ }
removeOptions := new(containers.RemoveOptions).WithVolumes(true).WithForce(false)
removeContainer := func(id string) {
reports, err := containers.Remove(ic.ClientCtx, id, removeOptions)
@@ -683,15 +689,11 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
}
// There can only be one container if attach was used
- for i, ctr := range ctrs {
+ for _, ctr := range ctrs {
name := ctr.ID
- rawInput := ctr.ID
- if !options.All {
- rawInput = namesOrIds[i]
- }
report := entities.ContainerStartReport{
Id: name,
- RawInput: rawInput,
+ RawInput: idToRawInput[name],
ExitCode: exitCode,
}
ctrRunning := ctr.State == define.ContainerStateRunning.String()