Skip to content

Commit

Permalink
remove cancel reason for successfully finishing operator
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Aug 31, 2023
1 parent ba25af5 commit 5625b8e
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 5625b8e

Please sign in to comment.