qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	qemu-devel@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Beraldo Leal" <bleal@redhat.com>
Subject: Re: [RFC PATCH v3 1/1] gitlab: Use plain docker in container-template.yml
Date: Tue, 28 Feb 2023 10:03:57 +0000	[thread overview]
Message-ID: <Y/3RjeKCbA0u/FMq@redhat.com> (raw)
In-Reply-To: <87lekiyfr5.fsf@suse.de>

On Mon, Feb 27, 2023 at 06:12:30PM -0300, Fabiano Rosas wrote:
> Alex Bennée <alex.bennee@linaro.org> writes:
> 
> > Fabiano Rosas <farosas@suse.de> writes:
> >
> >> Our dockerfiles no longer reference layers from other qemu images so
> >> we can now use 'docker build' on them.
> >>
> >> Also reinstate the caching that was disabled due to bad interactions
> >> with certain runners. See commit 6ddc3dc7a8 ("tests/docker: don't use
> >> BUILDKIT in GitLab either"). We now believe those issues to be fixed.
> >>
> >> The COMMON_TAG needed to be fixed for the caching to work. The
> >> docker.py script was not using the variable, but constructing the
> >> correct URL directly.
> >>
> >> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> >> ---
> >>  .gitlab-ci.d/container-template.yml | 9 ++++-----
> >>  1 file changed, 4 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/.gitlab-ci.d/container-template.yml b/.gitlab-ci.d/container-template.yml
> >> index c434b9c8f3..519b8a9482 100644
> >> --- a/.gitlab-ci.d/container-template.yml
> >> +++ b/.gitlab-ci.d/container-template.yml
> >> @@ -6,17 +6,16 @@
> >>      - docker:dind
> >>    before_script:
> >>      - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
> >> -    - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/$NAME:latest"
> >> +    - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
> >>      - apk add python3
> >>      - docker info
> >>      - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
> >>    script:
> >>      - echo "TAG:$TAG"
> >>      - echo "COMMON_TAG:$COMMON_TAG"
> >> -    - ./tests/docker/docker.py --engine docker build
> >> -          -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
> >> -          -r $CI_REGISTRY/qemu-project/qemu
> >> -    - docker tag "qemu/$NAME" "$TAG"
> >> +    - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
> >> +      --build-arg BUILDKIT_INLINE_CACHE=1
> >> +      -f "tests/docker/dockerfiles/$NAME.docker" "."
> >
> > I wonder why this doesn't injest a bunch of context. If I run:
> >
> >   docker build --cache-from registry.gitlab.com/stsquad/qemu/qemu/debian-alpha-cross --build-arg BUILDKIT_INLINE_CACHE=1  --build-arg USER=alex --build-arg UID=1000 -t qemu
> >   /debian-alpha-cross -f "/home/alex/lsrc/qemu.git/tests/docker/dockerfiles/debian-alpha-cross.docker" .
> >
> > it attempts to bring my entire build directory in as build context. This
> > is why we use the - < docker form in the Makefile.
> >
> 
> I only see that without DOCKER_BUILDKIT=1. With the variable set it does
> like in the CI jobs. I presume it is being set automatically by gitlab,
> but we could add it to the script to be explicit.
> 
> >>      - docker push "$TAG"
> >>    after_script:
> >>      - docker logout
> >
> > So what I don't understand is if I do:
> >
> >   docker pull registry.gitlab.com/stsquad/qemu/qemu/debian-alpha-cross
> >   docker build --cache-from registry.gitlab.com/stsquad/qemu/qemu/debian-alpha-cross --build-arg
> >     BUILDKIT_INLINE_CACHE=1 -t qemu/debian-alpha-cross - <
> >     /home/alex/lsrc/qemu.git/tests/docker/dockerfiles/debian-alpha-cross.docker
> >
> > I still see pretty much a full rebuild of the image.
> 
> I don't use docker and podman does not support caching. I have
> fresh-installed docker today and indeed it seems to not use the cache at
> every build. We're missing something.

Empirically in gitlab I see it working as desired after applying this
patch. My first job building alpine container does all commands:

  https://gitlab.com/berrange/qemu/-/jobs/3845066410

My second job building alpine container uses the cache:

  https://gitlab.com/berrange/qemu/-/jobs/3845340414

IME of using this in libvirt the caching almost always did its job as
expected in gitlab.

IOW I wouldn't worry too much about local behaviour possibly differing.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  parent reply	other threads:[~2023-02-28 10:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 15:11 [RFC PATCH v3 0/1] ci: Speed up container stage Fabiano Rosas
2023-02-27 15:11 ` [RFC PATCH v3 1/1] gitlab: Use plain docker in container-template.yml Fabiano Rosas
2023-02-27 19:00   ` Alex Bennée
2023-02-27 19:39     ` Alex Bennée
2023-02-27 21:12     ` Fabiano Rosas
2023-02-27 21:18       ` Fabiano Rosas
2023-02-28 10:03       ` Daniel P. Berrangé [this message]
2023-02-28 10:23       ` Alex Bennée
2023-02-28 10:14   ` Daniel P. Berrangé
2023-02-28 10:29 ` [RFC PATCH v3 0/1] ci: Speed up container stage Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/3RjeKCbA0u/FMq@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=bleal@redhat.com \
    --cc=farosas@suse.de \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).