Skip to content

Commit

Permalink
operator: remove cancel reason for successfully finishing operator (#…
Browse files Browse the repository at this point in the history
…7019)

close #4399

Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
rleungx and ti-chi-bot[bot] authored Aug 31, 2023
1 parent a0b2f3d commit bce3133
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 3 additions & 5 deletions pkg/schedule/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ var (
AdminStop CancelReasonType = "admin stop"
// NotInRunningState is the cancel reason when the operator is not in running state.
NotInRunningState CancelReasonType = "not in running state"
// Succeed is the cancel reason when the operator is finished successfully.
Succeed CancelReasonType = "succeed"
// Timeout is the cancel reason when the operator is timeout.
Timeout CancelReasonType = "timeout"
// Expired is the cancel reason when the operator is expired.
Expand Down Expand Up @@ -265,9 +263,9 @@ func (o *Operator) CheckSuccess() bool {
}

// Cancel marks the operator canceled.
func (o *Operator) Cancel(reason CancelReasonType) bool {
if _, ok := o.AdditionalInfos[cancelReason]; !ok {
o.AdditionalInfos[cancelReason] = string(reason)
func (o *Operator) Cancel(reason ...CancelReasonType) bool {
if _, ok := o.AdditionalInfos[cancelReason]; !ok && len(reason) != 0 {
o.AdditionalInfos[cancelReason] = string(reason[0])
}
return o.status.To(CANCELED)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/schedule/operator/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (oc *Controller) Dispatch(region *core.RegionInfo, source string, recordOpS
if op.ContainNonWitnessStep() {
recordOpStepWithTTL(op.RegionID())
}
if oc.RemoveOperator(op, Succeed) {
if oc.RemoveOperator(op) {
operatorCounter.WithLabelValues(op.Desc(), "promote-success").Inc()
oc.PromoteWaitingOperator()
}
Expand Down Expand Up @@ -544,8 +544,6 @@ func (oc *Controller) RemoveOperator(op *Operator, reasons ...CancelReasonType)
var cancelReason CancelReasonType
if len(reasons) > 0 {
cancelReason = reasons[0]
} else {
cancelReason = Unknown
}
if removed {
if op.Cancel(cancelReason) {
Expand Down

0 comments on commit bce3133

Please sign in to comment.