Skip to content
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

operatror_controller:remove redundant logic introduced by #6427 #8696

Open
AndreMouche opened this issue Oct 12, 2024 · 1 comment · May be fixed by #8697
Open

operatror_controller:remove redundant logic introduced by #6427 #8696

AndreMouche opened this issue Oct 12, 2024 · 1 comment · May be fixed by #8697
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@AndreMouche
Copy link
Member

Enhancement Task

the following logic was redundant since #6427
we could remove L469~L470

if op.SchedulerKind() == OpAdmin || op.IsLeaveJointStateOperator() {
continue

from the follow part:

for _, op := range ops {
region := oc.cluster.GetRegion(op.RegionID())
if region == nil {
log.Debug("region not found, cancel add operator",
zap.Uint64("region-id", op.RegionID()))
operatorCounter.WithLabelValues(op.Desc(), "not-found").Inc()
return false, RegionNotFound
}
if region.GetRegionEpoch().GetVersion() != op.RegionEpoch().GetVersion() ||
region.GetRegionEpoch().GetConfVer() != op.RegionEpoch().GetConfVer() {
log.Debug("region epoch not match, cancel add operator",
zap.Uint64("region-id", op.RegionID()),
zap.Reflect("old", region.GetRegionEpoch()),
zap.Reflect("new", op.RegionEpoch()))
operatorCounter.WithLabelValues(op.Desc(), "epoch-not-match").Inc()
return false, EpochNotMatch
}
if oldi, ok := oc.operators.Load(op.RegionID()); ok && oldi.(*Operator) != nil && !isHigherPriorityOperator(op, oldi.(*Operator)) {
old := oldi.(*Operator)
log.Debug("already have operator, cancel add operator",
zap.Uint64("region-id", op.RegionID()),
zap.Reflect("old", old))
operatorCounter.WithLabelValues(op.Desc(), "already-have").Inc()
return false, AlreadyExist
}
if op.Status() != CREATED {
log.Error("trying to add operator with unexpected status",
zap.Uint64("region-id", op.RegionID()),
zap.String("status", OpStatusToString(op.Status())),
zap.Reflect("operator", op), errs.ZapError(errs.ErrUnexpectedOperatorStatus))
failpoint.Inject("unexpectedOperator", func() {
panic(op)
})
operatorCounter.WithLabelValues(op.Desc(), "unexpected-status").Inc()
return false, NotInCreateStatus
}
if !isPromoting && oc.wopStatus.getCount(op.Desc()) >= oc.config.GetSchedulerMaxWaitingOperator() {
log.Debug("exceed max return false", zap.Uint64("waiting", oc.wopStatus.getCount(op.Desc())), zap.String("desc", op.Desc()), zap.Uint64("max", oc.config.GetSchedulerMaxWaitingOperator()))
operatorCounter.WithLabelValues(op.Desc(), "exceed-max-waiting").Inc()
return false, ExceedWaitLimit
}
if op.SchedulerKind() == OpAdmin || op.IsLeaveJointStateOperator() {
continue
}
}

@AndreMouche AndreMouche added the type/enhancement The issue or PR belongs to an enhancement. label Oct 12, 2024
@AndreMouche AndreMouche changed the title operatror_controller: operatror_controller:remove redundant logic introduced by #6427 Oct 12, 2024
@lhy1024
Copy link
Contributor

lhy1024 commented Oct 16, 2024

why is it redundant? Would you like to say more details?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants