ci: fix race on container image name

Message ID 20230802065404.3807143-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series ci: fix race on container image name |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/loongarch-compilation success Compilation OK
ci/intel-Functional success Functional PASS
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

David Marchand Aug. 2, 2023, 6:54 a.m. UTC
  We had a race on the container image name when the prepare job was
running a day before the build job was triggered.

Example:
- a prepare job generated image name on 2023/08/01:

  2023-08-01T23:59:32.9711845Z ++ date -u +%Y-%m-%d
  2023-08-01T23:59:32.9713485Z + echo image=image-fedora:37-2023-08-01

- a few seconds later, the build jobs later tried to use a different
  image name on 2023/08/02:

  2023-08-02T00:01:29.9103180Z ++ date -u +%Y-%m-%d
  2023-08-02T00:01:29.9113486Z + echo image=image-fedora:37-2023-08-02

Fix this by directly reusing the prepare job output.

Fixes: b35c4b0aa2bc ("ci: add Fedora 35 container in GHA")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 .github/workflows/build.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Aaron Conole Aug. 2, 2023, 12:44 p.m. UTC | #1
David Marchand <david.marchand@redhat.com> writes:

> We had a race on the container image name when the prepare job was
> running a day before the build job was triggered.
>
> Example:
> - a prepare job generated image name on 2023/08/01:
>
>   2023-08-01T23:59:32.9711845Z ++ date -u +%Y-%m-%d
>   2023-08-01T23:59:32.9713485Z + echo image=image-fedora:37-2023-08-01
>
> - a few seconds later, the build jobs later tried to use a different
>   image name on 2023/08/02:
>
>   2023-08-02T00:01:29.9103180Z ++ date -u +%Y-%m-%d
>   2023-08-02T00:01:29.9113486Z + echo image=image-fedora:37-2023-08-02
>
> Fix this by directly reusing the prepare job output.
>
> Fixes: b35c4b0aa2bc ("ci: add Fedora 35 container in GHA")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>

The dangers of dates... :-)
  
David Marchand Aug. 4, 2023, 1:02 p.m. UTC | #2
On Wed, Aug 2, 2023 at 2:44 PM Aaron Conole <aconole@redhat.com> wrote:
> David Marchand <david.marchand@redhat.com> writes:
>
> > We had a race on the container image name when the prepare job was
> > running a day before the build job was triggered.
> >
> > Example:
> > - a prepare job generated image name on 2023/08/01:
> >
> >   2023-08-01T23:59:32.9711845Z ++ date -u +%Y-%m-%d
> >   2023-08-01T23:59:32.9713485Z + echo image=image-fedora:37-2023-08-01
> >
> > - a few seconds later, the build jobs tried to use a different
> >   image name on 2023/08/02:
> >
> >   2023-08-02T00:01:29.9103180Z ++ date -u +%Y-%m-%d
> >   2023-08-02T00:01:29.9113486Z + echo image=image-fedora:37-2023-08-02
> >
> > Fix this by directly reusing the prepare job output.
> >
> > Fixes: b35c4b0aa2bc ("ci: add Fedora 35 container in GHA")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> Acked-by: Aaron Conole <aconole@redhat.com>

Applied, thanks.
  

Patch

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2c1eda9b18..7a2ac0ceee 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -148,6 +148,8 @@  jobs:
   prepare-container-images:
     name: ${{ join(matrix.config.*, '-') }}
     runs-on: ubuntu-latest
+    outputs:
+      image: ${{ steps.get_keys.outputs.image }}
 
     strategy:
       fail-fast: false
@@ -214,14 +216,13 @@  jobs:
       id: get_keys
       run: |
         echo 'ccache=ccache-${{ matrix.config.image }}-${{ matrix.config.compiler }}-'$(date -u +%Y-w%W) >> $GITHUB_OUTPUT
-        echo 'image=image-${{ matrix.config.image }}-'$(date -u +%Y-%m-%d) >> $GITHUB_OUTPUT
         echo 'logs=meson-logs-${{ join(matrix.config.*, '-') }}' | tr -d ':' >> $GITHUB_OUTPUT
     - name: Retrieve image cache
       id: image_cache
       uses: actions/cache@v3
       with:
         path: ~/.image
-        key: ${{ steps.get_keys.outputs.image }}
+        key: ${{ needs.prepare-container-images.outputs.image }}
     - name: Fail if no image (not supposed to happen)
       if: steps.image_cache.outputs.cache-hit != 'true'
       run: |