Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman events: check for an error after we finish reading events #22691

Merged
merged 1 commit into from
May 15, 2024

Conversation

nalind
Copy link
Member

@nalind nalind commented May 13, 2024

Does this PR introduce a user-facing change?

`podman events` should be able to diagnose invalid values being passed as arguments to its `--since` and `--until` flags.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@rhatdan
Copy link
Member

rhatdan commented May 13, 2024

LGTM

if err != nil {
return err
}
case <-time.After(1 * time.Millisecond):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming you did this to get a non blocking call on the error channel you should use the default case instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either one assumes that the error will be ready by the time the select statement looks at the channel, but yeah, default would be cleaner. Changed it.

Copy link

Cockpit tests failed for commit ace8080. @martinpitt, @jelly, @mvollmer please check.

@mheon
Copy link
Member

mheon commented May 14, 2024

I hate the nested select, but I don't see another way.

LGTM once you get the test to pass.

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label May 14, 2024
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

Copy link

Cockpit tests failed for commit dc7a0ed. @martinpitt, @jelly, @mvollmer please check.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

Comment on lines 47 to 63
var bodyText string
if body, err := io.ReadAll(response.Body); err == nil {
bodyText = string(body)
}
var errorModel errorhandling.ErrorModel
if err := json.Unmarshal([]byte(bodyText), &errorModel); err == nil && errorModel.Message != "" {
bodyText = errorModel.Message
}
if response.Status != "" {
if bodyText != "" {
return fmt.Errorf("%s: %s", response.Status, bodyText)
}
return errors.New(response.Status)
}
if bodyText != "" {
return fmt.Errorf("server responded with unexpected status code %d: %s", response.StatusCode, bodyText)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the rest of the code simply calls return response.Process(nil) to convert the error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's much better. Thanks!

Copy link

Cockpit tests failed for commit e1320a8. @martinpitt, @jelly, @mvollmer please check.

The function that's handing us events will return an error after closing
the channel over which it's sending events, and its caller (in its own
goroutine) will then send that error over another channel.

The logic that started the goroutine is likely to notice that the events
channel is closed before noticing that the error channel has a result
for it to read, so any error that would have been communicated would be
lost.

When we finish reading events, check if the reader returned an error
before telling our caller that there was no error.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

Copy link

Cockpit tests failed for commit c46884a. @martinpitt, @jelly, @mvollmer please check.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

Copy link

Cockpit tests failed for commit c46884a. @martinpitt, @jelly, @mvollmer please check.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 15, 2024
Copy link
Contributor

openshift-ci bot commented May 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, nalind

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 15, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 759e546 into containers:main May 15, 2024
88 of 91 checks passed
@nalind nalind deleted the events-bad-filters branch May 16, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants