Skip to content
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

optimize checking for current digest #1665

Merged
merged 2 commits into from Dec 12, 2022
Merged

Conversation

pkwarren
Copy link
Member

@pkwarren pkwarren commented Dec 9, 2022

If the current digest has the same image ID as the image to push, we can greatly speed up looking through every tag (which may contain multiple duplicates - potentially one per version/revision of a plugin). This should greatly speed up the lookup in the case where the plugin already exists on the OCI registry.

If the current digest has the same image ID as the image to push, we can
greatly speed up looking through every tag (which may contain multiple
duplicates - potentially one per version/revision of a plugin). This
should greatly speed up the lookup in the case where the plugin already
exists on the OCI registry.
@@ -376,7 +384,19 @@ func findExistingDigestForImageID(ctx context.Context, plugin *bufpluginconfig.C
return "", err
}
auth := &authn.Basic{Username: authConfig.Username, Password: authConfig.Password}
tags, err := remote.List(repo, remote.WithContext(ctx), remote.WithAuth(auth))
remoteOpts := []remote.Option{remote.WithContext(ctx), remote.WithAuth(auth)}
// First attempt to see if the current image digest matches the image ID
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a lot faster in the case of the image already existing in the BSR with the same digest as before. It only has to check one digest (the current one) and not potentially search through dozens of tags.

@pkwarren pkwarren merged commit 8985c1b into main Dec 12, 2022
@pkwarren pkwarren deleted the pkw/check-current-digest-first branch December 12, 2022 16:59
Monirul1 pushed a commit to Monirul1/buf that referenced this pull request Apr 30, 2023
If the current digest has the same image ID as the image to push, we can
greatly speed up looking through every tag (which may contain multiple
duplicates - potentially one per version/revision of a plugin). This
should greatly speed up the lookup in the case where the plugin already
exists on the OCI registry.
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.

None yet

2 participants