-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Disk Manager] add RunSystemTasks to tasks config, run system tasks i…
…n controlplane only, clean up lister metrics when collectListerMetricsTask finishes
- Loading branch information
Showing
7 changed files
with
305 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package tasks | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
tasks_config "github.com/ydb-platform/nbs/cloud/tasks/config" | ||
"github.com/ydb-platform/nbs/cloud/tasks/metrics" | ||
tasks_storage "github.com/ydb-platform/nbs/cloud/tasks/storage" | ||
) | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
func RegisterSystemTasks( | ||
ctx context.Context, | ||
registry *Registry, | ||
storage tasks_storage.Storage, | ||
config *tasks_config.TasksConfig, | ||
tasksMetricsRegistry metrics.Registry, | ||
taskScheduler Scheduler, | ||
) error { | ||
|
||
err := registry.RegisterForExecution("tasks.Blank", func() Task { | ||
return &blankTask{} | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
endedTaskExpirationTimeout, err := time.ParseDuration( | ||
config.GetEndedTaskExpirationTimeout(), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
clearEndedTasksTaskScheduleInterval, err := time.ParseDuration( | ||
config.GetClearEndedTasksTaskScheduleInterval(), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = registry.RegisterForExecution("tasks.ClearEndedTasks", func() Task { | ||
return &clearEndedTasksTask{ | ||
storage: storage, | ||
expirationTimeout: endedTaskExpirationTimeout, | ||
limit: int(config.GetClearEndedTasksLimit()), | ||
} | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
taskScheduler.ScheduleRegularTasks( | ||
ctx, | ||
"tasks.ClearEndedTasks", | ||
TaskSchedule{ | ||
ScheduleInterval: clearEndedTasksTaskScheduleInterval, | ||
MaxTasksInflight: 1, | ||
}, | ||
) | ||
|
||
listerMetricsCollectionInterval, err := time.ParseDuration( | ||
config.GetListerMetricsCollectionInterval(), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = registry.RegisterForExecution( | ||
"tasks.CollectListerMetrics", func() Task { | ||
return &collectListerMetricsTask{ | ||
registry: tasksMetricsRegistry, | ||
storage: storage, | ||
metricsCollectionInterval: listerMetricsCollectionInterval, | ||
|
||
// This task is registered in control plane and collects metrics | ||
// for all types of tasks. | ||
taskTypes: registry.TaskTypes(), | ||
hangingTaskGaugesByID: make(map[string]metrics.Gauge), | ||
maxHangingTaskIDsToReport: config.GetMaxHangingTaskIDsToReport(), | ||
} | ||
}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
collectListerMetricsTaskScheduleInterval, err := time.ParseDuration( | ||
config.GetCollectListerMetricsTaskScheduleInterval(), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
taskScheduler.ScheduleRegularTasks( | ||
ctx, | ||
"tasks.CollectListerMetrics", | ||
TaskSchedule{ | ||
ScheduleInterval: collectListerMetricsTaskScheduleInterval, | ||
MaxTasksInflight: 1, | ||
}, | ||
) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.