Repository navigation
Mirror distfiles to Cloudflare on the fly when S3 credentials are present - #4404
Merged
Merged
Conversation
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
The 10 year old comment claims HTTPS didn't work when bootstrapping. If that was ever really true, it isn't true now. Our mirrors don't currently work, so many downloads will fall back to GitHub, which always redirects you to HTTPS. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
Including a URL apparently makes you more likely to be blocked, as this is typically done by bots. Gentoo has made the same change. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
chewi
force-pushed
the
chewi/distfiles-mirror
branch
from
November 25, 2026 23:08
338847b to
115c703
Compare
Copilot stopped reviewing on behalf of
chewi due to an error
November 25, 2026 23:08
chewi
force-pushed
the
chewi/distfiles-mirror
branch
from
November 25, 2026 23:19
115c703 to
57f33b3
Compare
Contributor
Author
There was a missing semicolon. I didn't notice because we use |
Contributor
Author
That really shouldn't fail. I'd rather stop at that point. |
krnowak
reviewed
Nov 26, 2026
Care is taken to not include the credentials in command line arguments
or write them to files.
If mirroring fails for any reason, such as the credentials not being
present because it's not CI, the script exits non-fatally. We don't want
it to break builds.
The requested URL is checked to ensure we don't upload something that we
just downloaded from the same mirror. That would be slow and expensive.
The downloaded file is checked against the Manifest file (BLAKE2B only)
before Portage does its own check to ensure we don't mirror a corrupted
file.
I tried to implement this as a Portage phase hook so that it would only
upload after Portage had checked against the Manifest, but I bumped into
the network sandbox. It was also awkward for other reasons.
Unlike before, files for the different Portage repositories are mirrored
together under the same distfiles directory. There is no benefit in
separating them, and this would incur a performance cost because Portage
would sometimes have to check more than one location to find the file.
Flatcar previously mirrored using the traditional flat layout with all
the files in a single directory. Gentoo now uses the filename-hash
layout, but this has little benefit over the flat layout when hosted on
Cloudflare R2. However, I have chosen the content-hash layout because it
handles different versions of files with the same filename, which could
be useful when maintaining several Flatcar release channels. The hosted
files are named with their digest rather than their regular filename,
but this shouldn't be an issue, as Portage does the translation. This
requires a distfiles/layout.conf file to be placed on the mirror. For
future reference, it looks like this:
[structure]
0=content-hash BLAKE2B 8
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
chewi
force-pushed
the
chewi/distfiles-mirror
branch
from
November 26, 2026 15:54
57f33b3 to
052753f
Compare
krnowak
approved these changes
Nov 27, 2026
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Care is taken to not include the credentials in command line arguments or write them to files.
If mirroring fails for any reason, such as the credentials not being present because it's not CI, the script exits non-fatally. We don't want it to break builds.
The requested URL is checked to ensure we don't upload something that we just downloaded from the same mirror. That would be slow and expensive.
The downloaded file is checked against the Manifest file (BLAKE2B only) before Portage does its own check to ensure we don't mirror a corrupted file.
I tried to implement this as a Portage phase hook so that it would only upload after Portage had checked against the Manifest, but I bumped into the network sandbox. It was also awkward for other reasons.
Unlike before, files for the different Portage repositories are mirrored together under the same distfiles directory. There is no benefit in separating them, and this would incur a performance cost because Portage would sometimes have to check more than one location to find the file.
Flatcar previously mirrored using the traditional flat layout with all the files in a single directory. Gentoo now uses the filename-hash layout, but this has little benefit over the flat layout when hosted on Cloudflare R2. However, I have chosen the content-hash layout because it handles different versions of files with the same filename, which could be useful when maintaining several Flatcar release channels. The hosted files are named with their digest rather than their regular filename, but this shouldn't be an issue, as Portage does the translation. This requires a distfiles/layout.conf file to be placed on the mirror. For future reference, it looks like this:
I have also:
See flatcar/jenkins-os#493 for the jenkins-os changes. I will only need to backport the rclone config file change to the other channels.
How to use
Build in CI with the chewi/rclone-env jenkins-os branch.
Testing done
I've done lots of builds locally and in CI, including this successful SDK build. The mirror is now fully populated for main.
changelog/directory (user-facing change, bug fix, security fix, update) -- N/A/bootand/usrsize, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.