-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improve VTOrc config handling to support dynamic variables #17218
Changes from 1 commit
b3e4aec
85913d1
0a27ba8
c6c89fb
7b86cb3
1ab5cc3
ec2ef87
2121e16
0420ce5
897ab10
d20979b
d5923cd
7ef3b3b
6822752
8b1e52b
3a422fa
ed96f72
9f14d8b
b63d4f8
a939288
cb16b34
a9761f5
85fbc91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…nce poll seconds Signed-off-by: Manan Gupta <manan@planetscale.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,11 +73,6 @@ func init() { | |
}) | ||
} | ||
|
||
// used in several places | ||
func instancePollSecondsDuration() time.Duration { | ||
return time.Duration(config.Config.InstancePollSeconds) * time.Second | ||
} | ||
|
||
// acceptSighupSignal registers for SIGHUP signal from the OS to reload the configuration files. | ||
func acceptSighupSignal() { | ||
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. @GuptaManan100 double-checking: the 3rd party library handles 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. SIGHUP is not even required anymore. Viper has a watcher on the file, and if it changes, it automatically reloads the configurations. |
||
c := make(chan os.Signal, 1) | ||
|
@@ -161,7 +156,7 @@ func DiscoverInstance(tabletAlias string, forceDiscovery bool) { | |
defer func() { | ||
latency.Stop("total") | ||
discoveryTime := latency.Elapsed("total") | ||
if discoveryTime > instancePollSecondsDuration() { | ||
if discoveryTime > config.GetInstancePollTime() { | ||
instancePollSecondsExceededCounter.Add(1) | ||
log.Warningf("discoverInstance exceeded InstancePollSeconds for %+v, took %.4fs", tabletAlias, discoveryTime.Seconds()) | ||
if metric != nil { | ||
|
@@ -177,7 +172,7 @@ func DiscoverInstance(tabletAlias string, forceDiscovery bool) { | |
// Calculate the expiry period each time as InstancePollSeconds | ||
// _may_ change during the run of the process (via SIGHUP) and | ||
// it is not possible to change the cache's default expiry.. | ||
if existsInCacheError := recentDiscoveryOperationKeys.Add(tabletAlias, true, instancePollSecondsDuration()); existsInCacheError != nil && !forceDiscovery { | ||
if existsInCacheError := recentDiscoveryOperationKeys.Add(tabletAlias, true, config.GetInstancePollTime()); existsInCacheError != nil && !forceDiscovery { | ||
// Just recently attempted | ||
return | ||
} | ||
|
@@ -271,7 +266,7 @@ func onHealthTick() { | |
// nolint SA1015: using time.Tick leaks the underlying ticker | ||
func ContinuousDiscovery() { | ||
log.Infof("continuous discovery: setting up") | ||
recentDiscoveryOperationKeys = cache.New(instancePollSecondsDuration(), time.Second) | ||
recentDiscoveryOperationKeys = cache.New(config.GetInstancePollTime(), time.Second) | ||
|
||
go handleDiscoveryRequests() | ||
|
||
|
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.
This makes the field dynamic