mirror of
https://github.com/containers/podman.git
synced 2025-06-30 07:26:39 +08:00
Merge pull request #18282 from Luap99/remote-logs-fix
podman-remote logs: handle server error correctly
This commit is contained in:
@ -35,6 +35,11 @@ func Logs(ctx context.Context, nameOrID string, options *LogOptions, stdoutChan,
|
|||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
// if not success handle and return possible error message
|
||||||
|
if !(response.IsSuccess() || response.IsInformational()) {
|
||||||
|
return response.Process(nil)
|
||||||
|
}
|
||||||
|
|
||||||
buffer := make([]byte, 1024)
|
buffer := make([]byte, 1024)
|
||||||
for {
|
for {
|
||||||
fd, l, err := DemuxHeader(response.Body, buffer)
|
fd, l, err := DemuxHeader(response.Body, buffer)
|
||||||
|
@ -47,6 +47,13 @@ var _ = Describe("Podman logs", func() {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman logs on not existent container", func() {
|
||||||
|
results := podmanTest.Podman([]string{"logs", "notexist"})
|
||||||
|
results.WaitWithDefaultTimeout()
|
||||||
|
Expect(results).To(Exit(125))
|
||||||
|
Expect(results.ErrorToString()).To(Equal(`Error: no container with name or ID "notexist" found: no such container`))
|
||||||
|
})
|
||||||
|
|
||||||
for _, log := range []string{"k8s-file", "journald", "json-file"} {
|
for _, log := range []string{"k8s-file", "journald", "json-file"} {
|
||||||
// This is important to move the 'log' var to the correct scope under Ginkgo flow.
|
// This is important to move the 'log' var to the correct scope under Ginkgo flow.
|
||||||
log := log
|
log := log
|
||||||
|
Reference in New Issue
Block a user