ci: label docker images and prune dangling images selectively #27793

pull stickies-v wants to merge 2 commits into bitcoin:master from stickies-v:ci-label-images changing 1 files +7 −0
  1. stickies-v commented at 10:46 AM on May 31, 2023: contributor

    Follow-up from #27777 (review).

    Labeling the docker images produced by the CI allows us/the user to apply batch operations to all images (including dangling ones) produced by the ci without affecting other, non-bitcoin-ci images. With labeling, we can safely always prune dangling bitcoin-ci-test images without checking for RESTART_CI_DOCKER_BEFORE_RUN, which we enable on our persistent runners.

  2. DrahtBot commented at 10:46 AM on May 31, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK fanquake
    Concept ACK Sjors, hebasto, pablomartin4btc

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  3. DrahtBot added the label Tests on May 31, 2023
  4. Sjors commented at 8:00 AM on June 6, 2023: member

    Concept ACK. Haven't tested.

    It would also be nice to have an incantation (e.g. in the help) to kill dangling images after CI failure / interruption (if you don't plan on running it again).

  5. DrahtBot added the label Needs rebase on Jun 12, 2023
  6. stickies-v force-pushed on Jun 12, 2023
  7. stickies-v commented at 1:19 PM on June 12, 2023: contributor

    Rebased to address merge conflict from #27844.

    It would also be nice to have an incantation (e.g. in the help) to kill dangling images after CI failure / interruption (if you don't plan on running it again).

    Thanks, added doc: ci: add instructions for pruning dangling images manually

  8. DrahtBot removed the label Needs rebase on Jun 12, 2023
  9. fanquake commented at 1:46 PM on June 30, 2023: member

    Concept ACK

  10. DrahtBot added the label Needs rebase on Jul 28, 2023
  11. stickies-v force-pushed on Jul 28, 2023
  12. stickies-v commented at 3:53 PM on July 28, 2023: contributor

    Rebased to address merge conflict from #28138.

  13. DrahtBot removed the label Needs rebase on Jul 28, 2023
  14. DrahtBot added the label Needs rebase on Aug 3, 2023
  15. stickies-v force-pushed on Aug 4, 2023
  16. stickies-v commented at 10:24 AM on August 4, 2023: contributor

    Rebased to address merge conflict from #28161.

  17. in ci/README.md:33 in 44b36af11d outdated
      25 | @@ -26,6 +26,13 @@ To run the test stage with a specific configuration,
      26 |  FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh
      27 |  ```
      28 |  
      29 | +The ci automatically prunes all dangling docker images every time it runs. If you want to perform
      30 | +the cleanup manually (e.g. if you won't be running the ci again), you can run
      31 | +
      32 | +```sh
      33 | +docker image prune --force --filter "label=bitcoin-ci-test"
    


    maflcko commented at 10:41 AM on August 4, 2023:

    I think if one wants to not run the CI again, they'll need to use rm instead of prune, no? The goal of prune is to only remove dangling/stale/intermediate image layers?


    stickies-v commented at 10:59 AM on August 4, 2023:

    Yeah, would you prefer it like this?

    diff --git a/ci/README.md b/ci/README.md
    index ab5e6ce866..16310b7703 100644
    --- a/ci/README.md
    +++ b/ci/README.md
    @@ -26,13 +26,19 @@ To run the test stage with a specific configuration,
     FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh
     ```
     
    -The ci automatically prunes all dangling docker images every time it runs. If you want to perform
    -the cleanup manually (e.g. if you won't be running the ci again), you can run
    +The ci automatically prunes all dangling (i.e. unused) docker images every time it runs. To do this
    +manually, run
     
     ```sh
     docker image prune --force --filter "label=bitcoin-ci-test"
     ```
     
    +To also remove the used images (e.g. if you're not planning on running the ci again), run
    +
    +```sh
    +docker rmi -f $(docker images -q -a --filter "label=bitcoin-ci-test")
    +```
    +
     ### Configurations
     
     The test files (`FILE_ENV`) are constructed to test a wide range of
    
    

    maflcko commented at 3:29 PM on August 14, 2023:

    Yeah, would you prefer it like this?

    No preference. Currently it is wrong, so you'll have to remove it, or fix it, or close this pull.

  18. DrahtBot removed the label Needs rebase on Aug 4, 2023
  19. hebasto commented at 3:26 PM on August 14, 2023: member

    Concept ACK.

  20. stickies-v force-pushed on Aug 15, 2023
  21. stickies-v commented at 9:34 PM on August 15, 2023: contributor

    Force pushed to update documentation addressing this review comment.

  22. DrahtBot added the label CI failed on Aug 16, 2023
  23. in ci/README.md:36 in 0fe9b99874 outdated
      31 | +
      32 | +```sh
      33 | +docker image prune --force --filter "label=bitcoin-ci-test"
      34 | +```
      35 | +
      36 | +To also remove the used images (e.g. if you're not planning on running the ci again), run
    


    maflcko commented at 6:10 AM on August 16, 2023:

    this isn't enough. Volumes also exist


    stickies-v commented at 8:45 AM on August 16, 2023:

    Thanks Dropped the README.md commit, don't feel like spending more time on this. @Sjors feel free to follow up if you think it's important.

  24. stickies-v force-pushed on Aug 16, 2023
  25. stickies-v force-pushed on Aug 16, 2023
  26. maflcko commented at 9:24 AM on August 17, 2023: member

    Could rebase for green CI, if still relevant?

  27. stickies-v force-pushed on Aug 17, 2023
  28. DrahtBot removed the label CI failed on Aug 17, 2023
  29. DrahtBot added the label Needs rebase on Aug 24, 2023
  30. stickies-v force-pushed on Aug 24, 2023
  31. stickies-v commented at 2:31 PM on August 24, 2023: contributor

    Rebased to address merge conflict from #27976.

  32. DrahtBot removed the label Needs rebase on Aug 24, 2023
  33. pablomartin4btc commented at 3:46 AM on October 9, 2023: member

    Concept ACK.

    Perhaps description needs to be updated regarding the user instructions (ci/README.md).

  34. stickies-v commented at 9:17 AM on October 9, 2023: contributor

    Perhaps description needs to be updated regarding the user instructions (ci/README.md).

    Thanks, reverted that description.

  35. DrahtBot added the label Needs rebase on Oct 13, 2023
  36. stickies-v closed this on Oct 13, 2023

  37. stickies-v commented at 9:07 AM on October 13, 2023: contributor

    Closed, not an essential change and doesn't seem like there's sufficient interest.

  38. in ci/test/04_install.sh:30 in be99d4d764 outdated
      27 | @@ -26,9 +28,9 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
      28 |    if [ -n "${RESTART_CI_DOCKER_BEFORE_RUN}" ] ; then
      29 |      echo "Restart docker before run to stop and clear all containers started with --rm"
      30 |      podman container stop --all  # Similar to "systemctl restart docker"
      31 | -    echo "Prune all dangling images"
      32 | -    docker image prune --force
    


    maflcko commented at 9:11 AM on October 13, 2023:

    Maybe keep this, just to be safe, in case the label stuff doesn't work? (For example from a previous run when labels weren't set) :sweat_smile:


    stickies-v commented at 10:29 AM on October 13, 2023:

    Makes sense, especially the migration aspect which I didn't think about. Added a comment that it can probably be removed in the future, though.

  39. maflcko commented at 9:11 AM on October 13, 2023: member

    lgtm, after the nit

  40. ci: add label to docker images
    This allows us or the user to perform batch operations on all
    images produced by the ci, e.g. to prune all dangling images,
    without affecting non-ci images.
    ce1699706e
  41. ci: always prune all dangling bitcoin-ci-test images
    Since all bitcoin-ci-test images are now labeled, we can always
    prune all dangling images, regardless of whether we are in
    RESTART_CI_DOCKER_BEFORE_RUN.
    
    To be safe, still prune all images if RESTART_CI_DOCKER_BEFORE_RUN
    in case the filtering doesn't work, or if images were created on
    an earlier version that did not assign labels.
    e44c574650
  42. stickies-v reopened this on Oct 13, 2023

  43. stickies-v force-pushed on Oct 13, 2023
  44. stickies-v commented at 10:31 AM on October 13, 2023: contributor

    Force-pushed to address merge conflict from #28547 and incorporate suggestion from maflcko to keep the unfiltered pruning for now, as belt and suspenders approach.

  45. DrahtBot removed the label Needs rebase on Oct 13, 2023
  46. fanquake approved
  47. fanquake commented at 8:48 AM on October 15, 2023: member

    utACK e44c574650827f18e12ac0ba378c0a19d23a07b4

  48. DrahtBot requested review from Sjors on Oct 15, 2023
  49. DrahtBot requested review from hebasto on Oct 15, 2023
  50. DrahtBot requested review from pablomartin4btc on Oct 15, 2023
  51. fanquake merged this on Oct 15, 2023
  52. fanquake closed this on Oct 15, 2023

  53. stickies-v deleted the branch on Oct 15, 2023
  54. Frank-GER referenced this in commit 991767f1c2 on Oct 21, 2023
  55. bitcoin locked this on Oct 14, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me