-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schedule: move the logic of patrol region from coordinator to checkers #8428
Conversation
Signed-off-by: lhy1024 <admin@liudos.us>
/test pull-integration-realcluster-test |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8428 +/- ##
==========================================
- Coverage 77.40% 77.36% -0.05%
==========================================
Files 472 472
Lines 61796 61811 +15
==========================================
- Hits 47836 47820 -16
- Misses 10382 10430 +48
+ Partials 3578 3561 -17
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
Signed-off-by: lhy1024 <admin@liudos.us>
@@ -233,3 +417,39 @@ func (c *Controller) GetPauseController(name string) (*PauseController, error) { | |||
return nil, errs.ErrCheckerNotFound.FastGenByArgs() | |||
} | |||
} | |||
|
|||
// PatrolRegionContext is used to store the context of patrol regions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be used in the next pr, it may be more suitable to move it to the next pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the fields be part of the checker controller? Is it necessary to wrap it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is needed. It will contain more value and config in the future.
pd/pkg/schedule/checker/checker_controller.go
Lines 465 to 479 in ae0778f
type PatrolRegionContext struct { | |
syncutil.RWMutex | |
// config | |
interval time.Duration | |
workerCount int | |
scanLimit int | |
// status | |
patrolRoundStartTime time.Time | |
duration time.Duration | |
// workers | |
workersCtx context.Context | |
workersCancel context.CancelFunc | |
regionChan chan *core.RegionInfo | |
wg sync.WaitGroup | |
} |
// PatrolRegions is used to scan regions. | ||
// The checkers will check these regions to decide if they need to do some operations. | ||
func (c *Controller) PatrolRegions() { | ||
c.patrolRegionContext.init(c.cluster) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.patrolRegionContext.init(c.cluster) | |
patrolInterval := cluster.GetCheckerConfig().GetPatrolRegionInterval() | |
c.patrolRegionContext.init(patrolInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.cluster
is needed in updateTickerIfNeeded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init doesn't need it.
func (c *Controller) updateTickerIfNeeded(ticker *time.Ticker) { | ||
// Note: we reset the ticker here to support updating configuration dynamically. | ||
newInterval := c.cluster.GetCheckerConfig().GetPatrolRegionInterval() | ||
if c.patrolRegionContext.interval != newInterval { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keep it the same as before, just reset it every time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move it to patrolRegionContext?
interval time.Duration | ||
// status | ||
patrolRoundStartTime time.Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields are unnecessary IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to add a new commit, what do you think? Is it better to move both updateTickerIfNeeded
and roundUpdateMetrics
to the patrolRegion
function, would that make it too long?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: HuSharp, rleungx The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold |
/test pull-integration-realcluster-test |
Signed-off-by: lhy1024 <admin@liudos.us>
339d545
to
9784aac
Compare
/test pull-integration-realcluster-test |
Signed-off-by: lhy1024 <admin@liudos.us>
/retest-required |
/hold cancel |
What problem does this PR solve?
Issue Number: Ref #7963
What is changed and how does it work?
Check List
Tests
Release note