Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Sep 24, 2024
1 parent 8cd8825 commit bcd5018
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/schedule/checker/checker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ const (
)

var (
denyCheckersByLabelerCounter = labeler.LabelerEventCounter.WithLabelValues("checkers", "deny")
// WithLabelValues is a heavy operation, define variable to avoid call it every time.
pendingProcessedRegionsGauge = regionListGauge.WithLabelValues("pending_processed_regions")
priorityListGauge = regionListGauge.WithLabelValues("priority_list")
denyCheckersByLabelerCounter = labeler.LabelerEventCounter.WithLabelValues("checkers", "deny")
)

// Controller is used to manage all checkers.
Expand Down Expand Up @@ -85,7 +85,8 @@ type Controller struct {
// interval is the config interval of patrol regions.
// It's used to update the ticker, so we need to
// record it to avoid updating the ticker frequently.
interval time.Duration
interval time.Duration
// workerCount is the count of workers to patrol regions.
workerCount int
// patrolRegionScanLimit is the limit of regions to scan.
// It is calculated by the number of regions.
Expand Down Expand Up @@ -490,7 +491,6 @@ func (c *Controller) GetPauseController(name string) (*PauseController, error) {

// PatrolRegionContext is used to store the context of patrol regions.
type PatrolRegionContext struct {
// workers
workersCtx context.Context
workersCancel context.CancelFunc
regionChan chan *core.RegionInfo
Expand All @@ -503,9 +503,11 @@ func (p *PatrolRegionContext) init(ctx context.Context) {
}

func (p *PatrolRegionContext) stop() {
log.Debug("closing patrol region workers")
close(p.regionChan)
p.workersCancel()
p.wg.Wait()
log.Debug("patrol region workers are closed")
}

func (p *PatrolRegionContext) startPatrolRegionWorkers(c *Controller) {
Expand Down

0 comments on commit bcd5018

Please sign in to comment.