Skip to content

Commit 8235af5

Browse files
committed
fix(operations): version switchover dispatch status
1 parent 364dff9 commit 8235af5

7 files changed

Lines changed: 554 additions & 187 deletions

File tree

apis/operations/v1alpha1/opsrequest_types.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,11 +1024,17 @@ type ProgressStatusDetail struct {
10241024
// +optional
10251025
ActionTasks []ActionTask `json:"actionTasks,omitempty"`
10261026

1027+
// Records the durable dispatch state for a Switchover lifecycle action.
1028+
// This structured field is the controller protocol; Message remains display-only.
1029+
// +optional
1030+
SwitchoverDispatch *SwitchoverDispatchStatus `json:"switchoverDispatch,omitempty"`
1031+
10271032
// Represents the current processing state of the object, including "Processing", "Pending", "Failed", "Succeed"
10281033
// +kubebuilder:validation:Required
10291034
Status ProgressStatus `json:"status"`
10301035

10311036
// Provides a human-readable explanation of the object's condition.
1037+
// Controllers must not parse this field as durable state or a versioned protocol.
10321038
// +optional
10331039
Message string `json:"message,omitempty"`
10341040

@@ -1041,6 +1047,61 @@ type ProgressStatusDetail struct {
10411047
EndTime metav1.Time `json:"endTime,omitempty"`
10421048
}
10431049

1050+
const SwitchoverDispatchProtocolVersionV1 = "v1"
1051+
1052+
// SwitchoverDispatchStatus records the durable identity and state of one
1053+
// non-idempotent Switchover lifecycle-action dispatch.
1054+
type SwitchoverDispatchStatus struct {
1055+
// Version selects the protocol contract used by this status value.
1056+
// Readers must fail closed when they do not support the recorded version.
1057+
// +kubebuilder:validation:MinLength=1
1058+
// +kubebuilder:validation:MaxLength=16
1059+
Version string `json:"version"`
1060+
1061+
// OpsRequestUID binds the dispatch to one exact OpsRequest incarnation.
1062+
// +kubebuilder:validation:MinLength=1
1063+
// +kubebuilder:validation:MaxLength=128
1064+
OpsRequestUID string `json:"opsRequestUID"`
1065+
1066+
// ComponentName is the logical component or sharding name used by the writer.
1067+
// +kubebuilder:validation:MinLength=1
1068+
// +kubebuilder:validation:MaxLength=256
1069+
ComponentName string `json:"componentName"`
1070+
1071+
// InstanceName is the source instance requested by the Switchover.
1072+
// +kubebuilder:validation:MinLength=1
1073+
// +kubebuilder:validation:MaxLength=256
1074+
InstanceName string `json:"instanceName"`
1075+
1076+
// CandidateName is the optional target instance requested by the Switchover.
1077+
// +kubebuilder:validation:MaxLength=256
1078+
// +optional
1079+
CandidateName string `json:"candidateName,omitempty"`
1080+
1081+
// Token uniquely identifies the writer that committed the dispatch claim.
1082+
// +kubebuilder:validation:MinLength=1
1083+
// +kubebuilder:validation:MaxLength=256
1084+
Token string `json:"token"`
1085+
1086+
// State records whether the external call is still unconfirmed, was resolved
1087+
// by its caller, or crossed a restart with no retained result.
1088+
// +kubebuilder:validation:Enum=Claimed;Resolved;OutcomeUnknown
1089+
State SwitchoverDispatchState `json:"state"`
1090+
}
1091+
1092+
type SwitchoverDispatchState string
1093+
1094+
const (
1095+
// SwitchoverDispatchClaimed means the claim was committed before the external
1096+
// call but no call result has been committed yet.
1097+
SwitchoverDispatchClaimed SwitchoverDispatchState = "Claimed"
1098+
// SwitchoverDispatchResolved means the caller committed its definite result.
1099+
SwitchoverDispatchResolved SwitchoverDispatchState = "Resolved"
1100+
// SwitchoverDispatchOutcomeUnknown means no caller-held result remains and
1101+
// the lifecycle action must not be replayed.
1102+
SwitchoverDispatchOutcomeUnknown SwitchoverDispatchState = "OutcomeUnknown"
1103+
)
1104+
10441105
type ActionTask struct {
10451106
// Represents the name of the task.
10461107
// +kubebuilder:validation:Required

apis/operations/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/operations.kubeblocks.io_opsrequests.yaml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,8 +3264,9 @@ spec:
32643264
object belongs to.
32653265
type: string
32663266
message:
3267-
description: Provides a human-readable explanation of
3268-
the object's condition.
3267+
description: |-
3268+
Provides a human-readable explanation of the object's condition.
3269+
Controllers must not parse this field as durable state or a versioned protocol.
32693270
type: string
32703271
objectKey:
32713272
description: |-
@@ -3286,6 +3287,64 @@ spec:
32863287
- Failed
32873288
- Succeed
32883289
type: string
3290+
switchoverDispatch:
3291+
description: |-
3292+
Records the durable dispatch state for a Switchover lifecycle action.
3293+
This structured field is the controller protocol; Message remains display-only.
3294+
properties:
3295+
candidateName:
3296+
description: CandidateName is the optional target
3297+
instance requested by the Switchover.
3298+
maxLength: 256
3299+
type: string
3300+
componentName:
3301+
description: ComponentName is the logical component
3302+
or sharding name used by the writer.
3303+
maxLength: 256
3304+
minLength: 1
3305+
type: string
3306+
instanceName:
3307+
description: InstanceName is the source instance requested
3308+
by the Switchover.
3309+
maxLength: 256
3310+
minLength: 1
3311+
type: string
3312+
opsRequestUID:
3313+
description: OpsRequestUID binds the dispatch to one
3314+
exact OpsRequest incarnation.
3315+
maxLength: 128
3316+
minLength: 1
3317+
type: string
3318+
state:
3319+
description: |-
3320+
State records whether the external call is still unconfirmed, was resolved
3321+
by its caller, or crossed a restart with no retained result.
3322+
enum:
3323+
- Claimed
3324+
- Resolved
3325+
- OutcomeUnknown
3326+
type: string
3327+
token:
3328+
description: Token uniquely identifies the writer
3329+
that committed the dispatch claim.
3330+
maxLength: 256
3331+
minLength: 1
3332+
type: string
3333+
version:
3334+
description: |-
3335+
Version selects the protocol contract used by this status value.
3336+
Readers must fail closed when they do not support the recorded version.
3337+
maxLength: 16
3338+
minLength: 1
3339+
type: string
3340+
required:
3341+
- componentName
3342+
- instanceName
3343+
- opsRequestUID
3344+
- state
3345+
- token
3346+
- version
3347+
type: object
32893348
required:
32903349
- status
32913350
type: object

deploy/helm/crds/operations.kubeblocks.io_opsrequests.yaml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,8 +3264,9 @@ spec:
32643264
object belongs to.
32653265
type: string
32663266
message:
3267-
description: Provides a human-readable explanation of
3268-
the object's condition.
3267+
description: |-
3268+
Provides a human-readable explanation of the object's condition.
3269+
Controllers must not parse this field as durable state or a versioned protocol.
32693270
type: string
32703271
objectKey:
32713272
description: |-
@@ -3286,6 +3287,64 @@ spec:
32863287
- Failed
32873288
- Succeed
32883289
type: string
3290+
switchoverDispatch:
3291+
description: |-
3292+
Records the durable dispatch state for a Switchover lifecycle action.
3293+
This structured field is the controller protocol; Message remains display-only.
3294+
properties:
3295+
candidateName:
3296+
description: CandidateName is the optional target
3297+
instance requested by the Switchover.
3298+
maxLength: 256
3299+
type: string
3300+
componentName:
3301+
description: ComponentName is the logical component
3302+
or sharding name used by the writer.
3303+
maxLength: 256
3304+
minLength: 1
3305+
type: string
3306+
instanceName:
3307+
description: InstanceName is the source instance requested
3308+
by the Switchover.
3309+
maxLength: 256
3310+
minLength: 1
3311+
type: string
3312+
opsRequestUID:
3313+
description: OpsRequestUID binds the dispatch to one
3314+
exact OpsRequest incarnation.
3315+
maxLength: 128
3316+
minLength: 1
3317+
type: string
3318+
state:
3319+
description: |-
3320+
State records whether the external call is still unconfirmed, was resolved
3321+
by its caller, or crossed a restart with no retained result.
3322+
enum:
3323+
- Claimed
3324+
- Resolved
3325+
- OutcomeUnknown
3326+
type: string
3327+
token:
3328+
description: Token uniquely identifies the writer
3329+
that committed the dispatch claim.
3330+
maxLength: 256
3331+
minLength: 1
3332+
type: string
3333+
version:
3334+
description: |-
3335+
Version selects the protocol contract used by this status value.
3336+
Readers must fail closed when they do not support the recorded version.
3337+
maxLength: 16
3338+
minLength: 1
3339+
type: string
3340+
required:
3341+
- componentName
3342+
- instanceName
3343+
- opsRequestUID
3344+
- state
3345+
- token
3346+
- version
3347+
type: object
32893348
required:
32903349
- status
32913350
type: object

0 commit comments

Comments
 (0)