fix monitoring daily backpressure
This commit is contained in:
@@ -344,20 +344,19 @@ func shutdownSchedulerMetricsServer(server *http.Server, logger interface {
|
||||
}
|
||||
|
||||
func monitoringDailyRunOptions(jobCtx internalscheduler.JobRunContext) tenantapp.MonitoringDailyTaskRunOptions {
|
||||
batchSize := 0
|
||||
maxDesktopDispatch := 0
|
||||
if jobCtx.Job != nil && jobCtx.Job.BatchSize != nil {
|
||||
batchSize = *jobCtx.Job.BatchSize
|
||||
maxDesktopDispatch = *jobCtx.Job.BatchSize
|
||||
}
|
||||
if batchSize <= 0 {
|
||||
batchSize = internalscheduler.AsInt(jobCtx.Config, "max_materialize_per_run", 0)
|
||||
if maxDesktopDispatch <= 0 {
|
||||
maxDesktopDispatch = internalscheduler.AsInt(jobCtx.Config, "max_desktop_dispatch_per_run", 0)
|
||||
}
|
||||
if batchSize <= 0 {
|
||||
batchSize = internalscheduler.AsInt(jobCtx.Config, "batch_size", 0)
|
||||
if maxDesktopDispatch <= 0 {
|
||||
maxDesktopDispatch = internalscheduler.AsInt(jobCtx.Config, "batch_size", 0)
|
||||
}
|
||||
return tenantapp.MonitoringDailyTaskRunOptions{
|
||||
MaxMaterializePerRun: batchSize,
|
||||
MaxMaterializePerPlan: internalscheduler.AsInt(jobCtx.Config, "max_materialize_per_plan", 0),
|
||||
MaxMaterializePerBrand: internalscheduler.AsInt(jobCtx.Config, "max_materialize_per_brand", 0),
|
||||
MaxDesktopDispatchPerRun: maxDesktopDispatch,
|
||||
MaxDesktopClientBacklog: internalscheduler.AsInt(jobCtx.Config, "max_desktop_client_backlog", 0),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,22 +59,29 @@ func TestSchedulerMetricsAuthMiddleware(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMonitoringDailyRunOptionsUsesJobBatchSize(t *testing.T) {
|
||||
func TestMonitoringDailyRunOptionsUsesJobBatchSizeForDesktopDispatchOnly(t *testing.T) {
|
||||
batchSize := 88
|
||||
got := monitoringDailyRunOptions(internalscheduler.JobRunContext{
|
||||
Job: &opsdomain.SchedulerJob{BatchSize: &batchSize},
|
||||
Config: map[string]any{
|
||||
"max_materialize_per_run": 999,
|
||||
"max_materialize_per_plan": 12,
|
||||
"max_materialize_per_brand": 4,
|
||||
"max_materialize_per_run": 999,
|
||||
"max_materialize_per_plan": 12,
|
||||
"max_materialize_per_brand": 4,
|
||||
"max_desktop_client_backlog": 6,
|
||||
},
|
||||
})
|
||||
|
||||
if got.MaxMaterializePerRun != 88 {
|
||||
t.Fatalf("MaxMaterializePerRun = %d, want 88", got.MaxMaterializePerRun)
|
||||
if got.MaxDesktopDispatchPerRun != 88 {
|
||||
t.Fatalf("MaxDesktopDispatchPerRun = %d, want 88", got.MaxDesktopDispatchPerRun)
|
||||
}
|
||||
if got.MaxMaterializePerPlan != 12 || got.MaxMaterializePerBrand != 4 {
|
||||
t.Fatalf("unexpected plan/brand options: %#v", got)
|
||||
if got.MaxMaterializePerPlan != 0 || got.MaxMaterializePerBrand != 0 {
|
||||
t.Fatalf("legacy plan/brand throttles should be ignored: %#v", got)
|
||||
}
|
||||
if got.MaxMaterializePerRun != 0 {
|
||||
t.Fatalf("batch_size must not throttle daily materialization: %#v", got)
|
||||
}
|
||||
if got.MaxDesktopClientBacklog != 6 {
|
||||
t.Fatalf("MaxDesktopClientBacklog = %d, want 6", got.MaxDesktopClientBacklog)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user