mirror of https://github.com/grpc/grpc-node.git
Add logging for DNS update delays due to rate limit or backoff
This commit is contained in:
parent
f1f8d1ba61
commit
10c4bbdbe3
|
@ -78,6 +78,11 @@ export class BackoffTimeout {
|
|||
* running is true.
|
||||
*/
|
||||
private startTime: Date = new Date();
|
||||
/**
|
||||
* The approximate time that the currently running timer will end. Only valid
|
||||
* if running is true.
|
||||
*/
|
||||
private endTime: Date = new Date();
|
||||
|
||||
constructor(private callback: () => void, options?: BackoffOptions) {
|
||||
if (options) {
|
||||
|
@ -100,6 +105,8 @@ export class BackoffTimeout {
|
|||
}
|
||||
|
||||
private runTimer(delay: number) {
|
||||
this.endTime = this.startTime;
|
||||
this.endTime.setMilliseconds(this.endTime.getMilliseconds() + this.nextDelay);
|
||||
clearTimeout(this.timerId);
|
||||
this.timerId = setTimeout(() => {
|
||||
this.callback();
|
||||
|
@ -178,4 +185,12 @@ export class BackoffTimeout {
|
|||
this.hasRef = false;
|
||||
this.timerId.unref?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the approximate timestamp of when the timer will fire. Only valid if
|
||||
* this.isRunning() is true.
|
||||
*/
|
||||
getEndTime() {
|
||||
return this.endTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,6 +353,11 @@ class DnsResolver implements Resolver {
|
|||
* fires. Otherwise, start resolving immediately. */
|
||||
if (this.pendingLookupPromise === null) {
|
||||
if (this.isNextResolutionTimerRunning || this.backoff.isRunning()) {
|
||||
if (this.isNextResolutionTimerRunning) {
|
||||
trace('resolution update delayed by "min time between resolutions" rate limit');
|
||||
} else {
|
||||
trace('resolution update delayed by backoff timer until ' + this.backoff.getEndTime().toISOString());
|
||||
}
|
||||
this.continueResolving = true;
|
||||
} else {
|
||||
this.startResolutionWithBackoff();
|
||||
|
|
|
@ -222,6 +222,7 @@ export class ResolvingLoadBalancer implements LoadBalancer {
|
|||
* In that case, the backoff timer callback will call
|
||||
* updateResolution */
|
||||
if (this.backoffTimeout.isRunning()) {
|
||||
trace('requestReresolution delayed by backoff timer until ' + this.backoffTimeout.getEndTime().toISOString());
|
||||
this.continueResolving = true;
|
||||
} else {
|
||||
this.updateResolution();
|
||||
|
|
Loading…
Reference in New Issue