Skip to content

ResolveImageConfig: Only fetch best matching config#4311

Merged
tonistiigi merged 1 commit intomoby:masterfrom
cpuguy83:one_platform_resolve
Oct 13, 2023
Merged

ResolveImageConfig: Only fetch best matching config#4311
tonistiigi merged 1 commit intomoby:masterfrom
cpuguy83:one_platform_resolve

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 commented Oct 5, 2023

Before this change, all platforms that loosely match the provided platform will be fetched even though we only care about 1 of them. As an example when linux/amd64 is requested it will also fetch linux/386 because it is a compatible architecture.
This means extra round trips to the registry, potentially even for content that doesn't exist in the remote.

This is especially a problem when resolve mode is prefer-local because we'll have the index locally but most likely only one manifest. In this case we'll end up reaching out to the registry to fetch the other manifests unncessarily.

With this change instead of fetching all matching platforms it chooses only the best matching platform.

Related: moby/moby#46584

@cpuguy83 cpuguy83 force-pushed the one_platform_resolve branch 2 times, most recently from ff5f785 to 6636bda Compare October 5, 2023 19:52
@thaJeztah
Copy link
Copy Markdown
Member

Some linting failures on receiver name.

Also a small typo in the commit message (ReolveImageConfig -> ResolveImageConfig

@cpuguy83 cpuguy83 force-pushed the one_platform_resolve branch from 6636bda to 230339f Compare October 5, 2023 22:01
@jedevc jedevc changed the title ReolveImageConfig: Only fetch best matching config ResolveImageConfig: Only fetch best matching config Oct 5, 2023
@thaJeztah
Copy link
Copy Markdown
Member

tentatively adding cherry pick label, but input welcome

@thaJeztah
Copy link
Copy Markdown
Member

@cpuguy83 compile error;

#29 133.7 util/imageutil/config_test.go:136:12: undefined: t (typecheck)

Comment thread util/imageutil/config.go Outdated
Comment thread util/imageutil/config.go Outdated
@cpuguy83 cpuguy83 force-pushed the one_platform_resolve branch from ebeda12 to 24a76c2 Compare October 10, 2023 16:37
Comment thread util/imageutil/config.go Outdated
} else {
descs = append(descs, index.Manifests...)
}
descs = append(descs, index.Manifests...)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

platform.Match condition should still be here. LimitManifests does not call Match and if we skip this it could lead to wrong resolution (eg. for nested indexes).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cpuguy83 @tonistiigi I've pushed an update to add this block back in to keep the original condition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry I totally missed this comment.

@cpuguy83 cpuguy83 force-pushed the one_platform_resolve branch from 24a76c2 to e17d488 Compare October 10, 2023 17:01
Before this change, all platforms that loosely match the provided
platform will be fetched even though we only care about 1 of them.
As an example when linux/amd64 is requested it will also fetch linux/386
because it is a compatible architecture.
This means extra round trips to the registry, potentially even for
content that doesn't exist in the remote.

This is especially a problem when resolve mode is prefer-local because
we'll have the index locally but most likely only one manifest.
In this case we'll end up reaching out to the registry to fetch the
other manifests unncessarily.

With this change instead of fetching all matching platforms it chooses
only the best matching platform.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@jedevc jedevc force-pushed the one_platform_resolve branch from e17d488 to 575cb10 Compare October 13, 2023 10:39
@jedevc jedevc requested a review from tonistiigi October 13, 2023 10:40
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.

7 participants