-
Notifications
You must be signed in to change notification settings - Fork 914
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
Refactor schedule type #967
Conversation
Many thanks to @dddddai , I'll look into it ASAP. |
These types were used to choose branches, I removed them since they are no longer needed karmada/pkg/scheduler/scheduler.go Line 406 in de55101
|
I'll check it later. |
/assign |
|
||
clusterPolicyName := util.GetLabelValue(clusterResourceBinding.Labels, policyv1alpha1.ClusterPropagationPolicyLabel) | ||
start := time.Now() | ||
if !helper.IsBindingReady(&rb.Status) { |
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.
hi, the Scheduled
condition is just to indicate that the ResourceBinding or ClusterResourceBinding has been scheduled once, not to indicate that the status of every scheduling process, right?
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.
Yes, please refer to #821 (comment), and I'm not sure if #988 meets what @RainbowMango said
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 is out of my expectation, I used to think that this condition is to indicate the status of every scheduling process. If first schedule, rescedule or scale schedule failed, it should be set to False
. For now, we will keep the schedule result of last success scheduling if reschedule failed. But for users, they don't know why schedule failed.
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.
/cc @RainbowMango Is it the expected behavior of this condition?
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.
We do need a condition to reflect the schedule failed state. I thought it might be too complicated, so we didn't handle the failed case in #821.
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.
uh-huh, it seems like the "First" schedule is a kind of special "Reschedule"
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.
Oh there is a problem: for example, if FailoverSchedule
failed, then Scheduled
condition would be false, then scheduler would regard it as FirstSchedule
whose behavior is different from FailoverSchedule
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.
How about to do it like:
func (s *Scheduler) doScheduleBinding(namespace, name string) error {
rb, err := s.bindingLister.ResourceBindings(namespace).Get(name)
if err != nil {
if apierrors.IsNotFound(err) {
// the binding does not exist, do nothing
return nil
}
return err
}
start := time.Now()
defer func() {
if err != nil {
// set "Scheduled" condition false
} else {
// set "Scheduled" condition true
}
}()
policyPlacement, policyPlacementStr, err := s.getPlacement(rb)
if err != nil {
return err
}
appliedPlacement := util.GetLabelValue(rb.Annotations, util.PolicyPlacementAnnotation)
if policyPlacementStr != appliedPlacement {
// policy placement changed, need reschedule
klog.Infof("Reschedule ResourceBinding(%s/%s) as placement changed", namespace, name)
err = s.scheduleResourceBinding(rb)
metrics.BindingSchedule(string(ReconcileSchedule), metrics.SinceInSeconds(start), err)
return err
}
Scheduled
condition is to indicate the schedule result of every schedule process. If schedule failed, we won't update the applied-placement annation, but will set the Scheduled
condition as false. The scheduler behavior will be consistent. The schedule will scheduleResourceBinding
once applied policy is not the same as current policy. Otherwise, perform failover schedule or scale schedule.
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.
Yeah, it sounds reasonable, i think we can get this one merged then do this job in #988
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.
Yeah, I agree
/lgtm |
c0872e0
to
de55101
Compare
Generally LGTM. |
Signed-off-by: dddddai <[email protected]>
Thanks! |
/approve We can get benefits from this path, like:
Thanks @dddddai. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango 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 |
Signed-off-by: dddddai [email protected]
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
As discussed with @RainbowMango at last meeting, it's not a good idea to branch by schedule types because it's tricky for us to extend scheduler behavior
Get ready for #829
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: