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

Fail earlier when no containers exist in stats #22707

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented May 14, 2024

Does this PR introduce a user-facing change?

None

Copy link
Contributor

openshift-ci bot commented May 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

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 14, 2024
@rhatdan
Copy link
Member Author

rhatdan commented May 14, 2024

@edsantiago PTAL

@edsantiago
Copy link
Collaborator

LGTM! Thank you!

@rhatdan
Copy link
Member Author

rhatdan commented May 14, 2024

Fixes: #22612

Copy link

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

Copy link

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

@@ -25,10 +25,6 @@ var _ = Describe("Podman stats", func() {
session := podmanTest.Podman([]string{"stats", "--no-stream", "123"})
session.WaitWithDefaultTimeout()
expect := `unable to get list of containers: unable to look up container 123: no container with name or ID "123" found: no such container`
Copy link
Collaborator

Choose a reason for hiding this comment

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

As long as you have to repush, though, might as well move the string below into ExitWithError(), and get rid of the temporary variable...

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.

This is changing the behavior, if you get the list of containers before the loop it will not update on each inteerval which means newly created contianer will not be added later which is wrong.

The proper way to fix is doing something like this for stats as well. #22691

@rhatdan rhatdan force-pushed the stats branch 2 times, most recently from 026052f to 0851695 Compare May 15, 2024 11:09
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label May 15, 2024
Copy link

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

Copy link

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

Copy link

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

@rhatdan rhatdan force-pushed the stats branch 2 times, most recently from 23d9c2b to 8e7cc2e Compare May 15, 2024 11:40
Copy link

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

Copy link

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

Copy link

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

@lsm5
Copy link
Member

lsm5 commented May 15, 2024

The ELN copr environment fixes should land today/tomorrow so ignore failures for now.

@lsm5
Copy link
Member

lsm5 commented May 15, 2024

@martinpitt the cockpit tests on rawhide have been failing consistently recently. PTAL.

Copy link

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

@jelly
Copy link
Contributor

jelly commented May 16, 2024

@martinpitt the cockpit tests on rawhide have been failing consistently recently. PTAL.

Hey, sorry we had some issues with the new systemd release landing in rawhide. The tests should run now.

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.

API tests are failing,
unable to look up container [$cid] looks like a bug in the tests, a caliss case of not checking the output/error message.

Comment on lines 89 to 97
if !wroteContent {
// Write header and content type.
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
if flusher, ok := w.(http.Flusher); ok {
flusher.Flush()
}
wroteContent = true
}
Copy link
Member

Choose a reason for hiding this comment

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

this would need happen before the coder.encode call as headers/status code must be written before content.
and you can remove the flush here as it flushes below anyway.

@rhatdan rhatdan force-pushed the stats branch 3 times, most recently from 6965b8c to 1e1df0f Compare May 16, 2024 19:13
@rhatdan
Copy link
Member Author

rhatdan commented May 20, 2024

@Luap99 PTAL

Comment on lines 116 to 121
t GET libpod/containers/$cid/stats?stream=false 200
else
if have_cgroupsv2; then
t GET libpod/containers/stats?containers='[$cid]' 200
t GET libpod/containers/$cid/stats?stream=false 200
else
t GET libpod/containers/stats?containers='[$cid]' 409
t GET libpod/containers/$cid/stats?stream=false 409
Copy link
Member

Choose a reason for hiding this comment

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

These are two different endpoints, I would suggest you keep testing the endpoint you actually fixed and juts fix the tests instead.
The correct URl param would be ?containers=$cid
And then add some basic output checks as well.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
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 release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants