Skip to content

gitlab ci: Rework how mirrors are configured#39939

Merged
kwryankrattiger merged 1 commit intospack:developfrom
scottwittenburg:ci-refactor-mirror-usage
Oct 19, 2023
Merged

gitlab ci: Rework how mirrors are configured#39939
kwryankrattiger merged 1 commit intospack:developfrom
scottwittenburg:ci-refactor-mirror-usage

Conversation

@scottwittenburg
Copy link
Copy Markdown
Contributor

@scottwittenburg scottwittenburg commented Sep 12, 2023

Improve how mirrors are used in gitlab ci, where we have until now thought of them as only a string. This PR aims to catch gitlab ci up to where the rest of spack is, in terms of mirror configuration.

By configuring ci mirrors ahead of time using the proposed mirror templates, and by taking advantage of the expressiveness that spack now has for mirrors, this PR will allow us to easily switch the protocol/url we use for fetching binary dependencies.

This PR also:

  • Adds three mirror templates which, assuming some variable replacement, should account for all the ways we use mirrors in ci.
  • Deprecates complicated (and likely somehow wrong) mirror management logic from the ci module.
  • Deprecates temporary storage and artifacts buildcache functionality from gitlab pipeline schema.
  • Deprecates --buildcache-destination and --copy-to options from the spack ci generate command.

