Skip to content

Commit 1fb0697

Browse files
authored
Make frontend drain traffic time configurable (#3934)
* Make frontend drain traffic time configurable
1 parent f332748 commit 1fb0697

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

common/dynamicconfig/constants.go

+2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ const (
202202
FrontendThrottledLogRPS = "frontend.throttledLogRPS"
203203
// FrontendShutdownDrainDuration is the duration of traffic drain during shutdown
204204
FrontendShutdownDrainDuration = "frontend.shutdownDrainDuration"
205+
// FrontendShutdownFailHealthcheckDuration is the duration of shutdown failure detection
206+
FrontendShutdownFailHealthcheckDuration = "frontend.shutdownFailHealthcheckDuration"
205207
// FrontendMaxBadBinaries is the max number of bad binaries in namespace config
206208
FrontendMaxBadBinaries = "frontend.maxBadBinaries"
207209
// SendRawWorkflowHistory is whether to enable raw history retrieving

service/frontend/service.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type Config struct {
8585
WorkerBuildIdSizeLimit dynamicconfig.IntPropertyFn
8686
DisallowQuery dynamicconfig.BoolPropertyFnWithNamespaceFilter
8787
ShutdownDrainDuration dynamicconfig.DurationPropertyFn
88+
ShutdownFailHealthcheckDuration dynamicconfig.DurationPropertyFn
8889

8990
MaxBadBinaries dynamicconfig.IntPropertyFnWithNamespaceFilter
9091

@@ -207,6 +208,7 @@ func NewConfig(dc *dynamicconfig.Collection, numHistoryShards int32, enableReadF
207208
BlobSizeLimitWarn: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.BlobSizeLimitWarn, 256*1024),
208209
ThrottledLogRPS: dc.GetIntProperty(dynamicconfig.FrontendThrottledLogRPS, 20),
209210
ShutdownDrainDuration: dc.GetDurationProperty(dynamicconfig.FrontendShutdownDrainDuration, 0*time.Second),
211+
ShutdownFailHealthcheckDuration: dc.GetDurationProperty(dynamicconfig.FrontendShutdownFailHealthcheckDuration, 10*time.Second),
210212
EnableNamespaceNotActiveAutoForwarding: dc.GetBoolPropertyFnWithNamespaceFilter(dynamicconfig.EnableNamespaceNotActiveAutoForwarding, true),
211213
SearchAttributesNumberOfKeysLimit: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.SearchAttributesNumberOfKeysLimit, 100),
212214
SearchAttributesSizeOfValueLimit: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.SearchAttributesSizeOfValueLimit, 2*1024),
@@ -336,11 +338,11 @@ func (s *Service) Stop() {
336338
// 1. Fail rpc health check, this will cause client side load balancer to stop forwarding requests to this node
337339
// 2. wait for failure detection time
338340
// 3. stop taking new requests by returning InternalServiceError
339-
// 4. Wait for a second
341+
// 4. Wait for X second
340342
// 5. Stop everything forcefully and return
341343

342-
requestDrainTime := util.Min(time.Second, s.config.ShutdownDrainDuration())
343-
failureDetectionTime := util.Max(0, s.config.ShutdownDrainDuration()-requestDrainTime)
344+
requestDrainTime := util.Max(time.Second, s.config.ShutdownDrainDuration())
345+
failureDetectionTime := util.Max(0, s.config.ShutdownFailHealthcheckDuration())
344346

345347
logger.Info("ShutdownHandler: Updating gRPC health status to ShuttingDown")
346348
s.healthServer.Shutdown()

0 commit comments

Comments
 (0)