Skip to content

Commit

Permalink
feat: adds health check warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengYa-0110 authored and SongZhen0704 committed Dec 18, 2024
1 parent ca79fa8 commit 0efdb8d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/controller/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func Start(ctx context.Context, configPath, serverLogFile string, shared *server

isMasterController := IsMasterController(cfg)
if isMasterController {
router.SetInitStageForHealthChecker("MySQL migration")
router.SetInitStageForHealthChecker(router.StageMySQLMigration)
migrateMySQL(cfg)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func UpgradeVTapAgentConfig(db *gorm.DB) error {
}
newConfigs := make([]agentconf.MySQLAgentGroupConfiguration, 0)
for _, config := range configs {
if config.VTapGroupLcuuid == nil {
log.Infof("agent_group_configuration (lcuuid: %s) has no vtap_group_lcuuid", *config.Lcuuid)
continue
}
if _, ok := existedNewConfigInfo[*config.VTapGroupLcuuid]; ok {
log.Infof("agent_group_configuration (agent_group_lcuuid: %s) already exists", *config.VTapGroupLcuuid)
continue
Expand Down
12 changes: 10 additions & 2 deletions server/controller/http/router/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import (

var log = logger.MustGetLogger("router")

const OK = "ok"
const (
OK = "ok"

StageMySQLMigration = "MySQL migration"
)

var curStage string
var curStageStartedAt time.Time
Expand All @@ -46,8 +50,12 @@ func (s *Health) RegisterTo(e *gin.Engine) {
if curStage == OK {
JsonResponse(c, make(map[string]string), nil)
} else {
msg := fmt.Sprintf("server is in stage: %s now, time cost: %v", curStage, time.Since(curStageStartedAt))
curStageCost := time.Since(curStageStartedAt)
msg := fmt.Sprintf("server is in stage: %s now, time cost: %v", curStage, curStageCost)
log.Errorf(msg)
if curStage == StageMySQLMigration && curStageCost > 30*time.Second {
log.Warningf("MySQL migration is taking too long, please add initialDelaySeconds of server to wait for migration to complete")
}
JsonResponse(
c, make(map[string]string),
servicecommon.NewError(httpcommon.SERVICE_UNAVAILABLE, msg),
Expand Down

0 comments on commit 0efdb8d

Please sign in to comment.