Skip to content

Commit 59dcf4b

Browse files
committed
pkg/domain/infra/tunnel: ignore error from removeContainer()
All callers ignore the error anyways so no reason to return it as the function itself already logs it. Signed-off-by: Paul Holzinger <[email protected]>
1 parent cb2b1d7 commit 59dcf4b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pkg/domain/infra/tunnel/containers.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
872872
for _, w := range con.Warnings {
873873
fmt.Fprintf(os.Stderr, "%s\n", w)
874874
}
875-
removeContainer := func(id, CIDFile string, force bool) error {
875+
removeContainer := func(id, CIDFile string, force bool) {
876876
if CIDFile != "" {
877877
if err := os.Remove(CIDFile); err != nil && !errors.Is(err, os.ErrNotExist) {
878878
logrus.Warnf("Cleaning up CID file: %s", err)
@@ -882,13 +882,12 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
882882
removeOptions := new(containers.RemoveOptions).WithVolumes(true).WithForce(force)
883883
reports, err := containers.Remove(ic.ClientCtx, id, removeOptions)
884884
logIfRmError(id, err, reports)
885-
return err
886885
}
887886

888887
if opts.CIDFile != "" {
889888
if err := util.CreateIDFile(opts.CIDFile, con.ID); err != nil {
890889
// If you fail to create CIDFile then remove the container
891-
_ = removeContainer(con.ID, opts.CIDFile, true)
890+
removeContainer(con.ID, opts.CIDFile, true)
892891
return nil, err
893892
}
894893
}
@@ -901,7 +900,7 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
901900
if err != nil {
902901
report.ExitCode = define.ExitCode(err)
903902
if opts.Rm {
904-
_ = removeContainer(con.ID, opts.CIDFile, true)
903+
removeContainer(con.ID, opts.CIDFile, true)
905904
}
906905
}
907906
return &report, err
@@ -924,15 +923,13 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
924923

925924
report.ExitCode = define.ExitCode(err)
926925
if opts.Rm {
927-
_ = removeContainer(con.ID, opts.CIDFile, false)
926+
removeContainer(con.ID, opts.CIDFile, false)
928927
}
929928
return &report, err
930929
}
931930

932931
if opts.Rm {
933-
// Defer the removal, so we can return early if needed and
934-
// de-spaghetti the code.
935-
defer removeContainer(con.ID, opts.CIDFile, false)
932+
removeContainer(con.ID, opts.CIDFile, false)
936933
}
937934

938935
report.ExitCode = code

0 commit comments

Comments
 (0)