mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
phase54: connect authority executor ack call-site
This commit is contained in:
1 parent
9aa031ce18
commit
de2d7080ae
10 files changed
+707
-49
No files matched your search
@@ -136,10 +136,6 @@ func runOpsAuthorityExecutor(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stderr, "sw-block ops authority-executor: returned-replica execution is disabled by product policy reason=%s mutation_attempts=0 ack_eligibility_mutation_attempts=0\n", ops.AuthorityExecutorBlockedPolicyDisabled)
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
if enableExecution {
|
||||
fmt.Fprintf(stderr, "sw-block ops authority-executor: ACK eligibility mutation target is not implemented reason=%s mutation_attempts=0 ack_eligibility_mutation_attempts=0\n", ops.AuthorityExecutorBlockedMutationTargetMissing)
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
runOnce := func() int {
|
||||
client, err := opsAuthorityExecutorClientFactory()
|
||||
if err != nil {
|
||||
@@ -162,18 +158,30 @@ func runOpsAuthorityExecutor(args []string, stdout, stderr io.Writer) int {
|
||||
}
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
fmt.Fprintf(stdout, "authority_executor=disabled namespace=%s volumes=%d contracts=%d disabled_contracts=%d blocked_contracts=%d terminal_evidence_required=%d allowed_mutation_class=%s execution_requested=%t execution_policy_enabled=%t mutation_attempts=%d ack_eligibility_mutation_attempts=%d mutation_allowed=false\n",
|
||||
status := "disabled"
|
||||
if enableExecution && result.MutationAttemptCount > 0 && result.BlockedReason != "" {
|
||||
status = "partial"
|
||||
} else if enableExecution && result.MutationAttemptCount > 0 {
|
||||
status = "executed"
|
||||
} else if enableExecution && result.BlockedReason != "" {
|
||||
status = "blocked"
|
||||
}
|
||||
fmt.Fprintf(stdout, "authority_executor=%s namespace=%s volumes=%d contracts=%d disabled_contracts=%d blocked_contracts=%d terminal_evidence_required=%d terminal_evidence_missing=%d ack_eligibility_target_missing=%d allowed_mutation_class=%s execution_requested=%t execution_policy_enabled=%t mutation_attempts=%d ack_eligibility_mutation_attempts=%d mutation_allowed=%t storage_mutation_allowed=false\n",
|
||||
status,
|
||||
namespace,
|
||||
result.VolumeCount,
|
||||
result.ContractCount,
|
||||
result.DisabledContractCount,
|
||||
result.BlockedContractCount,
|
||||
result.TerminalEvidenceRequiredCount,
|
||||
result.TerminalEvidenceMissingCount,
|
||||
result.AckEligibilityTargetMissingCount,
|
||||
allowedMutationClass,
|
||||
enableExecution,
|
||||
executionPolicyEnabled,
|
||||
result.MutationAttemptCount,
|
||||
result.AckEligibilityMutationAttempts)
|
||||
result.AckEligibilityMutationAttempts,
|
||||
result.MutationAttemptCount > 0)
|
||||
return ops.VolumeStatusExitOK
|
||||
}
|
||||
if interval <= 0 {
|
||||
|
||||
@@ -564,15 +564,70 @@ func TestOpsAuthorityExecutorRejectsUnsupportedMutationClass(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOpsAuthorityExecutorExecutionPolicyBlocksWhenAckTargetMissing(t *testing.T) {
|
||||
client := &lifecycleOwnerTestClient{
|
||||
volumes: []ops.SwBlockVolumeObject{{
|
||||
Ref: ops.OperatorObjectRef{
|
||||
APIVersion: ops.SwBlockVolumeAPIVersion,
|
||||
Kind: ops.SwBlockVolumeKind,
|
||||
Namespace: "kube-system",
|
||||
Name: "returned",
|
||||
},
|
||||
Status: ops.SwBlockVolumeCRDStatus{
|
||||
VolumeID: "pvc-1",
|
||||
PVCName: "demo",
|
||||
ReplicaReintegrations: []ops.SwBlockVolumeCRDReturnedReplica{{
|
||||
ReplicaID: "r1",
|
||||
State: ops.ReturnedReplicaStateFenced,
|
||||
ReasonCode: ops.ReasonReturnedReplicaFrontendFenced,
|
||||
FrontendFenced: true,
|
||||
FrontendPrimaryReady: false,
|
||||
AckEligibilityKnown: true,
|
||||
AckEligible: false,
|
||||
DurableFrontierKnown: true,
|
||||
DurableFrontierLSN: 52,
|
||||
RequiredFrontierKnown: true,
|
||||
RequiredFrontierLSN: 52,
|
||||
}},
|
||||
ExecutorContracts: []ops.SwBlockVolumeCRDExecutorContract{{
|
||||
ActionType: ops.ManagedVolumeActionReintegrateReturned,
|
||||
ReplicaID: "r1",
|
||||
Decision: ops.ReturnedReplicaExecutorContractDisabled,
|
||||
Reason: ops.ReturnedReplicaExecutorContractReasonExecutorDisabled,
|
||||
OwnerExecutor: "authority_recovery_executor",
|
||||
ExecutionEnabled: false,
|
||||
MutationAllowed: false,
|
||||
PreflightDecision: ops.ReturnedReplicaExecutorPreflightReady,
|
||||
PreflightReason: ops.ReturnedReplicaExecutorPreflightReasonSatisfied,
|
||||
AllowedMutationClass: []string{ops.AuthorityExecutorAllowedMutationAckEligibility},
|
||||
ForbiddenMutationClass: []string{"frontend_publication", "rebuild_traffic", "failback"},
|
||||
}},
|
||||
},
|
||||
}},
|
||||
}
|
||||
oldFactory := opsAuthorityExecutorClientFactory
|
||||
opsAuthorityExecutorClientFactory = func() (ops.AuthorityExecutorClient, error) {
|
||||
return client, nil
|
||||
}
|
||||
t.Cleanup(func() { opsAuthorityExecutorClientFactory = oldFactory })
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
code := run([]string{"ops", "authority-executor", "--enable-execution", "--execution-policy"}, &stdout, &stderr)
|
||||
if code != ops.VolumeStatusExitInvalid {
|
||||
if code != ops.VolumeStatusExitOK {
|
||||
t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String())
|
||||
}
|
||||
if !strings.Contains(stderr.String(), "reason=ack_eligibility_mutation_target_missing") ||
|
||||
!strings.Contains(stderr.String(), "mutation_attempts=0") ||
|
||||
!strings.Contains(stderr.String(), "ack_eligibility_mutation_attempts=0") {
|
||||
t.Fatalf("stderr=%s", stderr.String())
|
||||
out := stdout.String()
|
||||
for _, want := range []string{
|
||||
"authority_executor=blocked",
|
||||
"execution_requested=true",
|
||||
"execution_policy_enabled=true",
|
||||
"ack_eligibility_target_missing=1",
|
||||
"mutation_attempts=0",
|
||||
"ack_eligibility_mutation_attempts=0",
|
||||
"mutation_allowed=false",
|
||||
} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Fatalf("stdout missing %q:\n%s", want, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,9 +931,11 @@ func (w *operatorStatusTestWriter) WriteVolumeStatus(_ context.Context, ref ops.
|
||||
}
|
||||
|
||||
type lifecycleOwnerTestClient struct {
|
||||
volumes []ops.SwBlockVolumeObject
|
||||
patches []lifecycleOwnerTestPatch
|
||||
events []ops.OperatorKubernetesEvent
|
||||
volumes []ops.SwBlockVolumeObject
|
||||
eligibilities []ops.SwBlockReplicaEligibilityObject
|
||||
patches []lifecycleOwnerTestPatch
|
||||
events []ops.OperatorKubernetesEvent
|
||||
eligibilityWrites []lifecycleOwnerTestEligibilityWrite
|
||||
}
|
||||
|
||||
type lifecycleOwnerTestPatch struct {
|
||||
@@ -886,10 +943,24 @@ type lifecycleOwnerTestPatch struct {
|
||||
finalizers []string
|
||||
}
|
||||
|
||||
type lifecycleOwnerTestEligibilityWrite struct {
|
||||
ref ops.OperatorObjectRef
|
||||
status ops.SwBlockReplicaEligibilityCRDStatus
|
||||
}
|
||||
|
||||
func (c *lifecycleOwnerTestClient) ListSwBlockVolumes(_ context.Context, _ string) ([]ops.SwBlockVolumeObject, error) {
|
||||
return append([]ops.SwBlockVolumeObject(nil), c.volumes...), nil
|
||||
}
|
||||
|
||||
func (c *lifecycleOwnerTestClient) ListSwBlockReplicaEligibilities(_ context.Context, _ string) ([]ops.SwBlockReplicaEligibilityObject, error) {
|
||||
return append([]ops.SwBlockReplicaEligibilityObject(nil), c.eligibilities...), nil
|
||||
}
|
||||
|
||||
func (c *lifecycleOwnerTestClient) WriteReplicaEligibilityStatus(_ context.Context, ref ops.OperatorObjectRef, status ops.SwBlockReplicaEligibilityCRDStatus) error {
|
||||
c.eligibilityWrites = append(c.eligibilityWrites, lifecycleOwnerTestEligibilityWrite{ref: ref, status: status})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *lifecycleOwnerTestClient) PatchSwBlockVolumeFinalizers(_ context.Context, ref ops.OperatorObjectRef, finalizers []string) error {
|
||||
c.patches = append(c.patches, lifecycleOwnerTestPatch{
|
||||
ref: ref,
|
||||
|
||||
@@ -3,16 +3,21 @@ package ops
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
AuthorityExecutorAllowedMutationAckEligibility = "ack_eligibility"
|
||||
AuthorityExecutorBlockedPolicyDisabled = "executor_policy_disabled"
|
||||
AuthorityExecutorBlockedMutationTargetMissing = "ack_eligibility_mutation_target_missing"
|
||||
AuthorityExecutorBlockedTerminalEvidence = "terminal_evidence_missing"
|
||||
AuthorityExecutorReasonAckEligibilityRecorded = "ack_eligibility_recorded"
|
||||
)
|
||||
|
||||
type AuthorityExecutorClient interface {
|
||||
ListSwBlockVolumes(ctx context.Context, namespace string) ([]SwBlockVolumeObject, error)
|
||||
ListSwBlockReplicaEligibilities(ctx context.Context, namespace string) ([]SwBlockReplicaEligibilityObject, error)
|
||||
WriteReplicaEligibilityStatus(ctx context.Context, ref OperatorObjectRef, status SwBlockReplicaEligibilityCRDStatus) error
|
||||
}
|
||||
|
||||
type AuthorityExecutorReconciler struct {
|
||||
@@ -21,18 +26,21 @@ type AuthorityExecutorReconciler struct {
|
||||
ExecutionRequested bool
|
||||
ExecutionPolicyEnabled bool
|
||||
AllowedMutationClass string
|
||||
Now func() time.Time
|
||||
}
|
||||
|
||||
type AuthorityExecutorReconcileResult struct {
|
||||
VolumeCount int `json:"volumeCount"`
|
||||
ContractCount int `json:"contractCount"`
|
||||
DisabledContractCount int `json:"disabledContractCount"`
|
||||
BlockedContractCount int `json:"blockedContractCount"`
|
||||
TerminalEvidenceRequiredCount int `json:"terminalEvidenceRequiredCount"`
|
||||
UnsafeExecutionContractCount int `json:"unsafeExecutionContractCount"`
|
||||
MutationAttemptCount int `json:"mutationAttemptCount"`
|
||||
AckEligibilityMutationAttempts int `json:"ackEligibilityMutationAttempts"`
|
||||
BlockedReason string `json:"blockedReason,omitempty"`
|
||||
VolumeCount int `json:"volumeCount"`
|
||||
ContractCount int `json:"contractCount"`
|
||||
DisabledContractCount int `json:"disabledContractCount"`
|
||||
BlockedContractCount int `json:"blockedContractCount"`
|
||||
TerminalEvidenceRequiredCount int `json:"terminalEvidenceRequiredCount"`
|
||||
TerminalEvidenceMissingCount int `json:"terminalEvidenceMissingCount"`
|
||||
AckEligibilityTargetMissingCount int `json:"ackEligibilityTargetMissingCount"`
|
||||
UnsafeExecutionContractCount int `json:"unsafeExecutionContractCount"`
|
||||
MutationAttemptCount int `json:"mutationAttemptCount"`
|
||||
AckEligibilityMutationAttempts int `json:"ackEligibilityMutationAttempts"`
|
||||
BlockedReason string `json:"blockedReason,omitempty"`
|
||||
}
|
||||
|
||||
func (r AuthorityExecutorReconciler) Reconcile(ctx context.Context) (AuthorityExecutorReconcileResult, error) {
|
||||
@@ -45,10 +53,6 @@ func (r AuthorityExecutorReconciler) Reconcile(ctx context.Context) (AuthorityEx
|
||||
result := AuthorityExecutorReconcileResult{BlockedReason: AuthorityExecutorBlockedPolicyDisabled}
|
||||
return result, fmt.Errorf("authority executor execution is disabled by product policy")
|
||||
}
|
||||
if r.ExecutionRequested {
|
||||
result := AuthorityExecutorReconcileResult{BlockedReason: AuthorityExecutorBlockedMutationTargetMissing}
|
||||
return result, fmt.Errorf("authority executor ACK eligibility mutation target is not implemented")
|
||||
}
|
||||
if r.Client == nil {
|
||||
return AuthorityExecutorReconcileResult{}, fmt.Errorf("authority executor client is required")
|
||||
}
|
||||
@@ -57,6 +61,13 @@ func (r AuthorityExecutorReconciler) Reconcile(ctx context.Context) (AuthorityEx
|
||||
if err != nil {
|
||||
return AuthorityExecutorReconcileResult{}, err
|
||||
}
|
||||
var targets []SwBlockReplicaEligibilityObject
|
||||
if r.ExecutionRequested {
|
||||
targets, err = r.Client.ListSwBlockReplicaEligibilities(ctx, namespace)
|
||||
if err != nil {
|
||||
return AuthorityExecutorReconcileResult{}, err
|
||||
}
|
||||
}
|
||||
result := AuthorityExecutorReconcileResult{VolumeCount: len(volumes)}
|
||||
for _, volume := range volumes {
|
||||
for _, contract := range volume.Status.ExecutorContracts {
|
||||
@@ -77,6 +88,11 @@ func (r AuthorityExecutorReconciler) Reconcile(ctx context.Context) (AuthorityEx
|
||||
case ReturnedReplicaExecutorContractBlocked:
|
||||
result.BlockedContractCount++
|
||||
}
|
||||
if r.ExecutionRequested {
|
||||
if err := r.evaluateAckEligibility(ctx, &result, volume, contract, targets); err != nil {
|
||||
return result, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if result.UnsafeExecutionContractCount > 0 {
|
||||
@@ -84,3 +100,132 @@ func (r AuthorityExecutorReconciler) Reconcile(ctx context.Context) (AuthorityEx
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r AuthorityExecutorReconciler) evaluateAckEligibility(ctx context.Context, result *AuthorityExecutorReconcileResult, volume SwBlockVolumeObject, contract SwBlockVolumeCRDExecutorContract, targets []SwBlockReplicaEligibilityObject) error {
|
||||
returned, ok := authorityExecutorTerminalEvidenceReady(volume, contract)
|
||||
if !ok {
|
||||
result.TerminalEvidenceMissingCount++
|
||||
result.BlockedReason = authorityExecutorFirstNonEmpty(result.BlockedReason, AuthorityExecutorBlockedTerminalEvidence)
|
||||
return nil
|
||||
}
|
||||
target, ok := authorityExecutorFindTarget(volume, contract, targets)
|
||||
if !ok {
|
||||
result.AckEligibilityTargetMissingCount++
|
||||
result.BlockedReason = authorityExecutorFirstNonEmpty(result.BlockedReason, AuthorityExecutorBlockedMutationTargetMissing)
|
||||
return nil
|
||||
}
|
||||
result.MutationAttemptCount++
|
||||
result.AckEligibilityMutationAttempts++
|
||||
if err := r.Client.WriteReplicaEligibilityStatus(ctx, target.Ref, authorityExecutorAckEligibilityStatus(r.now()(), volume, contract, returned)); err != nil {
|
||||
result.BlockedReason = "ack_eligibility_status_write_failed"
|
||||
return fmt.Errorf("write ACK eligibility status: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func authorityExecutorTerminalEvidenceReady(volume SwBlockVolumeObject, contract SwBlockVolumeCRDExecutorContract) (SwBlockVolumeCRDReturnedReplica, bool) {
|
||||
if contract.Decision != ReturnedReplicaExecutorContractDisabled ||
|
||||
contract.Reason != ReturnedReplicaExecutorContractReasonExecutorDisabled ||
|
||||
contract.PreflightDecision != ReturnedReplicaExecutorPreflightReady ||
|
||||
contract.PreflightReason != ReturnedReplicaExecutorPreflightReasonSatisfied ||
|
||||
!authorityExecutorStringSliceContains(contract.AllowedMutationClass, AuthorityExecutorAllowedMutationAckEligibility) ||
|
||||
contract.ReplicaID == "" {
|
||||
return SwBlockVolumeCRDReturnedReplica{}, false
|
||||
}
|
||||
for _, returned := range volume.Status.ReplicaReintegrations {
|
||||
if returned.ReplicaID != contract.ReplicaID {
|
||||
continue
|
||||
}
|
||||
if !returned.FrontendFenced ||
|
||||
returned.FrontendPrimaryReady ||
|
||||
!returned.AckEligibilityKnown ||
|
||||
returned.AckEligible ||
|
||||
!returned.RequiredFrontierKnown ||
|
||||
!returned.DurableFrontierKnown ||
|
||||
returned.DurableFrontierLSN < returned.RequiredFrontierLSN {
|
||||
return SwBlockVolumeCRDReturnedReplica{}, false
|
||||
}
|
||||
return returned, true
|
||||
}
|
||||
return SwBlockVolumeCRDReturnedReplica{}, false
|
||||
}
|
||||
|
||||
func authorityExecutorFindTarget(volume SwBlockVolumeObject, contract SwBlockVolumeCRDExecutorContract, targets []SwBlockReplicaEligibilityObject) (SwBlockReplicaEligibilityObject, bool) {
|
||||
var matches []SwBlockReplicaEligibilityObject
|
||||
for _, target := range targets {
|
||||
if target.Spec.VolumeName == "" && target.Spec.VolumeID == "" && target.Spec.PVCName == "" {
|
||||
continue
|
||||
}
|
||||
if target.Spec.ReplicaID != contract.ReplicaID {
|
||||
continue
|
||||
}
|
||||
if target.Spec.VolumeName != "" && target.Spec.VolumeName != volume.Ref.Name {
|
||||
continue
|
||||
}
|
||||
if target.Spec.VolumeID != "" && target.Spec.VolumeID != volume.Status.VolumeID {
|
||||
continue
|
||||
}
|
||||
if target.Spec.PVCName != "" && target.Spec.PVCName != volume.Status.PVCName {
|
||||
continue
|
||||
}
|
||||
matches = append(matches, target)
|
||||
}
|
||||
if len(matches) != 1 {
|
||||
return SwBlockReplicaEligibilityObject{}, false
|
||||
}
|
||||
return matches[0], true
|
||||
}
|
||||
|
||||
func authorityExecutorAckEligibilityStatus(now time.Time, volume SwBlockVolumeObject, contract SwBlockVolumeCRDExecutorContract, returned SwBlockVolumeCRDReturnedReplica) SwBlockReplicaEligibilityCRDStatus {
|
||||
evidenceRefs := appendUniqueStrings(nil, contract.EvidenceRefs...)
|
||||
evidenceRefs = appendUniqueStrings(evidenceRefs, returned.EvidenceRefs...)
|
||||
return SwBlockReplicaEligibilityCRDStatus{
|
||||
ObservedAt: now,
|
||||
Executor: defaultString(contract.OwnerExecutor, "authority_recovery_executor"),
|
||||
ReasonCode: AuthorityExecutorReasonAckEligibilityRecorded,
|
||||
AckEligibilityKnown: true,
|
||||
AckEligible: true,
|
||||
FrontendFencedAfterExecution: returned.FrontendFenced && !returned.FrontendPrimaryReady,
|
||||
PrimaryUnchanged: returned.FrontendFenced && !returned.FrontendPrimaryReady,
|
||||
DurableFrontierCovered: returned.DurableFrontierKnown && returned.RequiredFrontierKnown && returned.DurableFrontierLSN >= returned.RequiredFrontierLSN,
|
||||
NoCrossVolumeIdentityChange: true,
|
||||
Conditions: []ObservationCondition{{
|
||||
Type: ConditionReady,
|
||||
Status: "True",
|
||||
Reason: AuthorityExecutorReasonAckEligibilityRecorded,
|
||||
Severity: "info",
|
||||
Message: "ACK eligibility was recorded only after terminal returned-replica evidence stayed fenced and durable-frontier covered",
|
||||
}},
|
||||
EvidenceRefs: evidenceRefs,
|
||||
NonClaims: []string{
|
||||
"no_frontend_publication",
|
||||
"no_rebuild_traffic",
|
||||
"no_failback",
|
||||
"no_primary_authority_change",
|
||||
"no_cross_volume_mutation",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (r AuthorityExecutorReconciler) now() func() time.Time {
|
||||
if r.Now != nil {
|
||||
return r.Now
|
||||
}
|
||||
return func() time.Time { return time.Now().UTC() }
|
||||
}
|
||||
|
||||
func authorityExecutorStringSliceContains(values []string, want string) bool {
|
||||
for _, value := range values {
|
||||
if value == want {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func authorityExecutorFirstNonEmpty(current, fallback string) string {
|
||||
if current != "" {
|
||||
return current
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
@@ -3,10 +3,11 @@ package ops
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAuthorityExecutorReconcilerObservesDisabledContractsWithoutMutation(t *testing.T) {
|
||||
client := fakeAuthorityExecutorClient{volumes: []SwBlockVolumeObject{{
|
||||
client := &fakeAuthorityExecutorClient{volumes: []SwBlockVolumeObject{{
|
||||
Ref: OperatorObjectRef{Namespace: "kube-system", Name: "returned"},
|
||||
Status: SwBlockVolumeCRDStatus{ExecutorContracts: []SwBlockVolumeCRDExecutorContract{{
|
||||
ActionType: ManagedVolumeActionReintegrateReturned,
|
||||
@@ -40,7 +41,7 @@ func TestAuthorityExecutorReconcilerObservesDisabledContractsWithoutMutation(t *
|
||||
}
|
||||
|
||||
func TestAuthorityExecutorReconcilerFailsClosedOnExecutionEnabledContract(t *testing.T) {
|
||||
client := fakeAuthorityExecutorClient{volumes: []SwBlockVolumeObject{{
|
||||
client := &fakeAuthorityExecutorClient{volumes: []SwBlockVolumeObject{{
|
||||
Ref: OperatorObjectRef{Namespace: "kube-system", Name: "unsafe"},
|
||||
Status: SwBlockVolumeCRDStatus{ExecutorContracts: []SwBlockVolumeCRDExecutorContract{{
|
||||
ActionType: ManagedVolumeActionReintegrateReturned,
|
||||
@@ -66,7 +67,7 @@ func TestAuthorityExecutorReconcilerFailsClosedOnExecutionEnabledContract(t *tes
|
||||
|
||||
func TestAuthorityExecutorReconcilerRejectsUnsupportedMutationClass(t *testing.T) {
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Client: fakeAuthorityExecutorClient{},
|
||||
Client: &fakeAuthorityExecutorClient{},
|
||||
AllowedMutationClass: "rebuild_traffic",
|
||||
}).Reconcile(context.Background())
|
||||
if err == nil {
|
||||
@@ -79,7 +80,7 @@ func TestAuthorityExecutorReconcilerRejectsUnsupportedMutationClass(t *testing.T
|
||||
|
||||
func TestAuthorityExecutorReconcilerRejectsExecutionWhenPolicyDisabled(t *testing.T) {
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Client: fakeAuthorityExecutorClient{},
|
||||
Client: &fakeAuthorityExecutorClient{},
|
||||
ExecutionRequested: true,
|
||||
}).Reconcile(context.Background())
|
||||
if err == nil {
|
||||
@@ -93,26 +94,166 @@ func TestAuthorityExecutorReconcilerRejectsExecutionWhenPolicyDisabled(t *testin
|
||||
}
|
||||
|
||||
func TestAuthorityExecutorReconcilerBlocksExecutionWhenAckTargetMissing(t *testing.T) {
|
||||
volume := authorityExecutorReadyVolume()
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Client: fakeAuthorityExecutorClient{},
|
||||
Client: &fakeAuthorityExecutorClient{volumes: []SwBlockVolumeObject{volume}},
|
||||
ExecutionRequested: true,
|
||||
ExecutionPolicyEnabled: true,
|
||||
AllowedMutationClass: AuthorityExecutorAllowedMutationAckEligibility,
|
||||
}).Reconcile(context.Background())
|
||||
if err == nil {
|
||||
t.Fatalf("expected missing ACK target to fail closed, result=%+v", result)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: %v", err)
|
||||
}
|
||||
if result.BlockedReason != AuthorityExecutorBlockedMutationTargetMissing ||
|
||||
result.AckEligibilityTargetMissingCount != 1 ||
|
||||
result.MutationAttemptCount != 0 ||
|
||||
result.AckEligibilityMutationAttempts != 0 {
|
||||
t.Fatalf("result=%+v", result)
|
||||
}
|
||||
}
|
||||
|
||||
type fakeAuthorityExecutorClient struct {
|
||||
volumes []SwBlockVolumeObject
|
||||
func TestAuthorityExecutorReconcilerHoldsWhenTerminalEvidenceMissing(t *testing.T) {
|
||||
volume := authorityExecutorReadyVolume()
|
||||
volume.Status.ReplicaReintegrations[0].FrontendFenced = false
|
||||
client := &fakeAuthorityExecutorClient{
|
||||
volumes: []SwBlockVolumeObject{volume},
|
||||
eligibilities: []SwBlockReplicaEligibilityObject{authorityExecutorTarget()},
|
||||
}
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Client: client,
|
||||
ExecutionRequested: true,
|
||||
ExecutionPolicyEnabled: true,
|
||||
AllowedMutationClass: AuthorityExecutorAllowedMutationAckEligibility,
|
||||
}).Reconcile(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: %v", err)
|
||||
}
|
||||
if result.BlockedReason != AuthorityExecutorBlockedTerminalEvidence ||
|
||||
result.TerminalEvidenceMissingCount != 1 ||
|
||||
result.MutationAttemptCount != 0 ||
|
||||
len(client.writes) != 0 {
|
||||
t.Fatalf("result=%+v writes=%+v", result, client.writes)
|
||||
}
|
||||
}
|
||||
|
||||
func (f fakeAuthorityExecutorClient) ListSwBlockVolumes(context.Context, string) ([]SwBlockVolumeObject, error) {
|
||||
func TestAuthorityExecutorReconcilerWritesAckEligibilityStatusWhenTerminalEvidenceReady(t *testing.T) {
|
||||
client := &fakeAuthorityExecutorClient{
|
||||
volumes: []SwBlockVolumeObject{authorityExecutorReadyVolume()},
|
||||
eligibilities: []SwBlockReplicaEligibilityObject{authorityExecutorTarget()},
|
||||
}
|
||||
now := time.Date(2026, 6, 23, 1, 2, 3, 0, time.UTC)
|
||||
result, err := (AuthorityExecutorReconciler{
|
||||
Client: client,
|
||||
ExecutionRequested: true,
|
||||
ExecutionPolicyEnabled: true,
|
||||
AllowedMutationClass: AuthorityExecutorAllowedMutationAckEligibility,
|
||||
Now: func() time.Time { return now },
|
||||
}).Reconcile(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: %v", err)
|
||||
}
|
||||
if result.MutationAttemptCount != 1 ||
|
||||
result.AckEligibilityMutationAttempts != 1 ||
|
||||
result.BlockedReason != "" ||
|
||||
len(client.writes) != 1 {
|
||||
t.Fatalf("result=%+v writes=%+v", result, client.writes)
|
||||
}
|
||||
write := client.writes[0]
|
||||
if write.ref.Name != "returned-r1" {
|
||||
t.Fatalf("write ref=%+v", write.ref)
|
||||
}
|
||||
status := write.status
|
||||
if !status.AckEligibilityKnown ||
|
||||
!status.AckEligible ||
|
||||
!status.FrontendFencedAfterExecution ||
|
||||
!status.PrimaryUnchanged ||
|
||||
!status.DurableFrontierCovered ||
|
||||
!status.NoCrossVolumeIdentityChange ||
|
||||
status.ReasonCode != AuthorityExecutorReasonAckEligibilityRecorded ||
|
||||
!status.ObservedAt.Equal(now) {
|
||||
t.Fatalf("status=%+v", status)
|
||||
}
|
||||
if len(status.Conditions) != 1 || status.Conditions[0].Reason != AuthorityExecutorReasonAckEligibilityRecorded {
|
||||
t.Fatalf("conditions=%+v", status.Conditions)
|
||||
}
|
||||
}
|
||||
|
||||
type fakeAuthorityExecutorClient struct {
|
||||
volumes []SwBlockVolumeObject
|
||||
eligibilities []SwBlockReplicaEligibilityObject
|
||||
writes []fakeReplicaEligibilityWrite
|
||||
}
|
||||
|
||||
type fakeReplicaEligibilityWrite struct {
|
||||
ref OperatorObjectRef
|
||||
status SwBlockReplicaEligibilityCRDStatus
|
||||
}
|
||||
|
||||
func (f *fakeAuthorityExecutorClient) ListSwBlockVolumes(context.Context, string) ([]SwBlockVolumeObject, error) {
|
||||
return append([]SwBlockVolumeObject(nil), f.volumes...), nil
|
||||
}
|
||||
|
||||
func (f *fakeAuthorityExecutorClient) ListSwBlockReplicaEligibilities(context.Context, string) ([]SwBlockReplicaEligibilityObject, error) {
|
||||
return append([]SwBlockReplicaEligibilityObject(nil), f.eligibilities...), nil
|
||||
}
|
||||
|
||||
func (f *fakeAuthorityExecutorClient) WriteReplicaEligibilityStatus(_ context.Context, ref OperatorObjectRef, status SwBlockReplicaEligibilityCRDStatus) error {
|
||||
f.writes = append(f.writes, fakeReplicaEligibilityWrite{ref: ref, status: status})
|
||||
return nil
|
||||
}
|
||||
|
||||
func authorityExecutorReadyVolume() SwBlockVolumeObject {
|
||||
return SwBlockVolumeObject{
|
||||
Ref: OperatorObjectRef{Namespace: "kube-system", Name: "returned"},
|
||||
Status: SwBlockVolumeCRDStatus{
|
||||
VolumeID: "pvc-1",
|
||||
PVCName: "demo",
|
||||
ReplicaReintegrations: []SwBlockVolumeCRDReturnedReplica{{
|
||||
ReplicaID: "r1",
|
||||
State: ReturnedReplicaStateFenced,
|
||||
ReasonCode: ReasonReturnedReplicaFrontendFenced,
|
||||
FrontendFenced: true,
|
||||
FrontendPrimaryReady: false,
|
||||
AckEligibilityKnown: true,
|
||||
AckEligible: false,
|
||||
DurableFrontierKnown: true,
|
||||
DurableFrontierLSN: 52,
|
||||
RequiredFrontierKnown: true,
|
||||
RequiredFrontierLSN: 52,
|
||||
EvidenceRefs: []string{"returned.txt"},
|
||||
}},
|
||||
ExecutorContracts: []SwBlockVolumeCRDExecutorContract{{
|
||||
ActionType: ManagedVolumeActionReintegrateReturned,
|
||||
ReplicaID: "r1",
|
||||
Decision: ReturnedReplicaExecutorContractDisabled,
|
||||
Reason: ReturnedReplicaExecutorContractReasonExecutorDisabled,
|
||||
OwnerExecutor: "authority_recovery_executor",
|
||||
ExecutionEnabled: false,
|
||||
MutationAllowed: false,
|
||||
PreflightDecision: ReturnedReplicaExecutorPreflightReady,
|
||||
PreflightReason: ReturnedReplicaExecutorPreflightReasonSatisfied,
|
||||
AllowedMutationClass: []string{AuthorityExecutorAllowedMutationAckEligibility},
|
||||
ForbiddenMutationClass: []string{"frontend_publication", "rebuild_traffic", "failback"},
|
||||
TerminalEvidenceRequired: returnedReplicaTerminalEvidenceRequired(),
|
||||
EvidenceRefs: []string{"contract.txt"},
|
||||
}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func authorityExecutorTarget() SwBlockReplicaEligibilityObject {
|
||||
return SwBlockReplicaEligibilityObject{
|
||||
Ref: OperatorObjectRef{
|
||||
APIVersion: SwBlockVolumeAPIVersion,
|
||||
Kind: SwBlockReplicaEligibilityKind,
|
||||
Namespace: "kube-system",
|
||||
Name: "returned-r1",
|
||||
},
|
||||
Spec: SwBlockReplicaEligibilitySpec{
|
||||
VolumeName: "returned",
|
||||
VolumeID: "pvc-1",
|
||||
PVCName: "demo",
|
||||
ReplicaID: "r1",
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -128,6 +128,55 @@ func (c *KubernetesStatusClient) ListSwBlockVolumes(ctx context.Context, namespa
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *KubernetesStatusClient) ListSwBlockReplicaEligibilities(ctx context.Context, namespace string) ([]SwBlockReplicaEligibilityObject, error) {
|
||||
if namespace == "" {
|
||||
return nil, fmt.Errorf("namespace is required for SwBlockReplicaEligibility list")
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.resourceCollectionURL(namespace, SwBlockReplicaEligibilityPlural), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
if c.BearerToken != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+c.BearerToken)
|
||||
}
|
||||
client := c.HTTPClient
|
||||
if client == nil {
|
||||
client = http.DefaultClient
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
raw, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
|
||||
return nil, fmt.Errorf("list %s failed: http %d %s", SwBlockReplicaEligibilityPlural, resp.StatusCode, strings.TrimSpace(string(raw)))
|
||||
}
|
||||
var list kubernetesSwBlockReplicaEligibilityList
|
||||
if err := json.NewDecoder(io.LimitReader(resp.Body, 1<<20)).Decode(&list); err != nil {
|
||||
return nil, fmt.Errorf("decode %s list: %w", SwBlockReplicaEligibilityPlural, err)
|
||||
}
|
||||
out := make([]SwBlockReplicaEligibilityObject, 0, len(list.Items))
|
||||
for _, item := range list.Items {
|
||||
refNamespace := item.Metadata.Namespace
|
||||
if refNamespace == "" {
|
||||
refNamespace = namespace
|
||||
}
|
||||
out = append(out, SwBlockReplicaEligibilityObject{
|
||||
Ref: OperatorObjectRef{
|
||||
APIVersion: SwBlockVolumeAPIVersion,
|
||||
Kind: SwBlockReplicaEligibilityKind,
|
||||
Namespace: refNamespace,
|
||||
Name: item.Metadata.Name,
|
||||
},
|
||||
Spec: item.Spec,
|
||||
Status: item.Status,
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *KubernetesStatusClient) PatchSwBlockVolumeFinalizers(ctx context.Context, ref OperatorObjectRef, finalizers []string) error {
|
||||
if ref.Namespace == "" || ref.Name == "" {
|
||||
return fmt.Errorf("namespace and name are required for SwBlockVolume finalizer patch")
|
||||
@@ -341,3 +390,13 @@ type kubernetesSwBlockVolume struct {
|
||||
Spec SwBlockVolumeSpec `json:"spec"`
|
||||
Status SwBlockVolumeCRDStatus `json:"status"`
|
||||
}
|
||||
|
||||
type kubernetesSwBlockReplicaEligibilityList struct {
|
||||
Items []kubernetesSwBlockReplicaEligibility `json:"items"`
|
||||
}
|
||||
|
||||
type kubernetesSwBlockReplicaEligibility struct {
|
||||
Metadata kubernetesMetadata `json:"metadata"`
|
||||
Spec SwBlockReplicaEligibilitySpec `json:"spec"`
|
||||
Status SwBlockReplicaEligibilityCRDStatus `json:"status"`
|
||||
}
|
||||
@@ -24,6 +24,19 @@ type SwBlockVolumeSpec struct {
|
||||
StorageClass string `json:"storageClass,omitempty"`
|
||||
}
|
||||
|
||||
type SwBlockReplicaEligibilityObject struct {
|
||||
Ref OperatorObjectRef `json:"ref"`
|
||||
Spec SwBlockReplicaEligibilitySpec `json:"spec,omitempty"`
|
||||
Status SwBlockReplicaEligibilityCRDStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type SwBlockReplicaEligibilitySpec struct {
|
||||
VolumeName string `json:"volumeName,omitempty"`
|
||||
VolumeID string `json:"volumeID,omitempty"`
|
||||
PVCName string `json:"pvcName,omitempty"`
|
||||
ReplicaID string `json:"replicaID,omitempty"`
|
||||
}
|
||||
|
||||
type LifecycleOwnerReconciler struct {
|
||||
Namespace string
|
||||
Client LifecycleOwnerClient
|
||||
|
||||
@@ -176,13 +176,15 @@ Recommended order from here:
|
||||
read-only `SwBlockVolume` access. It consumes executor contracts and fails
|
||||
closed on execution-enabled or mutating contracts, but still performs no ACK
|
||||
eligibility mutation, frontend publication, rebuild traffic, or failback.
|
||||
11. Phase 54: returned-replica reintegration executor milestone. **Planned**
|
||||
11. Phase 54: returned-replica reintegration executor milestone. **In progress**
|
||||
(`internal/docs/current-plan.md`).
|
||||
This is intentionally larger than the previous safety-latch phases. It
|
||||
groups executor policy, the ACK eligibility mutation target, admission/RBAC,
|
||||
terminal evidence, failure states, multi-volume isolation, and a live close
|
||||
gate into one milestone. The first allowed mutation remains narrow:
|
||||
returned-replica ACK eligibility only.
|
||||
returned-replica ACK eligibility only. D1-D3 are implemented, with D3 live
|
||||
RBAC QA PASS; D4 has the executor call-site implemented and awaits terminal
|
||||
evidence QA.
|
||||
12. Add backup/restore and NVMe ANA parity after they can reuse the same action
|
||||
owner, evidence, and status model rather than creating another isolated
|
||||
control plane.
|
||||
|
||||
@@ -131,13 +131,13 @@ SwBlockVolume status is a projection surface owned by operator-status and must
|
||||
not be used as fake executor state.
|
||||
```
|
||||
|
||||
Execution still fails closed until D3 proves RBAC/admission and the writer path
|
||||
is implemented.
|
||||
Execution remains disabled by default. The bounded writer path now exists; D4
|
||||
must prove the executor calls it only with complete terminal evidence.
|
||||
|
||||
### D3: Admission/RBAC Boundary
|
||||
|
||||
Status: chart RBAC target and Kubernetes status writer path added; live proof
|
||||
and executor call-site still pending.
|
||||
Status: **QA PASS**. The live m02 k3s gate passed through
|
||||
`testops/scenarios/authority-executor-target-rbac-chain.yaml`.
|
||||
|
||||
Add real Kubernetes proof for the chosen mutation target.
|
||||
|
||||
@@ -161,9 +161,6 @@ still no swblockvolumes/status, swblockvolumes/finalizers, Events, pods, PVCs,
|
||||
PVs, storageclasses, secrets, or delete/create verbs
|
||||
```
|
||||
|
||||
Execution still fails closed until the executor call-site is implemented and
|
||||
the live RBAC/admission gate passes.
|
||||
|
||||
Writer path now exists:
|
||||
|
||||
```text
|
||||
@@ -172,10 +169,24 @@ PATCH /apis/block.seaweedfs.com/v1alpha1/namespaces/<ns>/
|
||||
swblockreplicaeligibilities/<name>/status
|
||||
```
|
||||
|
||||
The executor does not call it yet.
|
||||
The D4 call-site uses this writer only for the matching
|
||||
`SwBlockReplicaEligibility.status` object.
|
||||
|
||||
D3 close evidence:
|
||||
|
||||
```text
|
||||
phase54_authority_executor_target_rbac_status=ok
|
||||
executor SA: get/list/watch swblockvolumes and swblockreplicaeligibilities
|
||||
executor SA: update/patch swblockreplicaeligibilities/status
|
||||
executor SA: denied for SwBlockVolume status/finalizers, main object, Events,
|
||||
pods, PVCs, PVs, storageclasses, secrets, and delete/create verbs
|
||||
default SA: denied for swblockreplicaeligibilities/status
|
||||
```
|
||||
|
||||
### D4: Terminal Evidence Projection
|
||||
|
||||
Status: implemented locally, pending QA.
|
||||
|
||||
After execution, project terminal evidence:
|
||||
|
||||
```text
|
||||
@@ -187,6 +198,44 @@ durable_frontier_covered=true
|
||||
no_cross_volume_identity_change=true
|
||||
```
|
||||
|
||||
Implementation boundary:
|
||||
|
||||
```text
|
||||
authority-executor --enable-execution --execution-policy
|
||||
-> reads SwBlockVolume executorContracts + returned-replica status
|
||||
-> reads existing SwBlockReplicaEligibility targets
|
||||
-> patches only matching SwBlockReplicaEligibility.status
|
||||
```
|
||||
|
||||
The executor does **not** create the target CR. A missing target is a hold with
|
||||
`ack_eligibility_mutation_target_missing` and zero mutation attempts. This keeps
|
||||
object identity ownership outside the executor.
|
||||
|
||||
Terminal evidence required before any patch:
|
||||
|
||||
```text
|
||||
contract.actionType=authority.reintegrate_returned_replica
|
||||
contract.decision=disabled
|
||||
contract.reason=executor_policy_disabled
|
||||
contract.preflightDecision=ready
|
||||
contract.preflightReason=preconditions_satisfied
|
||||
contract.allowedMutationClass includes ack_eligibility
|
||||
returned replica exists for contract.replicaID
|
||||
frontendFenced=true
|
||||
frontendPrimaryReady=false
|
||||
ackEligibilityKnown=true
|
||||
ackEligible=false before execution
|
||||
requiredFrontierKnown=true
|
||||
durableFrontierKnown=true
|
||||
durableFrontierLsn >= requiredFrontierLsn
|
||||
exactly one SwBlockReplicaEligibility target matches volume identity + replicaID
|
||||
```
|
||||
|
||||
`primary_unchanged` is intentionally bounded: the call-site can prove the
|
||||
returned replica did not become frontend-primary-ready because it remains
|
||||
frontend-fenced. It does not claim a broad cluster primary proof from this
|
||||
executor path.
|
||||
|
||||
Acceptance:
|
||||
|
||||
- report, explain, dashboard, operator-snapshot, and CRD agree,
|
||||
@@ -251,6 +300,7 @@ Minimum local checks:
|
||||
go test -count=1 ./core/ops ./cmd/sw-block
|
||||
helm lint charts/seaweed-block
|
||||
swblock validate testops/scenarios/authority-executor-rbac-chain.yaml
|
||||
swblock validate testops/scenarios/authority-executor-target-rbac-chain.yaml
|
||||
swblock validate testops/scenarios/iscsi-returned-replica-chain.yaml
|
||||
```
|
||||
|
||||
|
||||
@@ -199,8 +199,10 @@ rebuild, delete safety, or cleanup must start as a separate gated phase.
|
||||
adds the disabled executor process boundary with read-only SwBlockVolume
|
||||
access. Phase 54 is the larger milestone for the first bounded mutation:
|
||||
returned-replica ACK eligibility only, with admission/RBAC, terminal evidence,
|
||||
failure states, and multi-volume isolation in one close gate. Broader
|
||||
authority/storage mutation is still deferred.
|
||||
failure states, and multi-volume isolation in one close gate. D1-D3 are
|
||||
implemented and D3 has live RBAC QA PASS; D4 now connects the executor
|
||||
call-site to the narrow ACK eligibility status target and is pending terminal
|
||||
evidence QA. Broader authority/storage mutation is still deferred.
|
||||
- Later: returned-replica rebuild/reintegration/failback execution, NVMe ANA
|
||||
Kubernetes multipath parity, stronger committed-frontier reporting, broad
|
||||
distro/host compatibility, and longer soak under failure. NVMe ANA parity
|
||||
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
# Phase 54 D4 QA: Authority Executor Call-Site And Terminal Evidence
|
||||
|
||||
Status: ready for QA after D3 RBAC PASS.
|
||||
|
||||
## Goal
|
||||
|
||||
Validate that `sw-block ops authority-executor --enable-execution
|
||||
--execution-policy` performs exactly one bounded mutation:
|
||||
|
||||
```text
|
||||
PATCH SwBlockReplicaEligibility.status
|
||||
```
|
||||
|
||||
It must not create targets, patch `SwBlockVolume`, emit Events, publish a
|
||||
frontend, start rebuild/catch-up, perform failback, or touch another volume.
|
||||
|
||||
## Preconditions
|
||||
|
||||
- Phase 54 D3 RBAC gate is PASS.
|
||||
- CRDs are installed, including `SwBlockReplicaEligibility`.
|
||||
- `authorityExecutor.execution.enabled=true` so the executor ServiceAccount has
|
||||
only:
|
||||
- get/list/watch `swblockvolumes`
|
||||
- get/list/watch `swblockreplicaeligibilities`
|
||||
- get/update/patch `swblockreplicaeligibilities/status`
|
||||
|
||||
## Terminal Evidence Required
|
||||
|
||||
The executor may patch target status only when all are true:
|
||||
|
||||
```text
|
||||
contract.actionType=authority.reintegrate_returned_replica
|
||||
contract.decision=disabled
|
||||
contract.reason=executor_policy_disabled
|
||||
contract.preflightDecision=ready
|
||||
contract.preflightReason=preconditions_satisfied
|
||||
contract.allowedMutationClass includes ack_eligibility
|
||||
returned replica exists for contract.replicaID
|
||||
frontendFenced=true
|
||||
frontendPrimaryReady=false
|
||||
ackEligibilityKnown=true
|
||||
ackEligible=false before execution
|
||||
requiredFrontierKnown=true
|
||||
durableFrontierKnown=true
|
||||
durableFrontierLsn >= requiredFrontierLsn
|
||||
exactly one SwBlockReplicaEligibility target matches volumeName/volumeID/pvcName
|
||||
and replicaID
|
||||
```
|
||||
|
||||
`primaryUnchanged=true` is a bounded claim: the returned replica remains
|
||||
frontend-fenced and did not become frontend-primary-ready. D4 must not claim a
|
||||
broader cluster-primary transition.
|
||||
|
||||
## G1: Target Missing Holds
|
||||
|
||||
Create a `SwBlockVolume` with complete ready returned-replica contract, but do
|
||||
not create a matching `SwBlockReplicaEligibility`.
|
||||
|
||||
Run the executor as the authority-executor ServiceAccount.
|
||||
|
||||
Expected:
|
||||
|
||||
```text
|
||||
authority_executor=blocked
|
||||
ack_eligibility_target_missing=1
|
||||
mutation_attempts=0
|
||||
ack_eligibility_mutation_attempts=0
|
||||
```
|
||||
|
||||
No `SwBlockReplicaEligibility` object is created.
|
||||
|
||||
## G2: Terminal Evidence Missing Holds
|
||||
|
||||
Create a matching `SwBlockReplicaEligibility`, but make one terminal evidence
|
||||
fact unsafe, for example:
|
||||
|
||||
```text
|
||||
frontendFenced=false
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```text
|
||||
durableFrontierLsn < requiredFrontierLsn
|
||||
```
|
||||
|
||||
Expected:
|
||||
|
||||
```text
|
||||
authority_executor=blocked
|
||||
terminal_evidence_missing=1
|
||||
mutation_attempts=0
|
||||
ack_eligibility_mutation_attempts=0
|
||||
```
|
||||
|
||||
Target status must remain unchanged or absent.
|
||||
|
||||
## G3: Complete Evidence Writes Target Status
|
||||
|
||||
Create:
|
||||
|
||||
- one `SwBlockVolume` with a complete ready returned-replica contract,
|
||||
- one matching `SwBlockReplicaEligibility` target.
|
||||
|
||||
Run the executor as the authority-executor ServiceAccount.
|
||||
|
||||
Expected command output:
|
||||
|
||||
```text
|
||||
authority_executor=executed
|
||||
mutation_attempts=1
|
||||
ack_eligibility_mutation_attempts=1
|
||||
storage_mutation_allowed=false
|
||||
```
|
||||
|
||||
Expected target status:
|
||||
|
||||
```text
|
||||
reasonCode=ack_eligibility_recorded
|
||||
ackEligibilityKnown=true
|
||||
ackEligible=true
|
||||
frontendFencedAfterExecution=true
|
||||
primaryUnchanged=true
|
||||
durableFrontierCovered=true
|
||||
noCrossVolumeIdentityChange=true
|
||||
conditions[Ready].status=True
|
||||
conditions[Ready].reason=ack_eligibility_recorded
|
||||
nonClaims includes no_frontend_publication
|
||||
nonClaims includes no_rebuild_traffic
|
||||
nonClaims includes no_failback
|
||||
nonClaims includes no_primary_authority_change
|
||||
```
|
||||
|
||||
## G4: Boundary Carry-Forward
|
||||
|
||||
Re-run or spot-check the D3 boundary:
|
||||
|
||||
- executor can patch `swblockreplicaeligibilities/status`,
|
||||
- executor cannot patch `swblockvolumes/status`,
|
||||
- executor cannot patch `swblockvolumes/finalizers`,
|
||||
- executor cannot patch `swblockvolumes` main object,
|
||||
- executor cannot create Events,
|
||||
- executor cannot create/update/patch/delete pods, PVCs, PVs, secrets, or
|
||||
storageclasses.
|
||||
|
||||
## G5: Cleanup
|
||||
|
||||
Delete all synthetic CRs and chart artifacts. Final lab state must show:
|
||||
|
||||
```text
|
||||
0 SwBlockVolume
|
||||
0 SwBlockReplicaEligibility
|
||||
0 helm releases
|
||||
0 sw-block pods
|
||||
0 PVC/PV
|
||||
```
|
||||
|
||||
## Blockers
|
||||
|
||||
Block D4 if:
|
||||
|
||||
- any target status patch occurs with missing terminal evidence,
|
||||
- the executor creates a target CR,
|
||||
- the executor patches `SwBlockVolume` or any workload/storage resource,
|
||||
- target status claims frontend publication, rebuild, failback, or broad primary
|
||||
movement,
|
||||
- target status is written to the wrong volume/replica identity.
|
||||
Reference in new issue
Block a user