mirror of
https://github.com/containers/podman.git
synced 2025-07-04 01:48:28 +08:00
Merge pull request #23080 from Luap99/remote-err
libpod API: fix two pod remote error messages
This commit is contained in:
@ -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{
|
||||
@ -411,12 +411,8 @@ func PodTop(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// We are committed now - all errors logged but not reported to client, ship has sailed
|
||||
w.WriteHeader(http.StatusOK)
|
||||
wroteContent := false
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if f, ok := w.(http.Flusher); ok {
|
||||
f.Flush()
|
||||
}
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
|
||||
@ -428,11 +424,22 @@ loop: // break out of for/select infinite` loop
|
||||
default:
|
||||
output, err := pod.GetPodPidInformation([]string{query.PsArgs})
|
||||
if err != nil {
|
||||
logrus.Infof("Error from %s %q : %v", r.Method, r.URL, err)
|
||||
break loop
|
||||
if !wroteContent {
|
||||
utils.InternalServerError(w, err)
|
||||
} else {
|
||||
// ship has sailed, client already got a 200 response and expects valid
|
||||
// PodTopOKBody json format so we no longer can send the error.
|
||||
logrus.Infof("Error from %s %q : %v", r.Method, r.URL, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if len(output) > 0 {
|
||||
if !wroteContent {
|
||||
// Write header only first time around
|
||||
w.WriteHeader(http.StatusOK)
|
||||
wroteContent = true
|
||||
}
|
||||
body := handlers.PodTopOKBody{}
|
||||
body.Titles = utils.PSTitles(output[0])
|
||||
for i := range body.Titles {
|
||||
|
@ -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() {
|
||||
|
@ -85,12 +85,7 @@ var _ = Describe("Podman top", func() {
|
||||
// the wrong input and still print the -ef output instead.
|
||||
result := podmanTest.Podman([]string{"pod", "top", podid, "-eo", "invalid"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
if IsRemote() {
|
||||
// FIXME: #22986
|
||||
Expect(result).Should(ExitWithError(125, "unmarshalling into &handlers.PodTopOKBody{ContainerTopOKBody:container.ContainerTopOKBody"))
|
||||
} else {
|
||||
Expect(result).Should(ExitWithError(125, "Error: '-eo': unknown descriptor"))
|
||||
}
|
||||
Expect(result).Should(ExitWithError(125, "Error: '-eo': unknown descriptor"))
|
||||
})
|
||||
|
||||
It("podman pod top on pod with containers in same pid namespace", func() {
|
||||
|
Reference in New Issue
Block a user