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: add layer caching compatiblity for non-podman clients. #12381

Merged

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Nov 22, 2021

Non podman clients do not set layers while making request. This is
supposed to be true by default but non-podman-clients i.e Docker dont
know about this field as a result they end up setting this value to
false. Causing builds to never use cache for layers.

Adds compatibility for non-podman (docker SDK).

[NO NEW TESTS NEEDED]
Cant find any convenient way to add a new test for this via podman client.

Closes: #12378

@flouthoc
Copy link
Collaborator Author

@stac47 Could you please try this with Docker SDK.

@flouthoc flouthoc force-pushed the build-layer-docker-compat branch 2 times, most recently from 584ad53 to 0ba5007 Compare November 22, 2021 12:25
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, thank you @flouthoc

@flouthoc flouthoc force-pushed the build-layer-docker-compat branch from 0ba5007 to c05d8c2 Compare November 22, 2021 12:36
@stac47
Copy link

stac47 commented Nov 22, 2021

Hi,
Perfect ! It works like a charm.
Thanks,

@vrothberg
Copy link
Member

@flouthoc, it looks like tests break. I did not check but suspect that the libpod endpoint is calling the same handler, so we may need to make setting the default conditional (i.e., do not set for libpod calls).

@mheon
Copy link
Member

mheon commented Nov 22, 2021

LGTM once tests go green, and concur that @vrothberg is on the right track on the cause of the failures

@flouthoc flouthoc force-pushed the build-layer-docker-compat branch from c05d8c2 to 6fed507 Compare November 22, 2021 14:40
@flouthoc
Copy link
Collaborator Author

flouthoc commented Nov 22, 2021

@vrothberg ackd then i guess previous version of commit should handle this, which only sets it true when no layer was passed which should honor libpod and docker sdk at the same time.

// if layers field not set assume its not from a valid podman-client
// could be a docker client, set `layers=true` since that is the default
// expected behviour
if _, found := r.URL.Query()["layers"]; !found {
Copy link
Member

Choose a reason for hiding this comment

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

That's not enough. We need to check whether the handler was called via libpod or compat. Otherwise we depend on behavior that may change.

Wrap that into if !utils.IsLibpodRequest(r) { ..}

Copy link
Member

Choose a reason for hiding this comment

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

Why should layers not default to true in the libpod API? podman build defaults to true so should the API IMO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Luap99 i guess because podman-remote has a option to configure it as false so we must honor it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@vrothberg ackd.

Copy link
Member

Choose a reason for hiding this comment

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

We will always honor it, this is just the default.

Copy link
Member

Choose a reason for hiding this comment

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

@vrothberg @mheon Why should the API have a different default then the podman cli?

Copy link
Member

Choose a reason for hiding this comment

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

Tests broke so there is an expectation on these libpod defaults. Changing them seems like a separate issue to me.

@Luap99
Copy link
Member

Luap99 commented Nov 22, 2021

@flouthoc Can you please document that parameter in the swagger doc. It looks like layers is not listed there.

Non-podman clients do not set `layers` while making request. This is
supposed to be `true` bydefault but `non-podman-clients i.e Docker` dont
know about this field as a result they end up setting this values to
`false`. Causing builds to never use cache for layers.

Adds compatiblity for `docker SDK`.

[NO NEW TESTS NEEDED]

Signed-off-by: Aditya Rajan <arajan@redhat.com>
Add missing `layer` entry to swagger docs for `/build`.

Signed-off-by: Aditya Rajan <arajan@redhat.com>
@flouthoc flouthoc force-pushed the build-layer-docker-compat branch from 6fed507 to 13ee178 Compare November 22, 2021 15:45
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

@rhatdan
Copy link
Member

rhatdan commented Nov 22, 2021

/lgtm
/hold
/approve

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 22, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 22, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, 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 Nov 22, 2021
@flouthoc
Copy link
Collaborator Author

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 22, 2021
@openshift-merge-robot openshift-merge-robot merged commit 9133c56 into containers:main Nov 22, 2021
@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 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image build cache not working through podman listening service
7 participants