From 29ecf5984c33c700a7c31beb3c0911d9bc7f3ca6 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 24 Jun 2024 13:20:21 +0200 Subject: [PATCH] libpod API: return proper error status code for pod start When we failed to do anything we should return 500, the 409 code has a special meaing to the client as it uses a different error format. As such the remote client was not able to unmarshal the error correctly and just returned an empty string. Fixes #22989 Signed-off-by: Paul Holzinger --- pkg/api/handlers/libpod/pods.go | 6 +++--- test/e2e/pod_start_test.go | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go index 0236a10794..bb5aadd2ce 100644 --- a/pkg/api/handlers/libpod/pods.go +++ b/pkg/api/handlers/libpod/pods.go @@ -202,7 +202,7 @@ func PodStart(w http.ResponseWriter, r *http.Request) { } status, err := pod.GetPodStatus() if err != nil { - utils.Error(w, http.StatusInternalServerError, err) + utils.InternalServerError(w, err) return } if status == define.PodStateRunning { @@ -212,13 +212,13 @@ func PodStart(w http.ResponseWriter, r *http.Request) { responses, err := pod.Start(r.Context()) if err != nil && !errors.Is(err, define.ErrPodPartialFail) { - utils.Error(w, http.StatusConflict, err) + utils.InternalServerError(w, err) return } cfg, err := pod.Config() if err != nil { - utils.Error(w, http.StatusConflict, err) + utils.InternalServerError(w, err) return } report := entities.PodStartReport{ diff --git a/test/e2e/pod_start_test.go b/test/e2e/pod_start_test.go index 03a445d431..640ff48462 100644 --- a/test/e2e/pod_start_test.go +++ b/test/e2e/pod_start_test.go @@ -29,12 +29,7 @@ var _ = Describe("Podman pod start", func() { session := podmanTest.Podman([]string{"pod", "start", podid}) session.WaitWithDefaultTimeout() - expect := fmt.Sprintf("no containers in pod %s have no dependencies, cannot start pod: no such container", podid) - if IsRemote() { - // FIXME: #22989 no error message - expect = "Error:" - } - Expect(session).Should(ExitWithError(125, expect)) + Expect(session).Should(ExitWithError(125, fmt.Sprintf("no containers in pod %s have no dependencies, cannot start pod: no such container", podid))) }) It("podman pod start single pod by name", func() {