All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch
@ 2021-02-15 19:28 Philippe Mathieu-Daudé
  2021-02-16  6:55 ` Thomas Huth
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-02-15 19:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Daniel P. Berrangé, Philippe Mathieu-Daudé,
	Richard Henderson, Wainer dos Santos Moschetta, Alex Bennée

While we are interested in building docker images in different
branches, it only makes sense to push 'latest' to the registry
when this is the project default branch (usually 'master').

Else when pushing different branches concurrently we might have
inconsistent image state between branches.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 .gitlab-ci.d/containers.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml
index 90fac85ce46..52a915f4141 100644
--- a/.gitlab-ci.d/containers.yml
+++ b/.gitlab-ci.d/containers.yml
@@ -17,7 +17,7 @@
           -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
           -r $CI_REGISTRY_IMAGE
     - docker tag "qemu/$NAME" "$TAG"
-    - docker push "$TAG"
+    - test "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" && docker push "$TAG"
   after_script:
     - docker logout
   rules:
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch
  2021-02-15 19:28 [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch Philippe Mathieu-Daudé
@ 2021-02-16  6:55 ` Thomas Huth
  2021-02-16  7:05   ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Huth @ 2021-02-16  6:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Alex Bennée, Richard Henderson, Daniel P. Berrangé,
	Wainer dos Santos Moschetta

On 15/02/2021 20.28, Philippe Mathieu-Daudé wrote:
> While we are interested in building docker images in different
> branches, it only makes sense to push 'latest' to the registry
> when this is the project default branch (usually 'master').
> 
> Else when pushing different branches concurrently we might have
> inconsistent image state between branches.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   .gitlab-ci.d/containers.yml | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml
> index 90fac85ce46..52a915f4141 100644
> --- a/.gitlab-ci.d/containers.yml
> +++ b/.gitlab-ci.d/containers.yml
> @@ -17,7 +17,7 @@
>             -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
>             -r $CI_REGISTRY_IMAGE
>       - docker tag "qemu/$NAME" "$TAG"
> -    - docker push "$TAG"
> +    - test "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" && docker push "$TAG"

So does that mean that the following stages in the CI (i.e. build, test) are 
only always (i.e. also for the non-master branches) going to use containers 
that have been build on the master branch?

  Thomas



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch
  2021-02-16  6:55 ` Thomas Huth
@ 2021-02-16  7:05   ` Philippe Mathieu-Daudé
  2021-02-16  9:52     ` Daniel P. Berrangé
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-02-16  7:05 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: Alex Bennée, Richard Henderson, Daniel P. Berrangé,
	Wainer dos Santos Moschetta

On 2/16/21 7:55 AM, Thomas Huth wrote:
> On 15/02/2021 20.28, Philippe Mathieu-Daudé wrote:
>> While we are interested in building docker images in different
>> branches, it only makes sense to push 'latest' to the registry
>> when this is the project default branch (usually 'master').
>>
>> Else when pushing different branches concurrently we might have
>> inconsistent image state between branches.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>   .gitlab-ci.d/containers.yml | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml
>> index 90fac85ce46..52a915f4141 100644
>> --- a/.gitlab-ci.d/containers.yml
>> +++ b/.gitlab-ci.d/containers.yml
>> @@ -17,7 +17,7 @@
>>             -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
>>             -r $CI_REGISTRY_IMAGE
>>       - docker tag "qemu/$NAME" "$TAG"
>> -    - docker push "$TAG"
>> +    - test "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" && docker push
>> "$TAG"
> 
> So does that mean that the following stages in the CI (i.e. build, test)
> are only always (i.e. also for the non-master branches) going to use
> containers that have been build on the master branch?

Hmm good point. Should we use "$CI_COMMIT_BRANCH" instead of "latest"?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch
  2021-02-16  7:05   ` Philippe Mathieu-Daudé
