mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
phase56: keep rebuild contract non-executing
This commit is contained in:
1 parent
97504eab94
commit
4240d66b8c
3 files changed
+97
-1
No files matched your search
@@ -72,6 +72,9 @@ func (r AuthorityExecutorReconciler) Reconcile(ctx context.Context) (AuthorityEx
|
||||
for _, volume := range volumes {
|
||||
for _, contract := range volume.Status.ExecutorContracts {
|
||||
if contract.ActionType != ManagedVolumeActionReintegrateReturned {
|
||||
if contract.ExecutionEnabled || contract.MutationAllowed {
|
||||
result.UnsafeExecutionContractCount++
|
||||
}
|
||||
continue
|
||||
}
|
||||
result.ContractCount++
|
||||
|
||||
@@ -78,6 +78,52 @@ func TestAuthorityExecutorReconcilerRejectsUnsupportedMutationClass(t *testing.T
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthorityExecutorReconcilerIgnoresDisabledRebuildContractWithoutMutation(t *testing.T) {
|
||||
client := &fakeAuthorityExecutorClient{
|
||||
volumes: []SwBlockVolumeObject{authorityExecutorRebuildVolume(false, false)},
|
||||
eligibilities: []SwBlockReplicaEligibilityObject{{
|
||||
Ref: OperatorObjectRef{Namespace: "kube-system", Name: "rebuild-r1"},
|
||||
Spec: SwBlockReplicaEligibilitySpec{
|
||||
VolumeName: "rebuild",
|
||||
VolumeID: "pvc-rebuild",
|
||||
PVCName: "rebuild-pvc",
|
||||
ReplicaID: "r1",
|
||||
},
|
||||
}},
|
||||
}
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Namespace: "kube-system",
|
||||
Client: client,
|
||||
ExecutionRequested: true,
|
||||
ExecutionPolicyEnabled: true,
|
||||
AllowedMutationClass: AuthorityExecutorAllowedMutationAckEligibility,
|
||||
}).Reconcile(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: %v", err)
|
||||
}
|
||||
if result.VolumeCount != 1 ||
|
||||
result.ContractCount != 0 ||
|
||||
result.MutationAttemptCount != 0 ||
|
||||
result.AckEligibilityMutationAttempts != 0 ||
|
||||
len(client.writes) != 0 {
|
||||
t.Fatalf("result=%+v writes=%+v", result, client.writes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthorityExecutorReconcilerFailsClosedOnEnabledRebuildContract(t *testing.T) {
|
||||
client := &fakeAuthorityExecutorClient{volumes: []SwBlockVolumeObject{authorityExecutorRebuildVolume(true, false)}}
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Namespace: "kube-system",
|
||||
Client: client,
|
||||
}).Reconcile(context.Background())
|
||||
if err == nil {
|
||||
t.Fatalf("expected enabled rebuild contract to fail closed, result=%+v", result)
|
||||
}
|
||||
if result.UnsafeExecutionContractCount != 1 || result.MutationAttemptCount != 0 || len(client.writes) != 0 {
|
||||
t.Fatalf("result=%+v writes=%+v", result, client.writes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthorityExecutorReconcilerRejectsExecutionWhenPolicyDisabled(t *testing.T) {
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Client: &fakeAuthorityExecutorClient{},
|
||||
@@ -241,6 +287,45 @@ func authorityExecutorReadyVolume() SwBlockVolumeObject {
|
||||
}
|
||||
}
|
||||
|
||||
func authorityExecutorRebuildVolume(executionEnabled, mutationAllowed bool) SwBlockVolumeObject {
|
||||
return SwBlockVolumeObject{
|
||||
Ref: OperatorObjectRef{Namespace: "kube-system", Name: "rebuild"},
|
||||
Status: SwBlockVolumeCRDStatus{
|
||||
VolumeID: "pvc-rebuild",
|
||||
PVCName: "rebuild-pvc",
|
||||
ReplicaReintegrations: []SwBlockVolumeCRDReturnedReplica{{
|
||||
ReplicaID: "r1",
|
||||
State: ReturnedReplicaStateRecovering,
|
||||
ReasonCode: ReasonCandidateFrontierBehind,
|
||||
FrontendFenced: true,
|
||||
FrontendPrimaryReady: false,
|
||||
AckEligibilityKnown: true,
|
||||
AckEligible: false,
|
||||
DurableFrontierKnown: true,
|
||||
DurableFrontierLSN: 51,
|
||||
RequiredFrontierKnown: true,
|
||||
RequiredFrontierLSN: 52,
|
||||
EvidenceRefs: []string{"rebuild.txt"},
|
||||
}},
|
||||
ExecutorContracts: []SwBlockVolumeCRDExecutorContract{{
|
||||
ActionType: ManagedVolumeActionRebuildReturned,
|
||||
ReplicaID: "r1",
|
||||
Decision: ReturnedReplicaExecutorContractDisabled,
|
||||
Reason: ReturnedReplicaExecutorContractReasonExecutorDisabled,
|
||||
OwnerExecutor: "authority_recovery_executor",
|
||||
ExecutionEnabled: executionEnabled,
|
||||
MutationAllowed: mutationAllowed,
|
||||
PreflightDecision: ReturnedReplicaExecutorPreflightReady,
|
||||
PreflightReason: ReturnedReplicaExecutorPreflightReasonSatisfied,
|
||||
AllowedMutationClass: []string{"rebuild_traffic"},
|
||||
ForbiddenMutationClass: []string{"ack_eligibility", "frontend_publication", "failback"},
|
||||
TerminalEvidenceRequired: returnedReplicaTerminalEvidenceRequired(ManagedVolumeActionRebuildReturned),
|
||||
EvidenceRefs: []string{"rebuild-contract.txt"},
|
||||
}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func authorityExecutorTarget() SwBlockReplicaEligibilityObject {
|
||||
return SwBlockReplicaEligibilityObject{
|
||||
Ref: OperatorObjectRef{
|
||||
|
||||
@@ -94,7 +94,7 @@ Implementation:
|
||||
|
||||
### D3: Executor Non-Execution Gate
|
||||
|
||||
Status: pending.
|
||||
Status: implemented locally.
|
||||
|
||||
Prove the existing authority executor does not act on
|
||||
`authority.rebuild_returned_replica` yet:
|
||||
@@ -105,6 +105,14 @@ Prove the existing authority executor does not act on
|
||||
- no failback;
|
||||
- no cross-volume mutation.
|
||||
|
||||
Implementation:
|
||||
|
||||
- `AuthorityExecutorReconciler` ignores disabled non-ACK contracts without
|
||||
mutation.
|
||||
- If any unsupported/non-ACK contract is incorrectly marked
|
||||
`executionEnabled=true` or `mutationAllowed=true`, the reconciler fails
|
||||
closed through `UnsafeExecutionContractCount`.
|
||||
|
||||
## Verification
|
||||
|
||||
Current local checks:
|
||||
|
||||
Reference in new issue
Block a user