[SPARK-58002][INFRA] Refresh CI build images on a schedule#57083
[SPARK-58002][INFRA] Refresh CI build images on a schedule#57083nchammas wants to merge 2 commits into
Conversation
|
cc @zhengruifeng and @dongjoon-hyun, since they have recently managed this infrastructure. |
|
I think the idea makes sense. We probably don't want actions from other repos to push to our docker cache, so we can't just add This won't update the images for branches other than The workflow should be really fast if the cache is hit, which means even if we do it daily, we won't lose 1 hr every day just to build the docker images (correct me if I'm wrong here because we probably need to readjust the frequency). |
|
Amusingly, we just so happened to push a recent commit that triggered a refresh of the images, so the builds are now fast again. 0fea5ee Once In any case, is there anyone else you'd like to get a review from, @gaogaotiantian, or is this PR good to go? |
| # scheduled rebuild, the cache goes stale between Dockerfile changes | ||
| # and every commit on every PR spends ~50 minutes building base images! | ||
| schedule: | ||
| - cron: '0 4 * * *' |
There was a problem hiding this comment.
I think it is a good idea, but I feel it might be too often, maybe a weekly refresh is enough?
I asked AI to analyze the frequency:
Actual run history on master (from the GitHub Actions API)
108 runs over the last ~13 months (2025-06-03 → 2026-07-07; older runs are aged out by GitHub's ~400-day API retention). All 108 were push-triggered — confirming no scheduled refresh.
┌─────────────────────────────────┬───────────┐
│ Metric │ Value │
├─────────────────────────────────┼───────────┤
│ Avg runs/month │ ~8.3 │
├─────────────────────────────────┼───────────┤
│ Median gap between runs │ ~1 day │
├─────────────────────────────────┼───────────┤
│ Mean gap │ ~3.7 days │
...
There was a problem hiding this comment.
I'm fine with any frequency (the PR actually started with a weekly schedule). But I think it's nice to have the predictability of a daily refresh vs. depending on updates to the Dockerfiles to trigger the workflow.
With a weekly refresh schedule, if we somehow happen to have a long period of time where no updates are made to the images, that means potentially accepting the ~50 minute image builds on every change to every PR for up to a week.
Another, more sophisticated, approach we could take is to persist the version of ubuntu:noble we last built against, run the job hourly, but only rebuild images if we see the version has changed. But that requires persisting the last seen version somewhere, perhaps in a repo variable.
And to reiterate an earlier suggestion, we could eliminate the need for regular refreshes and solve the problem of surprise rebuilds being needed on every PR by simply pinning all of our uses of ubuntu:noble to a specific version. Is it that important that we always be running the latest version of noble? If not, pinning the version would be the best solution.
There was a problem hiding this comment.
I think it's fine to run it daily because it would be super cheap if we don't need to update the cache. It basically costs us nothing. If we run it weekly it means we could lose a lot of minutes during the week just to build the image.
|
@gaogaotiantian which branches should we merge this PR? are those CI already decoupled by branch? |
What changes were proposed in this pull request?
Rebuild the various images used on CI on a schedule.
The schedule is set to once a day.
Why are the changes needed?
All of our CI build images are based on
ubuntu:noble. They are only refreshed if we push changes to the Dockerfiles onmaster.spark/.github/workflows/build_infra_images_cache.yml
Lines 31 to 48 in d386172
On the other hand, however,
ubuntu:nobleis updated roughly once a month:This means that there are several updates to the base image that we have not incorporated. So when CI runs, it cannot pull from an existing cache and has to build the images from scratch. This takes about 50 minutes! With an up-to-date cache, this drops down to ~1 minute.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
I tested this with a change to
build_and_test.ymlon one of my branches, but I believe the correct fix is to ensure the that the base images are refreshed on a schedule.Was this patch authored or co-authored using generative AI tooling?
No.