@ 2021-02-16  9:52     ` Daniel P. Berrangé
  2021-02-16 10:37       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel P. Berrangé @ 2021-02-16  9:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Richard Henderson, Thomas Huth, Alex Bennée, qemu-devel,
	Wainer dos Santos Moschetta

On Tue, Feb 16, 2021 at 08:05:09AM +0100, Philippe Mathieu-Daudé wrote:
> On 2/16/21 7:55 AM, Thomas Huth wrote:
> > On 15/02/2021 20.28, Philippe Mathieu-Daudé wrote:
> >> While we are interested in building docker images in different
> >> branches, it only makes sense to push 'latest' to the registry
> >> when this is the project default branch (usually 'master').
> >>
> >> Else when pushing different branches concurrently we might have
> >> inconsistent image state between branches.
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >> ---
> >>   .gitlab-ci.d/containers.yml | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml
> >> index 90fac85ce46..52a915f4141 100644
> >> --- a/.gitlab-ci.d/containers.yml
> >> +++ b/.gitlab-ci.d/containers.yml
> >> @@ -17,7 +17,7 @@
> >>             -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
> >>             -r $CI_REGISTRY_IMAGE
> >>       - docker tag "qemu/$NAME" "$TAG"
> >> -    - docker push "$TAG"
> >> +    - test "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" && docker push
> >> "$TAG"
> > 
> > So does that mean that the following stages in the CI (i.e. build, test)
> > are only always (i.e. also for the non-master branches) going to use
> > containers that have been build on the master branch?
> 
> Hmm good point. Should we use "$CI_COMMIT_BRANCH" instead of "latest"?

This doesn't work because git branch names are not guaranteed to be
valid docker tag names. Please see my thread here:

  https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg03535.html

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 :|



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch
  2021-02-16  9:52     ` Daniel P. Berrangé
@ 2021-02-16 10:37       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-02-16 10:37 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Richard Henderson, Thomas Huth, Alex Bennée, qemu-devel,
	Wainer dos Santos Moschetta

On 2/16/21 10:52 AM, Daniel P. Berrangé wrote:
> On Tue, Feb 16, 2021 at 08:05:09AM +0100, Philippe Mathieu-Daudé wrote:
>> On 2/16/21 7:55 AM, Thomas Huth wrote:
>>> On 15/02/2021 20.28, Philippe Mathieu-Daudé wrote:
>>>> While we are interested in building docker images in different
>>>> branches, it only makes sense to push 'latest' to the registry
>>>> when this is the project default branch (usually 'master').
>>>>
>>>> Else when pushing different branches concurrently we might have
>>>> inconsistent image state between branches.
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>> ---
>>>>   .gitlab-ci.d/containers.yml | 2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml
>>>> index 90fac85ce46..52a915f4141 100644
>>>> --- a/.gitlab-ci.d/containers.yml
>>>> +++ b/.gitlab-ci.d/containers.yml
>>>> @@ -17,7 +17,7 @@
>>>>             -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
>>>>             -r $CI_REGISTRY_IMAGE
>>>>       - docker tag "qemu/$NAME" "$TAG"
>>>> -    - docker push "$TAG"
>>>> +    - test "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" && docker push
>>>> "$TAG"
>>>
>>> So does that mean that the following stages in the CI (i.e. build, test)
>>> are only always (i.e. also for the non-master branches) going to use
>>> containers that have been build on the master branch?
>>
>> Hmm good point. Should we use "$CI_COMMIT_BRANCH" instead of "latest"?
> 
> This doesn't work because git branch names are not guaranteed to be
> valid docker tag names. Please see my thread here:
> 
>   https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg03535.html

Indeed this thread describes the problem I am having. I'll see if there
are follow up on your thread.

Another way of fixing this is to find a way to only allow 1 pipeline at
a time. I haven't tried it yet because I don't like the idea of making
CI slower, but this is still better than debugging inconsistent
pipelines when Docker images are rebuilt.

Regards,

Phil.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-16 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 19:28 [PATCH] gitlab-ci: Only push Docker 'latest' image when building default branch Philippe Mathieu-Daudé
2021-02-16  6:55 ` Thomas Huth
2021-02-16  7:05   ` Philippe Mathieu-Daudé
2021-02-16  9:52     ` Daniel P. Berrangé
2021-02-16 10:37       ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.