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

fix: don't override storage driver useragent if it's set #4195

Merged
merged 1 commit into from Dec 18, 2023

Conversation

milosgajdos
Copy link
Member

@milosgajdos milosgajdos commented Dec 18, 2023

We are overriding whatever value is set in the storage driver useragent config.

Let's.....NOT do that and only override it if it's not set.

PTAL @Jamstah @thaJeztah

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
Comment on lines +116 to +118
if storageParams["useragent"] == "" {
storageParams["useragent"] = fmt.Sprintf("distribution/%s %s", version.Version, runtime.Version())
}
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this was intentional 2dc1af1 (#1381) to address #1353

Is it correct to use the user-agent of the driver? (not the registry acting as client for s3)

Copy link
Member Author

Choose a reason for hiding this comment

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

I saw those PRs: my takeaway was it wasnt intended for debugging purposes, but that doesn't mean you shouldn't be able to set your own should you wish to do so.

This PR sets it to the "default" value unless the user explicitly requires a specific User-agent.

Say you run a commercial registry offering and want to distinguish your UA from the default one. How do you imagine doing that? (NOTE: I am not running any commercial service, just imagining a legitimate usecase)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, I should've looked more in-depth. I wasn't sure where storageParams["useragent"] could originate from, and if it could be initialised by the storage-driver itself (i.e., if the storage-driver itself would propagate it with (say) a blanket Amazon s3 client SDK). If that's not the case, then 💯 on not overriding it if it's set.

I'm curious though; is there a global config for this? It looks like it currently is required to be set for the selected storage driver (config.Storage.Parameters() returns config options for each driver, which feels ... odd (I would consider the application as a whole to use a specific user-agent)

Copy link
Member Author

Choose a reason for hiding this comment

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

To summarise the conversation I had with Seb offline:
He is suggesting creating a global configuration for useragent which can then be passed to individual storage drivers and used anywhere it might be needed.

That's a reasonable suggestion and I've made a new issue for it here: #4202

Copy link
Collaborator

@corhere corhere left a comment

Choose a reason for hiding this comment

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

I second @milosgajdos interpretation

@milosgajdos milosgajdos merged commit 35bda96 into distribution:main Dec 18, 2023
15 checks passed
@milosgajdos milosgajdos deleted the dont-override-useragent branch December 19, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config Related to registry config
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants