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

[resolver/dns] Allow configuration of dns resolution polling interval #3170

Closed
APTy opened this issue Nov 10, 2019 · 1 comment
Closed

[resolver/dns] Allow configuration of dns resolution polling interval #3170

APTy opened this issue Nov 10, 2019 · 1 comment
Labels
Type: Feature New features or improvements in behavior

Comments

@APTy
Copy link

APTy commented Nov 10, 2019

Use case(s) - what problem will this feature solve?

In cases where DNS is used by workloads for peer discovery, it may be necessary to make dynamic changes to allow traffic to flow from one failure domain to another. In such cases, the gRPC default polling interval of 30 minutes is too slow to allow for flexible traffic movement - it could instead be configurable for users who require more precise control over their traffic flow.

Proposed Solution

Extend resolver.BuildOption to include additional configuration.

type BuildOption struct {
    ...

    // PollingInterval is the minimum amount of time to wait
    // between name resolution attempts.
    PollingInterval time.Duration
}

This creates an implicit contract for Builder implementations to respect the provided configuration. Since I'm not familiar with what implementations of Builder exist beyond DNS, I'll defer to the maintainers to decide whether this is a good idea.

The usage would need to include some way to bubble this configuration up to the Client, for example:

func WithResolverPollingInterval(time.Duration) DialOption

This isn't a great API, but 🤷‍♂I'm open to suggestions.

Alternatives Considered

Extend internal/resolver/dns to expose additional constructor options and re-export them in resolver/dns.

type BuilderOption func(*dnsBuilder)

func WithPollingInterval(time.Duration)
func WithScheme(string)

func NewBuilder(...BuilderOption) resolver.Builder

Usage would be something like:

resolver.Register(dns.NewBuilder(
    dns.WithScheme("customdns"),
    dns.WithPollingInterval(time.Minute),
))

This approach is kind of nice because the polling configuration can be isolated to the dns package. On the other hand, users must Register() the custom Builder inside an init() function, which generally occurs before any configuration can been loaded, which creates a bit of an awkward API surface.

Thanks for your consideration!

@APTy APTy added the Type: Feature New features or improvements in behavior label Nov 10, 2019
@dfawley
Copy link
Member

dfawley commented Nov 11, 2019

We are removing polling entirely in #3165. DNS re-resolves any time any connection fails, and you can cause this to happen regularly by setting max connection age (https://godoc.org/google.golang.org/grpc/keepalive#ServerParameters).

For more discussion, see #1663 and grpc/grpc#12295.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

No branches or pull requests

2 participants