Still TODO:

  • create a spackbot PR to set the PIPELINE_MIRROR_TEMPLATE appropriately for "rebuild everything" pipelines (done here)
  • add backwards compatibility for things the community is actually using
  • set up cloudfront for s3://spack-binaries-prs (and fix urls in mirror templates)
  • to avoid generating pipelines from stale indices, tell cloudfront not to cache binary indices (done in buildcache: Tell servers not to cache index or hash #40339)
  • solve problem where already cached things ignore re-writing origin objects with CacheContent: no-cache headers
    • For develop mirror,I think we can write a script to issue cache invalidations for the existing index files, followed immediately by updating the index using the CacheContent: no-cache header. Since caching only happens on client requests, we should not have to worry about the PR mirrors as long as we merge buildcache: Tell servers not to cache index or hash #40339 before this.

@spackbot-app spackbot-app bot added binary-packages commands core PR affects Spack core functionality gitlab Issues related to gitlab integration tests General test capability(ies) labels Sep 12, 2023
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

fyi @kwryankrattiger @zackgalbreath I finally made this PR from the branch I've been using to test fetching from cloudfront in pipelines.

I'm still not sure how we bust the cache managed by cloudfront when we:

  • prune specs from mirrors (didn't come up in my testing)
  • update buildcache index in between pipelines (didn't come up in my testing where every pipeline was a "rebuild everything")

@kwryankrattiger
Copy link
Copy Markdown
Contributor

For the first point, I agree we need to investigate more. I can imagine some edge cases where it would be problematic and pipelines would fail where a spec hash left existence two weeks earlier, and was reintroduced via a reversion or something on a PR that was depending on the old cached binary. I can't think of a case where it would break develop pipelines though, but maybe you have some ideas.

For the second one I am less concerned about the growing mirror case. In the worst case it will schedule redundant jobs and then do nothing when it finds the binary in the cache. It isn't ideal, but it shouldn't break pipelines which I think is the most important. And if we are getting a huge speed bump in fetch times with CF, the cost of extra scheduled jobs may be outweighed. That may be something worth measuring and/or annotating in the database so we can compare how many jobs like that are getting scheduled and how long they are taking to run. It may be that CF causes a significant overhead.

In the case where things are removed from the index, I think that follows the first point.

@scottwittenburg
Copy link
Copy Markdown
Contributor Author

If it's possible to avoid caching at all for certain patterns (.+index.json$ or similar), I wonder if that would solve both points?

@scottwittenburg scottwittenburg force-pushed the ci-refactor-mirror-usage branch 3 times, most recently from 91c7aa9 to 7ca2028 Compare October 6, 2023 22:04
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

Fixed one issue caught by testing in staging.

@scottwittenburg scottwittenburg force-pushed the ci-refactor-mirror-usage branch from 7ca2028 to e0e669a Compare October 6, 2023 22:37
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

Used an old PR on spack-test/spack to test the proposed changes to spackbot (to make sure we can still "rebuild everything"). It's here.

The proof that it worked is, e.g., here, where you can see that instead of the usual three mirrors you'd expect for a PR pipeline, there's just the one, and it corresponds to the PR-specific version.

@scottwittenburg scottwittenburg force-pushed the ci-refactor-mirror-usage branch from e0e669a to abb3f89 Compare October 13, 2023 00:19
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

I did some more testing of the various flavors of pipeline in my side repo, which uncovered a couple of issues I have now fixed.

  • PR pipeline rebuilding only what changed (readline in build_systems)
  • PR pipeline rebuilding everything (triggered from here)
  • a develop pipeline rebuilding only what changed
  • a "develop snapshot" pipeline (copy-only)
  • a release branch pipeline (rebuild everything)
  • a release tag pipeline (copy-only)

All those were run with some extra WIP commits to:

  • build many fewer specs in each stack
  • change all the mirror urls to point away from production mirrors
  • comment out the id_tokens bits so we could fall back on aws credentials from ci variables

@scottwittenburg scottwittenburg force-pushed the ci-refactor-mirror-usage branch from abb3f89 to 855ebeb Compare October 13, 2023 18:39
@scottwittenburg scottwittenburg force-pushed the ci-refactor-mirror-usage branch from 855ebeb to 6437443 Compare October 16, 2023 18:02
Copy link
Copy Markdown
Contributor

@kwryankrattiger kwryankrattiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to verify the stacks have removed the mirror section, but having the old mirror listed also shouldn't hurt anything.

# TODO: Remove this block in Spack 0.23
mirrors_to_check = None
if remote_mirror_override:
if deprecated_mirror_config and remote_mirror_override:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it makes sense to disable this based on the deprecated_mirror_config flag since it is still a CLI option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to modify the mirror state unless the user didn't use the new approach of adding a mirror named buildcache-destination and instead used that command line option. Did I get that logic wrong?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option --buildcache-destination can still be specified without error, even in the new method. I think either this should be an error earlier saying we don't support both, or this specific override method should be allowed even in the new mode.

I didn't comment on the other mirror gymnastics we were doing because those were sort of magic from the outside world perspective.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm leaning toward an error saying we don't support both at the same time, unless you object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is also my inclination, having both active at the same time feels odd.

@scottwittenburg scottwittenburg force-pushed the ci-refactor-mirror-usage branch from 6437443 to 5cd8765 Compare October 18, 2023 17:35
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
@scottwittenburg scottwittenburg force-pushed the ci-refactor-mirror-usage branch from 5cd8765 to b614035 Compare October 18, 2023 23:17
Copy link
Copy Markdown
Contributor

@kwryankrattiger kwryankrattiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks @scottwittenburg !

@kwryankrattiger kwryankrattiger merged commit 46c1a8e into spack:develop Oct 19, 2023
@scottwittenburg scottwittenburg deleted the ci-refactor-mirror-usage branch October 19, 2023 16:43
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Oct 23, 2023
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
victoria-cherkas pushed a commit to victoria-cherkas/spack that referenced this pull request Oct 30, 2023
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Nov 2, 2023
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
gabrielctn pushed a commit to gabrielctn/spack that referenced this pull request Nov 24, 2023
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Dec 14, 2023
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 11, 2024
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 31, 2024
Improve how mirrors are used in gitlab ci, where we have until now thought
of them as only a string.

By configuring ci mirrors ahead of time using the proposed mirror templates,
and by taking advantage of the expressiveness that spack now has for mirrors,
this PR will allow us to easily switch the protocol/url we use for fetching
binary dependencies.

This change also deprecates some gitlab functionality and marks it for
removal in Spack 0.23:

    - arguments to "spack ci generate":
        * --buildcache-destination
        * --copy-to
    - gitlab configuration options:
        * enable-artifacts-buildcache
        * temporary-storage-url-prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

binary-packages commands core PR affects Spack core functionality documentation Improvements or additions to documentation don't-merge-yet gitlab Issues related to gitlab integration shell-support tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants