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

Compat API image remove events now have 'delete' status #15487

Merged
merged 1 commit into from
Aug 26, 2022

Conversation

mheon
Copy link
Member

@mheon mheon commented Aug 25, 2022

Change only the compat API, so we don't force a breaking change on Libpod API users.

Partial fix for #15485

Fixed a bug where the Compat Events endpoint set an incorrect status for image removal events (`remove` instead of `delete`)

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 25, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mheon

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 Aug 25, 2022
@mheon
Copy link
Member Author

mheon commented Aug 25, 2022

@edsantiago Mind checking my APIv2 test changes? I only vaguely know what I'm doing there.

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

LGTM! The jq magic is trickier than anything I could've come up with. Some nits inline.

Why does each call take 15 seconds? Is that because my laptop has been running too long, and journal is bloated?

# compat API delete image produces a delete event
#create, list and remove dangling image
podman image build -t test:test -<<EOF
from alpine
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: from $IMAGE

t DELETE libpod/images/test:test 200
t GET "libpod/events?stream=false&since=$START" 200 \
'select(.status | contains("remove")).Action=remove'
t GET "events?stream=false&since=$START" 200 \
Copy link
Member

Choose a reason for hiding this comment

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

LGTM, and fails when run against main.

@@ -239,4 +239,18 @@ fi

cleanBuildTest

# compat API delete image produces a delete event
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: make the difference clearer, e.g., ...delete event; libpod API calls it 'remove'

@edsantiago
Copy link
Member

I don't understand any of the test failures. The one in your new test: could that be a race? Is the event written to journal before the endpoint terminates, or could there be a delay such that t DELETE;t GET /events could run too quickly?

The 12-* errors, I don't understand at all.

@mheon
Copy link
Member Author

mheon commented Aug 25, 2022

I'm going to throw in a sleep to see if it could be a race.

@@ -59,7 +59,7 @@ t GET "images/testimage:20210610/json" 200 \

# Make sure that new images are pulled
old_iid=$(podman image inspect --format "{{.ID}}" docker.io/library/alpine:latest)
podman rmi -f docker.io/library/alpine:latest
11;rgb:0000/0000/0000podman rmi -f docker.io/library/alpine:latest
Copy link
Member

Choose a reason for hiding this comment

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

copy-paste error, methinks. I also methinks that this will make tests barf before you get to the actual real test, so, you might want to repush.

@@ -89,6 +89,10 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
}

e := entities.ConvertToEntitiesEvent(*evt)
if !utils.IsLibpodRequest(r) && e.Type == "image" && e.Status == "remove" {
Copy link
Member

Choose a reason for hiding this comment

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

y'know, as long as we're re-pushing, why not add a comment here for future maintainers, explaining exactly what the problem is?

@edsantiago
Copy link
Member

Passed this time. Now what?

@mheon
Copy link
Member Author

mheon commented Aug 25, 2022

I see two potential options. This could be bad behavior out of the delete endpoint for images (returning before work has fully completed), or this is a race in journald - we can't read the event's journal message until a short time after it's been written (possibly because the event needs time to be written?).

I'll investigate the first option, but I have a feeling it's the second. If it is, safest option might be some form of retry loop - say 5 attempts, half second between each, to give the journal time to settle?

@edsantiago
Copy link
Member

Retry loop sounds attractive, except for the how-to-implement-it part. It sounds really, really hard.

@mheon
Copy link
Member Author

mheon commented Aug 25, 2022

Could just leave the 1 second sleep in there and revisit if it flakes?

@edsantiago
Copy link
Member

Ostrich solution WFM.

Change only the compat API, so we don't force a breaking change
on Libpod API users.

Partial fix for containers#15485

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
@mheon
Copy link
Member Author

mheon commented Aug 25, 2022

Updated comment to note the offending sleep for future fixes (if necessary).

@containers/podman-maintainers PTAL, this should go green

Copy link
Member

@vrothberg vrothberg 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 Aug 26, 2022
@openshift-merge-robot openshift-merge-robot merged commit ac3d9c6 into containers:main Aug 26, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants