You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2022/03/25 23:21:40 UTC
[GitHub] [yunikorn-core] pbacsko commented on a change in pull request #395: [YUNIKORN-1107] Make health check occur in the background
pbacsko commented on a change in pull request #395:
URL: https://github.com/apache/yunikorn-core/pull/395#discussion_r835663967
##########
File path: pkg/scheduler/health_checker.go
##########
@@ -20,14 +20,73 @@ package scheduler
import (
"fmt"
+ "time"
+ "go.uber.org/zap"
+
+ "github.com/apache/incubator-yunikorn-core/pkg/log"
"github.com/apache/incubator-yunikorn-core/pkg/scheduler/objects"
"github.com/apache/incubator-yunikorn-core/pkg/common/resources"
"github.com/apache/incubator-yunikorn-core/pkg/metrics"
"github.com/apache/incubator-yunikorn-core/pkg/webservice/dao"
)
+const defaultPeriod = 30 * time.Second
+
+type HealthChecker struct {
+ period time.Duration
+ stopChan chan struct{}
+}
+
+func NewHealthChecker() *HealthChecker {
+ return &HealthChecker{
+ period: defaultPeriod,
+ stopChan: make(chan struct{}),
+ }
+}
+
+// start execute healthCheck service in the background,
+func (c *HealthChecker) start(schedulerContext *ClusterContext) {
+ go func() {
+ ticker := time.NewTicker(c.period)
+ for {
+ select {
+ case <-c.stopChan:
+ ticker.Stop()
+ return
+ case <-ticker.C:
+ schedulerMetrics := metrics.GetSchedulerMetrics()
+ result := GetSchedulerHealthStatus(schedulerMetrics, schedulerContext)
+ UpdateSchedulerHealthStatusCache(result, schedulerContext)
+ if !result.Healthy {
+ log.Logger().Error("Scheduler is not healthy",
+ zap.Any("health check values", result.HealthChecks))
+ } else {
+ log.Logger().Info("Scheduler is healthy",
+ zap.Any("health check values", result.HealthChecks))
+ }
+ }
+ }
+ }()
+}
+
+//nolint:unused
+func (c *HealthChecker) stop() {
+ c.stopChan <- struct{}{}
+ close(c.stopChan)
+}
+
+func UpdateSchedulerHealthStatusCache(latest dao.SchedulerHealthDAOInfo, schedulerContext *ClusterContext) {
Review comment:
Is this method neet to be exported? (capital "u")
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@yunikorn.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org