Skip to content

Commit

Permalink
add StatefulSet condition and change MySQLClusterCondition to metav1.…
Browse files Browse the repository at this point in the history
…Condition

Signed-off-by: YZ775 <[email protected]>

add envtest

Signed-off-by: YZ775 <[email protected]>

update gomod

Signed-off-by: YZ775 <[email protected]>

update envtest and add e2e

Signed-off-by: YZ775 <[email protected]>

update apidoc

Signed-off-by: YZ775 <[email protected]>

rename

Signed-off-by: YZ775 <[email protected]>

add ObservedGeneration and add partition handling, and update e2e test

Signed-off-by: YZ775 <[email protected]>

remove unnecessary ObservedGeneration and move updateStatus() after reconcileV1StatefulSet() , and update e2e test

Signed-off-by: YZ775 <[email protected]>

add document about UpToDate

Signed-off-by: YZ775 <[email protected]>

update against review

Signed-off-by: YZ775 <[email protected]>

wip

change status to StatefulSetReady and add ReconcileSuccess, and fix unstable test

Signed-off-by: YZ775 <[email protected]>

remove unnecessary condition check

Signed-off-by: YZ775 <[email protected]>

remove redundant assignments in updateStatusByStatefulSet

Signed-off-by: YZ775 <[email protected]>

move updateReconcileStatus in reconcileV1

Signed-off-by: YZ775 <[email protected]>

fix controller test

Signed-off-by: YZ775 <[email protected]>

update documents

Signed-off-by: YZ775 <[email protected]>

update lifecycle_test.go to check StatefulSetReady condition

Signed-off-by: YZ775 <[email protected]>

fix auto generated document

Signed-off-by: YZ775 <[email protected]>

join update status funcion

Signed-off-by: YZ775 <[email protected]>

revert Eventually in envtest

Signed-off-by: YZ775 <[email protected]>

fix multiple Update() call

Signed-off-by: YZ775 <[email protected]>

update docs

Signed-off-by: YZ775 <[email protected]>

fix controller

Signed-off-by: YZ775 <[email protected]>

update condition when sts not found

Signed-off-by: YZ775 <[email protected]>

update test

Signed-off-by: YZ775 <[email protected]>

update lifecycle_test.go

Signed-off-by: YZ775 <[email protected]>

fix condition

Signed-off-by: YZ775 <[email protected]>

fix generation check and err handling

Signed-off-by: YZ775 <[email protected]>

do not show err log when deletion of cluster

Signed-off-by: YZ775 <[email protected]>

add StatefulSet condition and change MySQLClusterCondition to metav1.Condition

Signed-off-by: YZ775 <[email protected]>
  • Loading branch information
YZ775 committed Aug 24, 2023
1 parent 647ee72 commit b7d6985
Show file tree
Hide file tree
Showing 24 changed files with 682 additions and 336 deletions.
35 changes: 6 additions & 29 deletions api/v1beta1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ type MySQLClusterStatus struct {

// Conditions is an array of conditions.
// +optional
Conditions []MySQLClusterCondition `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// CurrentPrimaryIndex is the index of the current primary Pod in StatefulSet.
// Initially, this is zero.
Expand Down Expand Up @@ -287,35 +287,12 @@ type MySQLClusterStatus struct {
ReconcileInfo ReconcileInfo `json:"reconcileInfo"`
}

// MySQLClusterCondition defines the condition of MySQLCluster.
type MySQLClusterCondition struct {
// Type is the type of the condition.
Type MySQLClusterConditionType `json:"type"`

// Status is the status of the condition.
Status corev1.ConditionStatus `json:"status"`

// Reason is a one-word CamelCase reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty"`

// Message is a human-readable message indicating details about last transition.
// +optional
Message string `json:"message,omitempty"`

// LastTransitionTime is the last time the condition transits from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
}

// MySQLClusterConditionType is the type of MySQLCluster condition.
// +kubebuilder:validation:Enum=Initialized;Available;Healthy
type MySQLClusterConditionType string

