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

remote: ensure that client connection is not established twice #2501

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

tonistiigi
Copy link
Member

Because remote driver implements Info() by calling Client() internally, two instances on Client are created backed by separate TCP connection. This hack avoids it and improves performance.

Because remote driver implements Info() by calling
Client() internally, two instances on Client are created
backed by separate TCP connection. This hack avoids it
and improves performance.

Signed-off-by: Tonis Tiigi <[email protected]>
client.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
return d.Dial(ctx)
}),
client.WithTracerDelegate(delegated.DefaultExporter),
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 pretty 😬 , normally called by DriverHandle. Mostly weird as other drivers don't need to call it.

Copy link
Member

@crazy-max crazy-max Jun 6, 2024

Choose a reason for hiding this comment

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

But do not client.WithTracerDelegate already set as opt in:

func (d *Driver) Client(ctx context.Context, opts ...client.ClientOpt) (*client.Client, error) {
via
client.WithTracerDelegate(delegated.DefaultExporter),
?

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 how it works in regular mode and for other drivers. But for remote driver the call path can be that Info() is called that internally calls Client() (and that client is now cached). In that case no delegate is set up.

Maybe a possible solution would be to move ClientOpt as part of InitConfig

Copy link
Member

Choose a reason for hiding this comment

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

Maybe a possible solution would be to move ClientOpt as part of InitConfig

Ah right yeah that would be neat

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 still would mean that every driver would need to handle the ClientOpt and if they don't then at least the tracing would not work.

@thompson-shaun thompson-shaun added this to the v0.15.0 milestone Jun 6, 2024
@tonistiigi tonistiigi modified the milestones: v0.15.0, v0.16.0 Jun 6, 2024
@tonistiigi tonistiigi merged commit 4be2259 into docker:master Jul 2, 2024
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants