-
Notifications
You must be signed in to change notification settings - Fork 38
K8SPS-642: Point-in-time recovery #1252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c2aa9d
1496ff3
925659c
634a30d
6e76ed0
b0795ec
aeb61df
2930942
35558b4
de34a01
8b38964
0712c3a
eb3219c
2e9433d
cd39d9e
031f250
b7d0b94
0a6773c
7cc8a91
e5d30c0
7bd1bcf
30aa87c
f97ad4e
29df4dc
78338f7
a001e39
43ceaf7
b15ce3c
abbb0ef
4c2315e
9658e72
692053c
9e01898
d806f3d
fea7a94
17f6aff
a2a2c8a
f4349db
b17dd59
0544e22
351dbba
d075fe6
a4c1e46
7761dba
32b7646
54bd542
0e313a2
37f2332
e97a5c1
3b86683
4d844a1
9a03722
9d7ae2e
68d3859
ccebfc4
11f6e16
3b1d879
204fc59
ed25bc0
2b3d10d
6a3973b
e04e0af
3e2bff9
d9b7806
7584be2
8b3ace8
42ca350
ffc3da6
e95c033
24387dd
18d1a7b
a7c2052
88562d7
7bab67a
9b7561c
cc4625e
eb74763
f780ffd
df264a3
9c06f7a
eb9951f
4fd8584
b642ed1
ecb632a
b7997fc
2a10e7b
c59fb23
11d251d
bcf6607
32d7307
0fddd84
aaf2e86
4d42333
86ee68b
180f8da
6bccf91
1631578
4d8b484
8b1acff
62adfcd
3c79b9a
6f4795a
c77b10f
d86fe9f
5734227
6f6ee9f
001e66b
6d717fe
ab77448
14fd413
d09f043
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -141,6 +141,8 @@ func (t ClusterType) isValid() bool { | |||||
| return false | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="has(self.image) && self.image != ''",message="mysql.image is required" | ||||||
| // +kubebuilder:validation:XValidation:rule="has(self.size) && self.size > 0",message="mysql.size must be greater than 0" | ||||||
| type MySQLSpec struct { | ||||||
| // +kubebuilder:validation:Enum=group-replication;async | ||||||
| // +kubebuilder:default=group-replication | ||||||
|
|
@@ -176,6 +178,8 @@ type SidecarPVC struct { | |||||
| Spec corev1.PersistentVolumeClaimSpec `json:"spec"` | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || (has(self.image) && self.image != '')",message="orchestrator.image is required when orchestrator is enabled" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [gofmt] reported by reviewdog 🐶
Suggested change
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || (has(self.size) && self.size > 0)",message="orchestrator.size must be greater than 0 when orchestrator is enabled" | ||||||
| type OrchestratorSpec struct { | ||||||
| Enabled bool `json:"enabled,omitempty"` | ||||||
| Expose ServiceExpose `json:"expose,omitempty"` | ||||||
|
|
@@ -184,7 +188,7 @@ type OrchestratorSpec struct { | |||||
| } | ||||||
|
|
||||||
| type ContainerSpec struct { | ||||||
| Image string `json:"image"` | ||||||
| Image string `json:"image,omitempty"` | ||||||
| ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` | ||||||
| ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` | ||||||
| Resources corev1.ResourceRequirements `json:"resources,omitempty"` | ||||||
|
|
@@ -200,7 +204,6 @@ type ContainerSpec struct { | |||||
| } | ||||||
|
|
||||||
| type PodSpec struct { | ||||||
| // +kubebuilder:validation:Required | ||||||
| Size int32 `json:"size,omitempty"` | ||||||
| Annotations map[string]string `json:"annotations,omitempty"` | ||||||
| Labels map[string]string `json:"labels,omitempty"` | ||||||
|
|
@@ -286,9 +289,10 @@ func (s *PodSpec) GetInitSpec(cr *PerconaServerMySQL) InitContainerSpec { | |||||
| return *s.InitContainer | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || (has(self.image) && self.image != '')",message="pmm.image is required when pmm is enabled" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [gofmt] reported by reviewdog 🐶
Suggested change
|
||||||
| type PMMSpec struct { | ||||||
| Enabled bool `json:"enabled,omitempty"` | ||||||
| Image string `json:"image"` | ||||||
| Image string `json:"image,omitempty"` | ||||||
| MySQLParams string `json:"mysqlParams,omitempty"` | ||||||
| ServerHost string `json:"serverHost,omitempty"` | ||||||
| Resources corev1.ResourceRequirements `json:"resources,omitempty"` | ||||||
|
|
@@ -513,6 +517,10 @@ func (b *BackupStorageAzureSpec) ContainerAndPrefix() (string, string) { | |||||
| return container, prefix | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || has(self.binlogServer)",message="binlogServer is required when pitr is enabled" | ||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || !has(self.binlogServer) || (has(self.binlogServer.image) && self.binlogServer.image != '')",message="binlogServer.image is required when pitr is enabled" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [gofmt] reported by reviewdog 🐶
Suggested change
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || !has(self.binlogServer) || (has(self.binlogServer.size) && self.binlogServer.size > 0)",message="binlogServer.size is required when pitr is enabled" | ||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || !has(self.binlogServer) || (has(self.binlogServer.serverId) && self.binlogServer.serverId > 0)",message="binlogServer.serverId is required when pitr is enabled" | ||||||
| type PiTRSpec struct { | ||||||
| Enabled bool `json:"enabled,omitempty"` | ||||||
|
|
||||||
|
|
@@ -523,19 +531,39 @@ type BinlogServerStorageSpec struct { | |||||
| S3 *BackupStorageS3Spec `json:"s3,omitempty"` | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="!has(self.size) || self.size <= 1",message="binlogServer size cannot be more than 1" | ||||||
| type BinlogServerSpec struct { | ||||||
| Storage BinlogServerStorageSpec `json:"storage"` | ||||||
| Storage BinlogServerStorageSpec `json:"storage,omitempty"` | ||||||
|
|
||||||
| // The number of seconds the MySQL client library will wait to establish a connection with a remote host | ||||||
| ConnectTimeout int32 `json:"connectTimeout"` | ||||||
| // +kubebuilder:default=30 | ||||||
| ConnectTimeout int32 `json:"connectTimeout,omitempty"` | ||||||
| // The number of seconds the MySQL client library will wait to read data from a remote server. | ||||||
| ReadTimeout int32 `json:"readTimeout"` | ||||||
| // +kubebuilder:default=30 | ||||||
| ReadTimeout int32 `json:"readTimeout,omitempty"` | ||||||
| // The number of seconds the MySQL client library will wait to write data to a remote server. | ||||||
| WriteTimeout int32 `json:"writeTimeout"` | ||||||
| // +kubebuilder:default=30 | ||||||
| WriteTimeout int32 `json:"writeTimeout,omitempty"` | ||||||
| // Specifies the server ID that the utility will be using when connecting to a remote MySQL server | ||||||
| ServerID int32 `json:"serverId"` | ||||||
| ServerID int32 `json:"serverId,omitempty"` | ||||||
| // The number of seconds the utility will spend in disconnected mode between reconnection attempts. | ||||||
| IdleTime int32 `json:"idleTime"` | ||||||
| // +kubebuilder:default=30 | ||||||
| IdleTime int32 `json:"idleTime,omitempty"` | ||||||
| // SSLMode specifies the SSL mode for the connection to MySQL. | ||||||
| // +kubebuilder:default="verify_identity" | ||||||
| SSLMode string `json:"sslMode,omitempty"` | ||||||
| // VerifyChecksum enables checksum verification during replication. | ||||||
| // +kubebuilder:default=true | ||||||
| VerifyChecksum *bool `json:"verifyChecksum,omitempty"` | ||||||
| // RewriteFileSize specifies the maximum binlog file size for rewrite. | ||||||
| // +kubebuilder:default="128M" | ||||||
| RewriteFileSize string `json:"rewriteFileSize,omitempty"` | ||||||
| // CheckpointSize specifies the storage checkpoint size. | ||||||
| // +kubebuilder:default="16M" | ||||||
| CheckpointSize string `json:"checkpointSize,omitempty"` | ||||||
| // CheckpointInterval specifies the storage checkpoint interval. | ||||||
| // +kubebuilder:default="30s" | ||||||
| CheckpointInterval string `json:"checkpointInterval,omitempty"` | ||||||
|
|
||||||
| PodSpec `json:",inline"` | ||||||
| } | ||||||
|
|
@@ -545,6 +573,8 @@ type ProxySpec struct { | |||||
| HAProxy *HAProxySpec `json:"haproxy,omitempty"` | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || (has(self.image) && self.image != '')",message="router.image is required when router is enabled" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [gofmt] reported by reviewdog 🐶
Suggested change
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || (has(self.size) && self.size > 0)",message="router.size must be greater than 0 when router is enabled" | ||||||
| type MySQLRouterSpec struct { | ||||||
| Enabled bool `json:"enabled,omitempty"` | ||||||
|
|
||||||
|
|
@@ -555,10 +585,13 @@ type MySQLRouterSpec struct { | |||||
| PodSpec `json:",inline"` | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="has(self.image) && self.image != ''",message="toolkit.image is required" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [gofmt] reported by reviewdog 🐶
Suggested change
|
||||||
| type ToolkitSpec struct { | ||||||
| ContainerSpec `json:",inline"` | ||||||
| } | ||||||
|
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || (has(self.image) && self.image != '')",message="haproxy.image is required when haproxy is enabled" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [gofmt] reported by reviewdog 🐶
Suggested change
|
||||||
| // +kubebuilder:validation:XValidation:rule="!(has(self.enabled) && self.enabled) || (has(self.size) && self.size > 0)",message="haproxy.size must be greater than 0 when haproxy is enabled" | ||||||
| type HAProxySpec struct { | ||||||
| Enabled bool `json:"enabled,omitempty"` | ||||||
|
|
||||||
|
|
@@ -645,6 +678,7 @@ type PerconaServerMySQLStatus struct { // INSERT ADDITIONAL STATUS FIELD - defin | |||||
| Orchestrator StatefulAppStatus `json:"orchestrator,omitempty"` | ||||||
| HAProxy StatefulAppStatus `json:"haproxy,omitempty"` | ||||||
| Router StatefulAppStatus `json:"router,omitempty"` | ||||||
| BinlogServer StatefulAppStatus `json:"binlogServer,omitempty"` | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fine, but for future, let's try to add these as conditions |
||||||
| State StatefulAppState `json:"state,omitempty"` | ||||||
| BackupVersion string `json:"backupVersion,omitempty"` | ||||||
| PMMVersion string `json:"pmmVersion,omitempty"` | ||||||
|
|
@@ -1014,11 +1048,46 @@ func (cr *PerconaServerMySQL) CheckNSetDefaults(_ context.Context, serverVersion | |||||
| cr.Spec.Backup.PiTR.BinlogServer = new(BinlogServerSpec) | ||||||
| } | ||||||
|
|
||||||
| if cr.Spec.Backup.PiTR.BinlogServer != nil { | ||||||
| bls := cr.Spec.Backup.PiTR.BinlogServer | ||||||
| if bls.SSLMode == "" { | ||||||
| bls.SSLMode = "verify_identity" | ||||||
| } | ||||||
| if bls.VerifyChecksum == nil { | ||||||
| t := true | ||||||
| bls.VerifyChecksum = &t | ||||||
| } | ||||||
| if bls.RewriteFileSize == "" { | ||||||
| bls.RewriteFileSize = "128M" | ||||||
| } | ||||||
| if bls.CheckpointSize == "" { | ||||||
| bls.CheckpointSize = "16M" | ||||||
| } | ||||||
| if bls.CheckpointInterval == "" { | ||||||
| bls.CheckpointInterval = "30s" | ||||||
| } | ||||||
| if bls.ConnectTimeout == 0 { | ||||||
| bls.ConnectTimeout = 30 | ||||||
| } | ||||||
| if bls.ReadTimeout == 0 { | ||||||
| bls.ReadTimeout = 30 | ||||||
| } | ||||||
| if bls.WriteTimeout == 0 { | ||||||
| bls.WriteTimeout = 30 | ||||||
| } | ||||||
| if bls.IdleTime == 0 { | ||||||
| bls.IdleTime = 30 | ||||||
| } | ||||||
|
Comment on lines
+1053
to
+1080
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets set defaults on CRD also |
||||||
| } | ||||||
|
|
||||||
| if cr.Spec.Pause { | ||||||
| cr.Spec.MySQL.Size = 0 | ||||||
| cr.Spec.Orchestrator.Size = 0 | ||||||
| cr.Spec.Proxy.Router.Size = 0 | ||||||
| cr.Spec.Proxy.HAProxy.Size = 0 | ||||||
| if cr.Spec.Backup.PiTR.BinlogServer != nil { | ||||||
| cr.Spec.Backup.PiTR.BinlogServer.Size = 0 | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if cr.Spec.SecretsName == "" { | ||||||
|
|
@@ -1290,7 +1359,6 @@ const ( | |||||
| UpgradeStrategyDisabled = "disabled" | ||||||
| UpgradeStrategyNever = "never" | ||||||
| UpgradeStrategyRecommended = "recommended" | ||||||
| UpgradeStrategyLatest = "latest" | ||||||
| ) | ||||||
|
|
||||||
| func (s *BackupStorageSpec) Equals(other *BackupStorageSpec) bool { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,24 @@ type PerconaServerMySQLRestoreSpec struct { | |
| BackupName string `json:"backupName,omitempty"` | ||
| BackupSource *PerconaServerMySQLBackupStatus `json:"backupSource,omitempty"` | ||
| ContainerOptions *BackupContainerOptions `json:"containerOptions,omitempty"` | ||
| PITR *RestorePITRSpec `json:"pitr,omitempty"` | ||
| } | ||
|
|
||
| type RestorePITRSpec struct { | ||
| // +kubebuilder:validation:Enum=gtid;date | ||
| Type PITRType `json:"type"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to add validation here? If user set type date, we need to have correct date? (the same for gtid) |
||
| Date string `json:"date,omitempty"` | ||
| GTID string `json:"gtid,omitempty"` | ||
| Force bool `json:"force,omitempty"` | ||
| } | ||
|
egegunes marked this conversation as resolved.
|
||
|
|
||
| type PITRType string | ||
|
|
||
| const ( | ||
| PITRGtid PITRType = "gtid" | ||
| PITRDate PITRType = "date" | ||
| ) | ||
|
|
||
| type RestoreState string | ||
|
|
||
| const ( | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[gofmt] reported by reviewdog 🐶