// Valid values for MySQLClusterConditionType
const (
ConditionInitialized MySQLClusterConditionType = "Initialized"
ConditionAvailable MySQLClusterConditionType = "Available"
ConditionHealthy MySQLClusterConditionType = "Healthy"
ConditionInitialized string = "Initialized"
ConditionAvailable string = "Available"
ConditionHealthy string = "Healthy"
ConditionStatefulSetReady string = "StatefulSetReady"
ConditionReconcileSuccess string = "ReconcileSuccess"
)

// BackupStatus represents the status of the last successful backup.
Expand Down
42 changes: 2 additions & 40 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 6 additions & 29 deletions api/v1beta2/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ type MySQLClusterStatus struct {

// Conditions is an array of conditions.
// +optional
Conditions []MySQLClusterCondition `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// CurrentPrimaryIndex is the index of the current primary Pod in StatefulSet.
// Initially, this is zero.
Expand Down Expand Up @@ -601,35 +601,12 @@ type MySQLClusterStatus struct {
ReconcileInfo ReconcileInfo `json:"reconcileInfo"`
}

// MySQLClusterCondition defines the condition of MySQLCluster.
type MySQLClusterCondition struct {
// Type is the type of the condition.
Type MySQLClusterConditionType `json:"type"`

// Status is the status of the condition.
Status corev1.ConditionStatus `json:"status"`

// Reason is a one-word CamelCase reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty"`

// Message is a human-readable message indicating details about last transition.
// +optional
Message string `json:"message,omitempty"`

// LastTransitionTime is the last time the condition transits from one status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
}

// MySQLClusterConditionType is the type of MySQLCluster condition.
// +kubebuilder:validation:Enum=Initialized;Available;Healthy
type MySQLClusterConditionType string

// Valid values for MySQLClusterConditionType
const (
ConditionInitialized MySQLClusterConditionType = "Initialized"
ConditionAvailable MySQLClusterConditionType = "Available"
ConditionHealthy MySQLClusterConditionType = "Healthy"
ConditionInitialized string = "Initialized"
ConditionAvailable string = "Available"
ConditionHealthy string = "Healthy"
ConditionStatefulSetReady string = "StatefulSetReady"
ConditionReconcileSuccess string = "ReconcileSuccess"
)

// BackupStatus represents the status of the last successful backup.
Expand Down
19 changes: 2 additions & 17 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 46 additions & 20 deletions charts/moco/templates/generated/crds/moco_crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9596,30 +9596,43 @@ spec:
conditions:
description: Conditions is an array of conditions.
items:
description: MySQLClusterCondition defines the condition of MyS
description: Condition contains details for one aspect of the c
properties:
lastTransitionTime:
description: 'LastTransitionTime is the last time the condition '
description: 'lastTransitionTime is the last time the condition '
format: date-time
type: string
message:
description: Message is a human-readable message indicating det
description: message is a human readable message indicating det
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.
format: int64
minimum: 0
type: integer
reason:
description: Reason is a one-word CamelCase reason for the cond
description: reason contains a programmatic identifier indicati
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: Status is the status of the condition.
description: status of the condition, one of True, False, Unkno
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: Type is the type of the condition.
enum:
- Initialized
- Available
- Healthy
description: type of condition in CamelCase or in foo.example.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
Expand Down Expand Up @@ -15339,30 +15352,43 @@ spec:
conditions:
description: Conditions is an array of conditions.
items:
description: MySQLClusterCondition defines the condition of MyS
description: Condition contains details for one aspect of the c
properties:
lastTransitionTime:
description: 'LastTransitionTime is the last time the condition '
description: 'lastTransitionTime is the last time the condition '
format: date-time
type: string
message:
description: Message is a human-readable message indicating det
description: message is a human readable message indicating det
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.
format: int64
minimum: 0
type: integer
reason:
description: Reason is a one-word CamelCase reason for the cond
description: reason contains a programmatic identifier indicati
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: Status is the status of the condition.
description: status of the condition, one of True, False, Unkno
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: Type is the type of the condition.
enum:
- Initialized
- Available
- Healthy
description: type of condition in CamelCase or in foo.example.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
Expand Down
Loading

0 comments on commit b7d6985

Please sign in to comment.