diff --git a/api/v1alpha1/cluster_types.go b/api/v1alpha1/cluster_types.go index 852469fcc..664bf24f1 100644 --- a/api/v1alpha1/cluster_types.go +++ b/api/v1alpha1/cluster_types.go @@ -43,7 +43,7 @@ type ClusterSpec struct { // MysqlOpts is the options of MySQL container. // +optional - // +kubebuilder:default:={rootPassword: "", rootHost: "localhost", user: "qc_usr", password: "Qing@123", database: "qingcloud", initTokuDB: true, resources: {limits: {cpu: "500m", memory: "1Gi"}, requests: {cpu: "100m", memory: "256Mi"}}} + // +kubebuilder:default:={rootPassword: "", rootHost: "localhost", user: "rdb_usr", password: "RadonDB@123", database: "radondb", initTokuDB: true, resources: {limits: {cpu: "500m", memory: "1Gi"}, requests: {cpu: "100m", memory: "256Mi"}}} MysqlOpts MysqlOpts `json:"mysqlOpts,omitempty"` // XenonOpts is the options of xenon container. @@ -101,7 +101,7 @@ type MysqlOpts struct { // Username of new user to create. // Only be a combination of letters, numbers or underlines. The length can not exceed 26 characters. // +optional - // +kubebuilder:default:="qc_usr" + // +kubebuilder:default:="rdb_usr" // +kubebuilder:validation:Pattern="^[A-Za-z0-9_]{2,26}$" User string `json:"user,omitempty"` @@ -109,13 +109,13 @@ type MysqlOpts struct { // Only be a combination of uppercase letters, lowercase letters, numbers or special characters. // Special characters are supported: @#$%^&*_+-=. // +optional - // +kubebuilder:default:="Qing@123" + // +kubebuilder:default:="RadonDB@123" // +kubebuilder:validation:Pattern="^[A-Za-z0-9@#$%^&*_+\\-=]{8,32}$" Password string `json:"password,omitempty"` // Name for new database to create. // +optional - // +kubebuilder:default:="qingcloud" + // +kubebuilder:default:="radondb" Database string `json:"database,omitempty"` // InitTokuDB represents if install tokudb engine. diff --git a/backup/syncer/job.go b/backup/syncer/job.go index e71de9952..366e1c623 100644 --- a/backup/syncer/job.go +++ b/backup/syncer/job.go @@ -82,7 +82,6 @@ func (s *jobSyncer) updateStatus(job *batchv1.Job) { // check for completion condition if cond := jobCondition(batchv1.JobComplete, job); cond != nil { s.backup.UpdateStatusCondition(v1alpha1.BackupComplete, cond.Status, cond.Reason, cond.Message) - if cond.Status == corev1.ConditionTrue { s.backup.Status.Completed = true } @@ -91,7 +90,6 @@ func (s *jobSyncer) updateStatus(job *batchv1.Job) { // check for failed condition if cond := jobCondition(batchv1.JobFailed, job); cond != nil { s.backup.UpdateStatusCondition(v1alpha1.BackupFailed, cond.Status, cond.Reason, cond.Message) - if cond.Status == corev1.ConditionTrue { s.backup.Status.Completed = true } diff --git a/charts/helm/templates/secrets.yaml b/charts/helm/templates/secrets.yaml index 1388ca2fd..c916e361c 100644 --- a/charts/helm/templates/secrets.yaml +++ b/charts/helm/templates/secrets.yaml @@ -16,7 +16,7 @@ data: mysql-root-password: {{ randAlphaNum 12 | b64enc | quote }} {{- end }} {{- end }} - {{- if and .Values.mysql.mysqlUser (and (ne .Values.mysql.mysqlUser "qc_repl") (ne .Values.mysql.mysqlUser "root")) }} + {{- if and .Values.mysql.mysqlUser (and (ne .Values.mysql.mysqlUser "rdb_repl") (ne .Values.mysql.mysqlUser "root")) }} {{- if .Values.mysql.mysqlPassword }} mysql-password: {{ .Values.mysql.mysqlPassword | b64enc | quote }} {{- else }} diff --git a/charts/helm/values.yaml b/charts/helm/values.yaml index 5288c18f7..483fa066a 100644 --- a/charts/helm/values.yaml +++ b/charts/helm/values.yaml @@ -30,9 +30,9 @@ mysql: # mysqlRootPassword: mysqlReplicationPassword: Repl_123 - mysqlUser: qingcloud - mysqlPassword: Qing@123 - mysqlDatabase: qingcloud + mysqlUser: radondb + mysqlPassword: RadonDB@123 + mysqlDatabase: radondb initTokudb: false ## Additionnal arguments that are passed to the MySQL container. diff --git a/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml b/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml index 57544482d..294e73019 100644 --- a/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml +++ b/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml @@ -48,7 +48,7 @@ spec: description: HostName represents the host for which to take backup type: string image: - default: radondb/mysql-sidecar:0.1.88 + default: radondb/mysql-sidecar:latest description: To specify the image that will be used for sidecar container. type: string required: diff --git a/charts/mysql-operator/crds/mysql.radondb.com_clusters.yaml b/charts/mysql-operator/crds/mysql.radondb.com_clusters.yaml index 8c8c4670c..1cf827c36 100644 --- a/charts/mysql-operator/crds/mysql.radondb.com_clusters.yaml +++ b/charts/mysql-operator/crds/mysql.radondb.com_clusters.yaml @@ -117,9 +117,9 @@ spec: type: string mysqlOpts: default: - database: qingcloud + database: radondb initTokuDB: true - password: Qing@123 + password: RadonDB@123 resources: limits: cpu: 500m @@ -129,11 +129,11 @@ spec: memory: 256Mi rootHost: localhost rootPassword: "" - user: qc_usr + user: rdb_usr description: MysqlOpts is the options of MySQL container. properties: database: - default: qingcloud + default: radondb description: Name for new database to create. type: string initTokuDB: @@ -147,7 +147,7 @@ spec: file. type: object password: - default: Qing@123 + default: RadonDB@123 description: 'Password for the new user, must be 8~32 characters long. Only be a combination of uppercase letters, lowercase letters, numbers or special characters. Special characters are @@ -200,7 +200,7 @@ spec: pattern: ^$|^[A-Za-z0-9@#$%^&*_+\-=]{8,32}$ type: string user: - default: qc_usr + default: rdb_usr description: Username of new user to create. Only be a combination of letters, numbers or underlines. The length can not exceed 26 characters. diff --git a/config/crd/bases/mysql.radondb.com_backups.yaml b/config/crd/bases/mysql.radondb.com_backups.yaml index 57544482d..294e73019 100644 --- a/config/crd/bases/mysql.radondb.com_backups.yaml +++ b/config/crd/bases/mysql.radondb.com_backups.yaml @@ -48,7 +48,7 @@ spec: description: HostName represents the host for which to take backup type: string image: - default: radondb/mysql-sidecar:0.1.88 + default: radondb/mysql-sidecar:latest description: To specify the image that will be used for sidecar container. type: string required: diff --git a/config/crd/bases/mysql.radondb.com_clusters.yaml b/config/crd/bases/mysql.radondb.com_clusters.yaml index 8c8c4670c..1cf827c36 100644 --- a/config/crd/bases/mysql.radondb.com_clusters.yaml +++ b/config/crd/bases/mysql.radondb.com_clusters.yaml @@ -117,9 +117,9 @@ spec: type: string mysqlOpts: default: - database: qingcloud + database: radondb initTokuDB: true - password: Qing@123 + password: RadonDB@123 resources: limits: cpu: 500m @@ -129,11 +129,11 @@ spec: memory: 256Mi rootHost: localhost rootPassword: "" - user: qc_usr + user: rdb_usr description: MysqlOpts is the options of MySQL container. properties: database: - default: qingcloud + default: radondb description: Name for new database to create. type: string initTokuDB: @@ -147,7 +147,7 @@ spec: file. type: object password: - default: Qing@123 + default: RadonDB@123 description: 'Password for the new user, must be 8~32 characters long. Only be a combination of uppercase letters, lowercase letters, numbers or special characters. Special characters are @@ -200,7 +200,7 @@ spec: pattern: ^$|^[A-Za-z0-9@#$%^&*_+\-=]{8,32}$ type: string user: - default: qc_usr + default: rdb_usr description: Username of new user to create. Only be a combination of letters, numbers or underlines. The length can not exceed 26 characters. diff --git a/config/samples/mysql_v1alpha1_cluster.yaml b/config/samples/mysql_v1alpha1_cluster.yaml index c2fcb64f1..4c16f21b5 100644 --- a/config/samples/mysql_v1alpha1_cluster.yaml +++ b/config/samples/mysql_v1alpha1_cluster.yaml @@ -16,9 +16,9 @@ spec: mysqlOpts: rootPassword: "" rootHost: localhost - user: qc_usr - password: Qing@123 - database: qingcloud + user: rdb_usr + password: RadonDB@123 + database: randondb initTokuDB: true # A simple map between string and string. diff --git a/controllers/backup_controller.go b/controllers/backup_controller.go index b2d538f83..6ba47d20c 100644 --- a/controllers/backup_controller.go +++ b/controllers/backup_controller.go @@ -91,14 +91,14 @@ func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr } // Clear the backup, Just keep historyLimit len - if err = r.clearHistoryJob(ctx, req, backup); err != nil { + if err = r.clearHistoryJob(ctx, req, *backup.Spec.HistoryLimit); err != nil { return reconcile.Result{}, err } return ctrl.Result{}, nil } // Clear the History finished Jobs over HistoryLimit. -func (r *BackupReconciler) clearHistoryJob(ctx context.Context, req ctrl.Request, backup *backup.Backup) error { +func (r *BackupReconciler) clearHistoryJob(ctx context.Context, req ctrl.Request, historyLimit int32) error { log := log.Log.WithName("controllers").WithName("Backup") backups := batchv1.JobList{} labelSet := labels.Set{"Type": utils.BackupJobTypeName} @@ -123,7 +123,7 @@ func (r *BackupReconciler) clearHistoryJob(ctx context.Context, req ctrl.Request }) for i, job := range finishedBackups { - if int32(i) >= int32(len(finishedBackups))-*backup.Spec.HistoryLimit { + if int32(i) >= int32(len(finishedBackups))-historyLimit { break } if err := r.Delete(ctx, job, client.PropagationPolicy(metav1.DeletePropagationBackground)); client.IgnoreNotFound(err) != nil { @@ -155,7 +155,7 @@ func (r *BackupReconciler) updateBackup(savedBackup *apiv1alpha1.Backup, backup log.Info("update backup object status") if err := r.Status().Update(context.TODO(), backup.Unwrap()); err != nil { log.Error(err, fmt.Sprintf("update status backup %s/%s", backup.Name, backup.Namespace), - "backupStatus", backup.Status) + "backupStatus", backup.Status, "saveBackupStatus", savedBackup.Status) return err } } diff --git a/utils/constants.go b/utils/constants.go index f10229402..9e88e625f 100644 --- a/utils/constants.go +++ b/utils/constants.go @@ -62,11 +62,11 @@ const ( XenonPeerPort = 6601 // The name of the MySQL replication user. - ReplicationUser = "qc_repl" + ReplicationUser = "rdb_repl" // The name of the MySQL metrics user. - MetricsUser = "qc_metrics" + MetricsUser = "rdb_metrics" // The MySQL user used for operator to connect to the mysql node for configuration. - OperatorUser = "qc_operator" + OperatorUser = "rdb_operator" // xtrabackup http server user BackupUser = "sys_backup"