Skip to content

Add ability to sync specific architectures. #3128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

lukaszraczylo
Copy link

What type of PR is this?

Feature

Which issue does this PR fix:

Adds ability to specify the images architecture for mirroring.

What does this PR do / Why do we need it:

Instead of pulling 10s of GB of images for different architectures, you can now pull only architectures you use.

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Meh.

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

{
"prefix": "/repo4/**",
"tags": {
"excludeRegex": ".*-(amd64|arm64)$"
Copy link
Contributor

Choose a reason for hiding this comment

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

tag-based exclusion if platform info is in the image name?

Copy link
Author

Choose a reason for hiding this comment

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

I'd say "meh". Platform info in the image name does not mean anything to be honest. I've seen ( and even accidentally released myself ) quite a few images tagged with one platform declared as part of the tag and image itself / binaries within being different platform.

@rchincha
Copy link
Contributor

@lukaszraczylo thanks for your PR. This has been a long standing ask from the community.

@lukaszraczylo
Copy link
Author

@rchincha I'll work on the suggestions as well, and I'd PR it faster, but I'm using zotregistry for past two days :D

@rchincha
Copy link
Contributor

@rchincha I'll work on the suggestions as well, and I'd PR it faster, but I'm using zotregistry for past two days :D

If you able to test locally, you can iterate a lot quicker.
Also do take a look at the CI and failures to understand what would matter to get this PR merged.

@lukaszraczylo
Copy link
Author

@rchincha sorted. I also have an idea re: resources usage improvement, but I'll leave it for the next PR to not scope creep too much :)


// ParsePlatform parses a platform string into a Platform struct
// The string can be in the format "os/arch" or just "arch"
func ParsePlatform(platform string) Platform {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, instead of a nested map, it is a flat string with a '/' separator

@rchincha
Copy link
Contributor

@rchincha sorted. I also have an idea re: resources usage improvement, but I'll leave it for the next PR to not scope creep too much :)

Looking forward to that also.

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 14.92537% with 171 lines in your changes missing coverage. Please review.

Project coverage is 90.34%. Comparing base (06a0cd5) to head (3eecc29).

Files with missing lines Patch % Lines
pkg/extensions/sync/service.go 11.00% 95 Missing and 2 partials ⚠️
pkg/extensions/sync/destination.go 19.56% 71 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3128      +/-   ##
==========================================
- Coverage   90.79%   90.34%   -0.46%     
==========================================
  Files         172      172              
  Lines       32385    32577     +192     
==========================================
+ Hits        29405    29431      +26     
- Misses       2241     2403     +162     
- Partials      739      743       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lukaszraczylo
Copy link
Author

@rchincha I resolved all the issues / suggestions from what I see :) If anything else - I'll pick it up tomorrow

Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

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

Call this config-sync-platforms.json instead

Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

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

test/blackbox tests - just make one file right?

@lukaszraczylo
Copy link
Author

@rchincha that's done. Also rewrote the commit messages to adhere to the rules

Copy link
Contributor

@andaaron andaaron left a comment

Choose a reason for hiding this comment

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

@eusebiu-constantin-petu-dbk , please review this PR

@rchincha when sync-ing an index, do we want an exact copy, or a new index containing just a subset of the synced manifests? The image would contain invalid references in the 1st case, and digest would change in the 2nd case. There is also a 3rd option of saving the new content with the old digest, but I don't know what the implications would be, since it doesn't respect the content addressability.

}

func NewDestinationRegistry(
storeController storage.StoreController, // local store controller
tempStoreController storage.StoreController, // temp store controller
metaDB mTypes.MetaDB,
log log.Logger,
config ...*syncconf.RegistryConfig, // optional config for filtering
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this optional?

return err
}

manifestContent = updatedContent
Copy link
Contributor

Choose a reason for hiding this comment

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

Note this will break any referrer pointing to the original index digest.
Unless the same digest is kept in the filename, but a different one would be computed based on the new filename, are we doing this?


for _, spec := range platformSpecs {
parts := strings.Split(spec, "/")
if len(parts) == 2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Do we need to handle the variant here as well?
  2. Maybe we should have a platform method for matching against a different platform object (including partial matches in case filtering is done just for a subset of platform attributes of course)?

}

// shouldIncludeArchitecture determines if an architecture should be included in the sync
// DEPRECATED: Use shouldIncludePlatform instead
Copy link
Contributor

Choose a reason for hiding this comment

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

Why commit this code if it is deprecated?

if !service.shouldIncludePlatform(platform) {
platformDesc := platform.Architecture
if platform.OS != "" {
platformDesc = platform.OS + "/" + platform.Architecture
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Do we need to handle variant here?
  2. Maybe we should have a Platform method to return the os/arch/variant string for that instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants