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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion registry/handlers/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ func NewApp(ctx context.Context, config *configuration.Configuration) *App {
if storageParams == nil {
storageParams = make(configuration.Parameters)
}
storageParams["useragent"] = fmt.Sprintf("distribution/%s %s", version.Version, runtime.Version())
if storageParams["useragent"] == "" {
storageParams["useragent"] = fmt.Sprintf("distribution/%s %s", version.Version, runtime.Version())
}
Comment on lines +116 to +118
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


var err error
app.driver, err = factory.Create(app, config.Storage.Type(), storageParams)
Expand Down