-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
clusterresolver: comply with A37 for handling errors from discovery mechanisms #6461
Changes from all commits
70d3e23
0065af2
649efc6
c4f49aa
4b1a54e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,13 +75,21 @@ func newDNSResolver(target string, topLevelResolver topLevelResolver, logger *gr | |
} | ||
u, err := url.Parse("dns:///" + target) | ||
if err != nil { | ||
topLevelResolver.onError(fmt.Errorf("failed to parse dns hostname %q in clusterresolver LB policy", target)) | ||
if ret.logger.V(2) { | ||
ret.logger.Infof("Failed to parse dns hostname %q in clusterresolver LB policy", target) | ||
} | ||
ret.updateReceived = true | ||
ret.topLevelResolver.onUpdate() | ||
return ret | ||
} | ||
|
||
r, err := newDNS(resolver.Target{URL: *u}, ret, resolver.BuildOptions{}) | ||
if err != nil { | ||
topLevelResolver.onError(fmt.Errorf("failed to build DNS resolver for target %q: %v", target, err)) | ||
if ret.logger.V(2) { | ||
ret.logger.Infof("Failed to build DNS resolver for target %q: %v", target, err) | ||
} | ||
ret.updateReceived = true | ||
ret.topLevelResolver.onUpdate() | ||
return ret | ||
} | ||
ret.dnsR = r | ||
|
@@ -142,7 +150,21 @@ func (dr *dnsDiscoveryMechanism) ReportError(err error) { | |
dr.logger.Infof("DNS discovery mechanism for resource %q reported error: %v", dr.target, err) | ||
} | ||
|
||
dr.topLevelResolver.onError(err) | ||
dr.mu.Lock() | ||
// If a previous good update was received, suppress the error and continue | ||
// using the previous update. If RPCs were succeeding prior to this, they | ||
// will continue to do so. Also suppress errors if we previously received an | ||
// error, since there will be no downstream effects of propagating this | ||
// error. | ||
if dr.updateReceived { | ||
dr.mu.Unlock() | ||
return | ||
} | ||
dr.addrs = nil | ||
dr.updateReceived = true | ||
dr.mu.Unlock() | ||
|
||
dr.topLevelResolver.onUpdate() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm ok. Will delete. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually being called in DNS Discovery Mechanism Construction errors, but as per the back and forth in chat I need to switch this to do same thing DNS errors before update do - create the priority and send TF down. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this in Discovery Mechanism Constructor same way as OnError - set updateReceived to true and then call onUpdate on the top level resolver. Let me know if you want to change the bool (I need to set it for lastUpdate() to return true). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What do you mean by this? I'm good with how it is looking now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the construction to also set this bool and trigger TF. Thus, I don't know if the naming is appropriate. Has it received an update, or is it just triggering an error? I'm fine leaving as is also though. |
||
} | ||
|
||
func (dr *dnsDiscoveryMechanism) NewAddress(addresses []resolver.Address) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably throw a warning log here and in the next error case. I would even be OK with an error log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep it consistent with the error logs already in codebase (from ReportError), switched to Info log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Log lines should be capitalized, unlike error strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting, noted. Switched.