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
stage_executor: re-use all the layers from cache
for squashed
case and commit
as late as possible.
#3674
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc 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 |
cache
for squashed
case and commit
as late as possible.cache
for squashed
case and commit
as late as possible.
@Romain-Geissler-1A Could you try following PR with As a result final sha would change for last step but all the other layers would be re-used from |
c70dba2
to
c0945ef
Compare
c0945ef
to
700314d
Compare
LGTM |
Do we have a test that ensures we don't reuse an image when we shouldn't? |
@nalind The Probably a check in this existing test to verify that |
LGTM |
@flouthoc There is something I don't get. Should I test like you by doing a first build WITHOUT --squash to save the intermediate layers ? Because, if I don't, it doesn't cache anything. I am testing inside docker, started with --privileged and a variant of this Dockerfile: https://github.com/containers/buildah/blob/main/contrib/buildahimage/upstream/Dockerfile
In both cases, the "sleep 20" command is ran, while I would expect it could be skipped the second time. Note that my real use case is obviously more complex, and uses multi stage builds. |
I would say the tests should be back to back squash, although I would also expect non squash followed by squash or vice versa to work. |
5a0a5c0
to
41c01a1
Compare
@Romain-Geissler-1A Could you please try again. I made some changes and tested with your use-case, it should work now.
Yes I am aware and i have tested it against various complex @rhatdan @nalind I'll add more tests once @Romain-Geissler-1A confirms if PR is working for him now. |
41c01a1
to
66e1970
Compare
…ilds Re-use all the layers from cache for squashed case and commit as late as possible Current implementation of marking for re-use of cache `commits` on every `stage` when used with `--squashed` however we should try to re-use as many layers are possible if `--layers` is specified and `commit` only on `last instruction` of `last stage` to perform final squash. Also treat all other layers as if they are being written for regular build and write them cache. Signed-off-by: Aditya Rajan <arajan@redhat.com>
66e1970
to
a74add5
Compare
@flouthoc Thanks, it works on my internal Amadeus case (Dockerfile is unmodified) with this version:
|
Buildah already supports using `--layers` with `--squash` after containers/buildah#3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: containers/buildah#4011 Signed-off-by: Aditya R <arajan@redhat.com>
Buildah already supports using `--layers` with `--squash` after containers/buildah#3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: containers/buildah#4011 Signed-off-by: Aditya R <arajan@redhat.com>
Buildah already supports using `--layers` with `--squash` after containers/buildah#3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: containers/buildah#4011 Signed-off-by: Aditya R <arajan@redhat.com>
Buildah already supports using `--layers` with `--squash` after containers/buildah#3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: containers/buildah#4011 Signed-off-by: Aditya R <arajan@redhat.com>
Buildah already supports using `--layers` with `--squash` after containers/buildah#3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: containers/buildah#4011 Signed-off-by: Aditya R <arajan@redhat.com>
Buildah already supports using `--layers` with `--squash` after containers/buildah#3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: containers/buildah#4011 Signed-off-by: Aditya R <arajan@redhat.com>
Buildah already supports using `--layers` with `--squash` after containers/buildah#3674 if user wants to do so hence podman must honor similar configuration in `--squash-all` behaviour if user wants to using cache. PS: We cannot alter behaviour of `podman build --squash` for docker-compat reasons hence this feature can be easily supported by `--squash-all`. Closes: containers/buildah#4011 Signed-off-by: Aditya R <arajan@redhat.com>
Current implementation of marking for re-use of cache
commits
on everystage
when used with--squashed
however we should try to re-use asmany layers are possible if
--layers
is specified andcommit
only onlast instruction
oflast stage
to perform final squash.Closes: #3665