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

Fix pull parameter parsing for compat /build endpoint #19591

Merged

Conversation

matejvasek
Copy link
Contributor

@matejvasek matejvasek commented Aug 10, 2023

Changes

Fixing Docker client incompatibility:

# Broken compatibility with the docker CLI
docker build . -t alpine-1000 --pull
Sending build context to Docker daemon  2.048kB
Error response from daemon: failed to parse query parameter 'pull': "1": invalid pull policy: "1"
  • Revert compat,build: pull must accept string #18583 since it breaks compatibility with standard docker client.
    Previously it was believed the pull parameter is pull-policy since REST API doc says it is string, not bool. However it fact it is a boolean. Confusingly enough Docker indeed accept values like always or never but these values are interpreted as true by Docker. As matter of the fact it appears that there is no such a thing as pull-policy in Docker.
  • Use custom boolean query param deserializer for all compat endpoints to get closer to Docker's way.
    This means anything but "", "0", "no", "false", "none" (ignoring case) is considered to be true.

More context: #17778 (comment)

Correct parsing of the pull query parameter for the compat /build endpoint.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None labels Aug 10, 2023
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Aug 10, 2023
@matejvasek
Copy link
Contributor Author

/cc @Luap99 @flouthoc

@openshift-ci openshift-ci bot requested review from flouthoc and Luap99 August 10, 2023 22:16
@matejvasek
Copy link
Contributor Author

matejvasek commented Aug 10, 2023

I do not insist on the second commit but we definitely must revert #18583.

@matejvasek
Copy link
Contributor Author

matejvasek commented Aug 10, 2023

Or if you do not like proliferation of CompatDecoderKey we can use that specific decoder only for the endpoint in question (at least for now).

@matejvasek
Copy link
Contributor Author

/cc @mheon

@openshift-ci openshift-ci bot requested a review from mheon August 10, 2023 22:42
@openshift-ci openshift-ci bot added release-note and removed do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None labels Aug 10, 2023
@matejvasek matejvasek changed the title Fix build pull compat Fix pull parameter parsing for compat /build endpoint Aug 10, 2023
@matejvasek
Copy link
Contributor Author

wrt DCO: do I really need to sign revert commit?

@matejvasek matejvasek force-pushed the fix-build-pull-compat branch from eb56909 to 18fba27 Compare August 11, 2023 00:16
@matejvasek matejvasek marked this pull request as ready for review August 11, 2023 00:17
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 11, 2023
@matejvasek matejvasek force-pushed the fix-build-pull-compat branch 3 times, most recently from d31b733 to 7622bfc Compare August 11, 2023 01:39
Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

Its weird though to drift away from docs here: https://docs.docker.com/engine/api/v1.42/#tag/Image/operation/ImageBuild ( but since your investigation points that there might be an issue with the docker documentation itself, I am convinced ) lets wait for other maintainers.

This is a breaking change even if this is reverting to an old behavior.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, matejvasek

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 11, 2023
@vrothberg
Copy link
Member

Please add rather verbose explanations on why we are reverting the commit. It has already been released.

@Luap99
Copy link
Member

Luap99 commented Aug 11, 2023

#17778 (comment) sounds reasonable but I agree with @vrothberg, explanations like this should be part of the commit message.

@rhatdan
Copy link
Member

rhatdan commented Aug 11, 2023

Is there a test to make sure the libpod entry point still works with the string passing?

@matejvasek
Copy link
Contributor Author

@rhatdan I don't know, but I think I have not touched libpod part at all.

@matejvasek
Copy link
Contributor Author

One questionable thing about this PR is changing boolean parser for all query params of all compat endpoints.

@matejvasek
Copy link
Contributor Author

matejvasek commented Aug 11, 2023

One questionable thing about this PR is changing boolean parser for all query params of all compat endpoints.

But it changes it in mostly compatible way. Strings "true", "1" are still true. Strings "false", "0" are still false. However string "f" will be now interpreted as true, previously it was false. But this is how Docker converts string to booleans.

@matejvasek
Copy link
Contributor Author

@vrothberg @Luap99 I updated description.

@matejvasek
Copy link
Contributor Author

sending using opt=blah should return a error to the caller and not assume true IMO

@Luap99 Wholeheartedly agree, but tell that to moby.

