gitlab artifact caching doesn't work due to differences with project ID and build directories

Created on 28 August 2024, 6 months ago
Updated 10 September 2024, 6 months ago

Problem/Motivation

See discussion in https://drupal.slack.com/archives/CGKLP028K/p1724653387328039

CI_PROJECT_ID differs for core test runs depending on whether you're a core committer or not, so we can't use it to determine the target to fetch artifacts from.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
PHPUnitย  โ†’

Last updated 5 days ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @catch
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch
  • Merge request !9352Hard-code the project ID. โ†’ (Open) created by catch
  • Status changed to Needs review 6 months ago
  • Pipeline finished with Success
    6 months ago
    Total: 347s
    #266858
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch
  • Pipeline finished with Failed
    6 months ago
    #267605
  • First commit to issue fork.
  • Merge request !9366Resolve #3470641 "Non committer" โ†’ (Open) created by mstrelan
  • Pipeline finished with Success
    6 months ago
    Total: 534s
    #267720
  • Pipeline finished with Failed
    6 months ago
    #267774
  • Pipeline finished with Success
    6 months ago
    Total: 674s
    #267812
  • Pipeline finished with Success
    6 months ago
    Total: 684s
    #267829
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    As well as the project ID being different, we're also running into both the yarn lint and phpstan caches using absolute paths.

    Tried a rewrite as part of the pipeline process and it partially helps (i.e. phpstan fails to use the cache, but gives less criteria it failed by), but not enough:

    https://git.drupalcode.org/issue/drupal-3470641/-/jobs/2585012

    https://git.drupalcode.org/issue/drupal-3470641/-/jobs/2585008

    Possible workaround mentioned here is to use bind mounts:

    https://github.com/phpstan/phpstan/issues/8599#issuecomment-2059227168

    e.g. we'd bind mount the current directory to /tmp/build, cd, do the composer install + run the linting jobs there both for the cache warming job and for the individual linting jobs - that way everything runs in the same directory as far as yarn and phpstan are concerned.

    However to fully test that we'd need to commit the change to HEAD so that the cache warming job runs with the bind mount, then see what the effect on pipelines is after that. Can probably hack the API URLs to point to the pipeline instead of core just to make sure it doesn't break things, but not easy to demonstrate it actually works.

  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Tried a bind mount but the user in the pipeline doesn't have permission to create one. This might need some help from infrastructure, i.e. can our k8s runner setup allow the bind mount, or can we do something there to have a consistent directory name?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States cmlara

    Since weโ€™re on docker runners an over simplified possibility

    mkdir /build;
    cp -Ria $CI_BUILD_DIR /build
    cd /build
    <execute as normal>
    cp -Ria anything_you_need_to_archive $CI_PROJECT_DIR 
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Was talking a little about this with @catch at dc. I'm thinking we might be able to just run the stylelint jobs in a symlinked directory to make sure the paths are consistent.

    Something this simple might just work?

    ln -s $CI_PROJECT_DIR /build
    cd /build
    

    And then run caching, linters and such. This could consolidate cacheing dirs in the cache files and make it consistent everywhere. I want to see how that works locally, but internet here is not really being helpfull.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    cmlara was right on slack. Symlinks dont work.

  • Merge request !9623Resolve #3470641 "Copy solution" โ†’ (Open) created by bbrala
  • Pipeline finished with Failed
    5 months ago
    Total: 263s
    #293422
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Made a solution with the copy suggestion. After a full green run we need to analyse the files see if paths make sense.

  • Pipeline finished with Canceled
    5 months ago
    Total: 391s
    #293441
  • Pipeline finished with Failed
    5 months ago
    Total: 1147s
    #293451
  • Pipeline finished with Failed
    5 months ago
    #293501
  • Pipeline finished with Failed
    5 months ago
    #293502
  • Pipeline finished with Failed
    5 months ago
    #293509
  • Pipeline finished with Canceled
    5 months ago
    Total: 430s
    #293512
  • Pipeline finished with Canceled
    5 months ago
    Total: 522s
    #293511
  • Pipeline finished with Failed
    5 months ago
    Total: 546s
    #293520
  • Pipeline finished with Canceled
    5 months ago
    Total: 363s
    #293543
  • Pipeline finished with Canceled
    5 months ago
    Total: 421s
    #293550
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Think this should work. But cant get the cached artifacts to download from the issue fork project even after changing the project id. Not sure why.

    It also seems the artifacts key in gitlab ci does some magic where it actually finds the artifact/report in the current directory. Not sure how that is possible, but hey, im not complaining to not have to move files around.

    I think we should test the pipelines failing also, but im done for today. COuld use a review here.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    This looks like it should work.

    But cant get the cached artifacts to download from the issue fork project even after changing the project id.

    I think to test this, it would also be necessary to hack the lint warming job to run on MR pipelines (which it doesn't), so that it creates the artifacts in the first place.

    Left one suggestion on the MR to try to explain a bit more what's going on in the comment. Apart from that it looks good. Will be hard to be 100% confident that it's working until after we commit it unfortunately, but that's the nature of what we're fixing.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    You're up early hehe.

    Anyways, I did run the job on the 11.x branch in the issue fork. And I can download the artifacts from the UI. So perhaps if we change the urls of the caches to the normal Web ui urls instead of the api one we might be able to use those.

    I'll try that while working on your feedback. See if we can acultually validate.

  • Pipeline finished with Failed
    5 months ago
    Total: 684s
    #293913
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Ok, so i changed the URL of the download for cspell to a run on the 11.x branch in the same issue fork. That seems to have worked perfectly.

    https://git.drupalcode.org/issue/drupal-3470641/-/jobs/2875946

    Don't think i can prove this to work more than this. :) I'll revert the hard code.

  • Pipeline finished with Canceled
    5 months ago
    Total: 255s
    #294230
  • Pipeline finished with Failed
    5 months ago
    Total: 601s
    #294235
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nicoloye

    I reviewed the MR for Bjรถrn, we discussed about it at Drupalcon Barcelona 2024.
    Everything seems good to me!

    • catch โ†’ committed 8db24ab8 on 11.0.x
      Issue #3470641 by bbrala, catch, mstrelan, cmlara, nicoloye: gitlab...
    • catch โ†’ committed 0624b81e on 11.x
      Issue #3470641 by bbrala, catch, mstrelan, cmlara, nicoloye: gitlab...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Committed/pushed to 11.x and cherry-picked to 11.0.x, thanks!

    Doesn't cherry-pick cleanly to 10.4.x but I think we might want it there for the next couple of years of backport MRs.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands bbrala Netherlands

    Just got home cause of delays. Yay.

    But had to check: https://git.drupalcode.org/issue/drupal-3421014/-/jobs/2885532

    It did find cache here?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    https://git.drupalcode.org/issue/drupal-3421014/-/jobs/2885532 definitely found the cache:

    9538/15309 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php cached
     9539/15309 core/modules/system/tests/src/Kernel/Form/ElementsFieldsetTest.php cached
     9540/15309 core/modules/system/tests/src/Kernel/Form/FileElementTest.php cached
     9541/15309 core/modules/system/tests/src/Kernel/Form/FormElementLabelTest.php cached
     9542/15309 core/modules/system/tests/src/Kernel/Form/FormElementMaxlengthTest.php cached
     9543/15309 core/modules/system/tests/src/Kernel/Form/FormObjectTest.php cached
     9544/15309 core/modules/system/tests/src/Kernel/Form/ProgrammaticTest.php cached
    

    The output is very verbose, but had previously left it like that so we could verify that it's using the cache, which it wasn't until this issue got fixed!

Production build 0.71.5 2024