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()
|
status, err := pod.GetPodStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error(w, http.StatusInternalServerError, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if status == define.PodStateRunning {
|
if status == define.PodStateRunning {
|
||||||
@ -212,13 +212,13 @@ func PodStart(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
responses, err := pod.Start(r.Context())
|
responses, err := pod.Start(r.Context())
|
||||||
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
||||||
utils.Error(w, http.StatusConflict, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := pod.Config()
|
cfg, err := pod.Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error(w, http.StatusConflict, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
report := entities.PodStartReport{
|
report := entities.PodStartReport{
|
||||||
@ -411,12 +411,8 @@ func PodTop(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are committed now - all errors logged but not reported to client, ship has sailed
|
wroteContent := false
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if f, ok := w.(http.Flusher); ok {
|
|
||||||
f.Flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
|
|
||||||
@ -428,11 +424,22 @@ loop: // break out of for/select infinite` loop
|
|||||||
default:
|
default:
|
||||||
output, err := pod.GetPodPidInformation([]string{query.PsArgs})
|
output, err := pod.GetPodPidInformation([]string{query.PsArgs})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Infof("Error from %s %q : %v", r.Method, r.URL, err)
|
if !wroteContent {
|
||||||
break loop
|
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 len(output) > 0 {
|
||||||
|
if !wroteContent {
|
||||||
|
// Write header only first time around
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
wroteContent = true
|
||||||
|
}
|
||||||
body := handlers.PodTopOKBody{}
|
body := handlers.PodTopOKBody{}
|
||||||
body.Titles = utils.PSTitles(output[0])
|
body.Titles = utils.PSTitles(output[0])
|
||||||
for i := range body.Titles {
|
for i := range body.Titles {
|
||||||
|
@ -29,12 +29,7 @@ var _ = Describe("Podman pod start", func() {
|
|||||||
|
|
||||||
session := podmanTest.Podman([]string{"pod", "start", podid})
|
session := podmanTest.Podman([]string{"pod", "start", podid})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
expect := fmt.Sprintf("no containers in pod %s have no dependencies, cannot start pod: no such container", podid)
|
Expect(session).Should(ExitWithError(125, 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))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman pod start single pod by name", func() {
|
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.
|
// the wrong input and still print the -ef output instead.
|
||||||
result := podmanTest.Podman([]string{"pod", "top", podid, "-eo", "invalid"})
|
result := podmanTest.Podman([]string{"pod", "top", podid, "-eo", "invalid"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
if IsRemote() {
|
Expect(result).Should(ExitWithError(125, "Error: '-eo': unknown descriptor"))
|
||||||
// FIXME: #22986
|
|
||||||
Expect(result).Should(ExitWithError(125, "unmarshalling into &handlers.PodTopOKBody{ContainerTopOKBody:container.ContainerTopOKBody"))
|
|
||||||
} else {
|
|
||||||
Expect(result).Should(ExitWithError(125, "Error: '-eo': unknown descriptor"))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman pod top on pod with containers in same pid namespace", func() {
|
It("podman pod top on pod with containers in same pid namespace", func() {
|
||||||
|
Reference in New Issue
Block a user