@matejvasek
Copy link
Contributor Author

Also as I said I am fine with just reverting to previous state where presumably strconv.ParseBool() was used.

@@ -580,19 +579,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
pullPolicy = buildahDefine.PolicyMap[query.PullPolicy]
} else {
if _, found := r.URL.Query()["pull"]; found {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Luap99 Is this found guard needed? Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean if the pull param is not present then quar.yPull is false anyway right?

Copy link
Member

Choose a reason for hiding this comment

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

Yes I don't think that is needed and should work without it.

@matejvasek
Copy link
Contributor Author

@Luap99 I fixed decoder discrimination for libpod and compat endpoints.

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

@matejvasek
Copy link
Contributor Author

matejvasek commented Aug 11, 2023

Draft of little bit more conservative fix /~https://github.com/containers/podman/pull/19601/files

@matejvasek
Copy link
Contributor Author

matejvasek commented Aug 11, 2023

@Luap99 @rhatdan IMO it would be good to backport this into patch releases (4.6.2). If this PR seems too big/risky for backporting we can consider something more conservative like #19601

@vrothberg
Copy link
Member

@vrothberg @Luap99 I updated description.

I don't see it in the commits.

@flouthoc
Copy link
Collaborator

@matejvasek I think PR description is updated but still it looks less verbose as compared to your investigation here #17778 (comment), I'd vote for including this in commit body or alteast a link to it: #17778 (comment)

This reverts commit 5b148a0.

Reverting to treating the `pull` query parameter as a boolean.
Because of deceiving Docker API documentation it was assumed that the
parameter is pull-policy, however that is not true. Docker does treat
`pull` as a boolean. What is interesting is that Docker indeed accepts
strings like `always` or `never` however Docekr both of these strings
treat as `true`, not as pull-policy. As matter of the fact it seems
there is no such a thing as pull-policy in Docker.

More context containers#17778 (comment)

Signed-off-by: Matej Vasek <mvasek@redhat.com>
@matejvasek matejvasek force-pushed the fix-build-pull-compat branch from 6120607 to a3f1451 Compare August 14, 2023 13:06
@matejvasek
Copy link
Contributor Author

@vrothberg @flouthoc I updated commit message.

In Docker anything but "", "0", "no", "false", "none" (ignoring case) is considered to be true.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
@matejvasek matejvasek force-pushed the fix-build-pull-compat branch from a3f1451 to f33b01b Compare August 14, 2023 13:10
@rhatdan
Copy link
Member

rhatdan commented Aug 14, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 14, 2023
@openshift-merge-robot openshift-merge-robot merged commit 824c766 into containers:main Aug 14, 2023
@matejvasek
Copy link
Contributor Author

@rhatdan will this be eligible for 4.6.2?

@Luap99
Copy link
Member

Luap99 commented Aug 15, 2023

I think backporting #19601 makes more sense IMO as this one has less risk involved, if you need the backport in RHEL you need to file a bugzilla as 4.6.1-rhel is already frozen for RHEL.

@matejvasek
Copy link
Contributor Author

What will be time period between 4.6.1-rhel and 4.6.2-rhel ? @Luap99

@Luap99
Copy link
Member

Luap99 commented Aug 15, 2023

There will never be a 4.6.2 in RHEL, RHEL is frozen for each minor RHEL release. Then only approved backports are allowed to the rhel branches so you need to file bugzillas (or Jira bugs soon) for those in order to get this fixed in RHEL.
4.6.1 will go into RHEL 8.9/9.3 and then next version will be only in 6 months for 8.10/9.4 which by then will likely by podman 4.8 or later whatever we decide upstream.

@matejvasek
Copy link
Contributor Author

@Luap99 I absolutely want this fix in rhel.

@matejvasek
Copy link
Contributor Author

#19631

@matejvasek
Copy link
Contributor Author

@Luap99 https://issues.redhat.com or somewhere else?

@TomSweeneyRedHat
Copy link
Member

@matejvasek I think this is what you're looking for: https://bugzilla.redhat.com/show_bug.cgi?id=2232127

@matejvasek
Copy link
Contributor Author

@TomSweeneyRedHat yeah I created that issue after chat on Slack with @Luap99 .

@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 Nov 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 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. kind/api-change Change to remote API; merits scrutiny 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.

7 participants