Skip to content

Commit 9790d74

Browse files
committed
allocator: move isDecommissionAction to allocatorimpl
This commit refactors isDecommissionAction into allocatorimpl for consistency with other similar helpers like allocatorActions.{Add,Replace,Remove}. This change has no behavior changes but to make future commits easier.
1 parent 07233e1 commit 9790d74

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pkg/kv/kvserver/allocator/allocatorimpl/allocator.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ func (a AllocatorAction) Remove() bool {
163163
a == AllocatorRemoveDecommissioningNonVoter
164164
}
165165

166+
// Decommissioning indicates an action replacing or removing a decommissioning
167+
// replicas.
168+
func (a AllocatorAction) Decommissioning() bool {
169+
return a == AllocatorRemoveDecommissioningVoter ||
170+
a == AllocatorRemoveDecommissioningNonVoter ||
171+
a == AllocatorReplaceDecommissioningVoter ||
172+
a == AllocatorReplaceDecommissioningNonVoter
173+
}
174+
166175
// TargetReplicaType returns that the action is for a voter or non-voter replica.
167176
func (a AllocatorAction) TargetReplicaType() TargetReplicaType {
168177
var t TargetReplicaType

pkg/kv/kvserver/replicate_queue.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -923,19 +923,12 @@ func (rq *replicateQueue) processOneChange(
923923
}
924924

925925
func maybeAnnotateDecommissionErr(err error, action allocatorimpl.AllocatorAction) error {
926-
if err != nil && isDecommissionAction(action) {
926+
if err != nil && action.Decommissioning() {
927927
err = decommissionPurgatoryError{err}
928928
}
929929
return err
930930
}
931931

932-
func isDecommissionAction(action allocatorimpl.AllocatorAction) bool {
933-
return action == allocatorimpl.AllocatorRemoveDecommissioningVoter ||
934-
action == allocatorimpl.AllocatorRemoveDecommissioningNonVoter ||
935-
action == allocatorimpl.AllocatorReplaceDecommissioningVoter ||
936-
action == allocatorimpl.AllocatorReplaceDecommissioningNonVoter
937-
}
938-
939932
// shedLease takes in a leaseholder replica, looks for a target for transferring
940933
// the lease and, if a suitable target is found (e.g. alive, not draining),
941934
// transfers the lease away.

0 commit comments

Comments
 (0)