Merge pull request #18282 from Luap99/remote-logs-fix

podman-remote logs: handle server error correctly
This commit is contained in:
Paul Holzinger
2023-04-20 16:25:52 +02:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@ -35,6 +35,11 @@ func Logs(ctx context.Context, nameOrID string, options *LogOptions, stdoutChan,
}
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)
for {
fd, l, err := DemuxHeader(response.Body, buffer)

View File

@ -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"} {
// This is important to move the 'log' var to the correct scope under Ginkgo flow.
log := log