podman/pkg/api/handlers/utils
Paul Holzinger 768ad8653a
rework event code to improve API errors
One of the problems with the Events() API was that you had to call it in
a new goroutine. This meant the the error returned by it had to be read
back via a second channel. This cuased other bugs in the past but here
the biggest problem is that basic errors such as invalid since/until
options were not directly returned to the caller.
It meant in the API we were not able to write http code 200 quickly
because we always waited for the first event or error from the
channels. This in turn made some clients not happy as they assume the
server hangs on time out if no such events are generated.

To fix this we resturcture the entire event flow. First we spawn the
goroutine inside the eventer Read() function so not all the callers have
to. Then we can return the basic error quickly without the goroutine.
The caller then checks the error like any normal function and the API
can use this one to decide which status code to return.
Second we now return errors/event in one channel then the callers can
decide to ignore or log them which makes it a bit more clear.

Fixes c46884aa93 ("podman events: check for an error after we finish reading events")
Fixes #23712

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-11-01 18:54:13 +01:00
..
apiutil set !remote build tags where needed 2024-08-19 11:41:28 +02:00
containers.go rework event code to improve API errors 2024-11-01 18:54:13 +01:00
errors.go set !remote build tags where needed 2024-08-19 11:41:28 +02:00
handler.go set !remote build tags where needed 2024-08-19 11:41:28 +02:00
handler_test.go set !remote build tags where needed 2024-08-19 11:41:28 +02:00
images.go Remove containers/common/pkg/config from pkg/util 2024-09-06 07:45:04 -04:00