From 11bcc17e6c00177a07f2d143f5c0c96842314ce0 Mon Sep 17 00:00:00 2001 From: yuyi Date: Thu, 19 Oct 2023 17:58:03 +0800 Subject: [PATCH] fix: test for 2.0.0 compatibility --- api/v1alpha1/monitor_template.go | 5 +- api/v1alpha1/obtenantbackuppolicy_webhook.go | 30 ++-- api/v1alpha1/zz_generated.deepcopy.go | 5 - .../oceanbase.oceanbase.com_obclusters.yaml | 20 --- .../oceanbase.oceanbase.com_observers.yaml | 20 --- ....oceanbase.com_obtenantbackuppolicies.yaml | 4 - .../oceanbase.oceanbase.com_obzones.yaml | 20 --- deploy/crd.yaml | 107 +++++------- deploy/operator.yaml | 159 +++++------------- deploy/tenant_op_activate.yaml | 20 +-- deploy/tenant_op_switchover.yaml | 20 +-- deploy/tenant_op_switchover_back.yaml | 35 ---- deploy/tenant_restore_wrong.yaml | 70 -------- pkg/oceanbase/model/system.go | 8 +- pkg/resource/observer_task.go | 17 +- pkg/resource/obtenantbackuppolicy_task.go | 52 +++--- 16 files changed, 130 insertions(+), 462 deletions(-) delete mode 100644 deploy/tenant_op_switchover_back.yaml delete mode 100644 deploy/tenant_restore_wrong.yaml diff --git a/api/v1alpha1/monitor_template.go b/api/v1alpha1/monitor_template.go index 3f860ec34..e9d2a1588 100644 --- a/api/v1alpha1/monitor_template.go +++ b/api/v1alpha1/monitor_template.go @@ -13,7 +13,6 @@ See the Mulan PSL v2 for more details. package v1alpha1 type MonitorTemplate struct { - Image string `json:"image"` - Resource *ResourceSpec `json:"resource,omitempty"` - Storage *ObagentStorageSpec `json:"storage"` + Image string `json:"image"` + Resource *ResourceSpec `json:"resource,omitempty"` } diff --git a/api/v1alpha1/obtenantbackuppolicy_webhook.go b/api/v1alpha1/obtenantbackuppolicy_webhook.go index 4d6bf52ff..17342d9e2 100644 --- a/api/v1alpha1/obtenantbackuppolicy_webhook.go +++ b/api/v1alpha1/obtenantbackuppolicy_webhook.go @@ -156,7 +156,16 @@ func (r *OBTenantBackupPolicy) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *OBTenantBackupPolicy) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - _ = old + currentResource := old.(*OBTenantBackupPolicy) + if currentResource.Status.Status == constants.BackupPolicyStatusRunning { + if r.Spec.DataBackup.EncryptionSecret != currentResource.Spec.DataBackup.EncryptionSecret { + return nil, field.Invalid( + field.NewPath("spec").Child("dataBackup").Child("encryptionSecret"), + r.Spec.DataBackup.EncryptionSecret, + "encryptionSecret can not be changed when backup policy is running, please pause the backup policy first", + ) + } + } return nil, r.validateBackupPolicy() } @@ -197,18 +206,12 @@ func (r *OBTenantBackupPolicy) validateBackupPolicy() error { return field.Invalid(field.NewPath("spec").Child("dataBackup").Child("encryptionSecret"), r.Spec.DataBackup.EncryptionSecret, "'password' field not found in encryptionSecret") } } - if r.Spec.DataBackup.Destination.Type == constants.BackupDestTypeOSS { + + if r.Spec.DataBackup.Destination.Type == constants.BackupDestTypeOSS && r.Spec.DataBackup.Destination.OSSAccessSecret != "" { if !ossPathPattern.MatchString(r.Spec.DataBackup.Destination.Path) { return field.Invalid(field.NewPath("spec").Child("dataBackup").Child("destination").Child("path"), r.Spec.DataBackup.Destination.Path, "invalid path, pattern: ^oss://[^/]+/[^/].*\\?host=.+$") } - if r.Spec.DataBackup.Destination.OSSAccessSecret == "" { - return field.Invalid( - field.NewPath("spec").Child("dataBackup").Child("destination").Child("ossAccessSecret"), - r.Spec.DataBackup.Destination.OSSAccessSecret, - "Backup tenant log to OSS type destination must have a OSSAccessSecret", - ) - } secret := &v1.Secret{} err := bakCtl.Get(context.Background(), types.NamespacedName{ Namespace: r.GetNamespace(), @@ -241,18 +244,11 @@ func (r *OBTenantBackupPolicy) validateBackupPolicy() error { } } - if r.Spec.LogArchive.Destination.Type == constants.BackupDestTypeOSS { + if r.Spec.LogArchive.Destination.Type == constants.BackupDestTypeOSS && r.Spec.LogArchive.Destination.OSSAccessSecret != "" { if !ossPathPattern.MatchString(r.Spec.LogArchive.Destination.Path) { return field.Invalid(field.NewPath("spec").Child("logArchive").Child("destination").Child("path"), r.Spec.LogArchive.Destination.Path, "invalid path, pattern: ^oss://[^/]+/[^/].*\\?host=.+$") } - if r.Spec.LogArchive.Destination.OSSAccessSecret == "" { - return field.Invalid( - field.NewPath("spec").Child("logArchive").Child("destination").Child("ossAccessSecret"), - r.Spec.LogArchive.Destination.OSSAccessSecret, - "Backup tenant log to OSS type destination must have a OSSAccessSecret", - ) - } secret := &v1.Secret{} err := bakCtl.Get(context.Background(), types.NamespacedName{ Namespace: r.GetNamespace(), diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 6a86562c0..251ad77f2 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -131,11 +131,6 @@ func (in *MonitorTemplate) DeepCopyInto(out *MonitorTemplate) { *out = new(ResourceSpec) (*in).DeepCopyInto(*out) } - if in.Storage != nil { - in, out := &in.Storage, &out.Storage - *out = new(ObagentStorageSpec) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitorTemplate. diff --git a/config/crd/bases/oceanbase.oceanbase.com_obclusters.yaml b/config/crd/bases/oceanbase.oceanbase.com_obclusters.yaml index a922bc1c7..f0920e321 100644 --- a/config/crd/bases/oceanbase.oceanbase.com_obclusters.yaml +++ b/config/crd/bases/oceanbase.oceanbase.com_obclusters.yaml @@ -1658,28 +1658,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object observer: properties: diff --git a/config/crd/bases/oceanbase.oceanbase.com_observers.yaml b/config/crd/bases/oceanbase.oceanbase.com_observers.yaml index 20b0c1bea..c4d498934 100644 --- a/config/crd/bases/oceanbase.oceanbase.com_observers.yaml +++ b/config/crd/bases/oceanbase.oceanbase.com_observers.yaml @@ -1664,28 +1664,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object nodeSelector: additionalProperties: diff --git a/config/crd/bases/oceanbase.oceanbase.com_obtenantbackuppolicies.yaml b/config/crd/bases/oceanbase.oceanbase.com_obtenantbackuppolicies.yaml index 30152c9da..c07d2319e 100644 --- a/config/crd/bases/oceanbase.oceanbase.com_obtenantbackuppolicies.yaml +++ b/config/crd/bases/oceanbase.oceanbase.com_obtenantbackuppolicies.yaml @@ -991,7 +991,6 @@ spec: - arbitration_service_status - compatibility_mode - create_time - - gmt_create_time - in_recyclebin - locality - locked @@ -1003,14 +1002,11 @@ spec: - recovery_until_scn - replayable_scn - status - - switchover_epoch - - switchover_status - sync_scn - tenant_id - tenant_name - tenant_role - tenant_type - - unit_num type: object required: - status diff --git a/config/crd/bases/oceanbase.oceanbase.com_obzones.yaml b/config/crd/bases/oceanbase.oceanbase.com_obzones.yaml index dcba02be3..fedc43216 100644 --- a/config/crd/bases/oceanbase.oceanbase.com_obzones.yaml +++ b/config/crd/bases/oceanbase.oceanbase.com_obzones.yaml @@ -1651,28 +1651,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object observerTemplate: properties: diff --git a/deploy/crd.yaml b/deploy/crd.yaml index 7180747aa..80e6f8bf9 100644 --- a/deploy/crd.yaml +++ b/deploy/crd.yaml @@ -1755,28 +1755,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object observer: properties: @@ -3780,28 +3760,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object nodeSelector: additionalProperties: @@ -4051,7 +4011,11 @@ spec: type: string type: type: string + required: + - path type: object + encryptionSecret: + type: string fullCrontab: type: string incrementalCrontab: @@ -4088,6 +4052,8 @@ spec: type: string type: type: string + required: + - path type: object switchPieceInterval: type: string @@ -4099,6 +4065,8 @@ spec: type: string suspend: type: boolean + tenantCRName: + type: string tenantName: type: string tenantSecret: @@ -4107,7 +4075,6 @@ spec: - dataBackup - logArchive - obClusterName - - tenantName type: object status: description: OBTenantBackupPolicyStatus defines the observed state of @@ -4515,6 +4482,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -4524,7 +4493,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -4958,7 +4931,6 @@ spec: - arbitration_service_status - compatibility_mode - create_time - - gmt_create_time - in_recyclebin - locality - locked @@ -4970,14 +4942,11 @@ spec: - recovery_until_scn - replayable_scn - status - - switchover_epoch - - switchover_status - sync_scn - tenant_id - tenant_name - tenant_role - tenant_type - - unit_num type: object required: - status @@ -5046,6 +5015,8 @@ spec: spec: description: OBTenantBackupSpec defines the desired state of OBTenantBackup properties: + encryptionSecret: + type: string obClusterName: type: string path: @@ -5055,8 +5026,6 @@ spec: tenantSecret: type: string type: - description: Foo is an example field of OBTenantBackup. Edit obtenantbackup_types.go - to remove/update type: string required: - obClusterName @@ -5571,6 +5540,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -5580,7 +5551,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -6075,6 +6050,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -6084,7 +6061,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -6543,6 +6524,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -6552,7 +6535,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -6914,6 +6901,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -6923,7 +6912,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -9003,28 +8996,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object observerTemplate: properties: diff --git a/deploy/operator.yaml b/deploy/operator.yaml index ba2443484..b794d1103 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -1771,28 +1771,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object observer: properties: @@ -3798,28 +3778,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object nodeSelector: additionalProperties: @@ -4069,7 +4029,11 @@ spec: type: string type: type: string + required: + - path type: object + encryptionSecret: + type: string fullCrontab: type: string incrementalCrontab: @@ -4106,6 +4070,8 @@ spec: type: string type: type: string + required: + - path type: object switchPieceInterval: type: string @@ -4117,6 +4083,8 @@ spec: type: string suspend: type: boolean + tenantCRName: + type: string tenantName: type: string tenantSecret: @@ -4125,7 +4093,6 @@ spec: - dataBackup - logArchive - obClusterName - - tenantName type: object status: description: OBTenantBackupPolicyStatus defines the observed state of @@ -4533,6 +4500,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -4542,7 +4511,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -4976,7 +4949,6 @@ spec: - arbitration_service_status - compatibility_mode - create_time - - gmt_create_time - in_recyclebin - locality - locked @@ -4988,14 +4960,11 @@ spec: - recovery_until_scn - replayable_scn - status - - switchover_epoch - - switchover_status - sync_scn - tenant_id - tenant_name - tenant_role - tenant_type - - unit_num type: object required: - status @@ -5065,6 +5034,8 @@ spec: spec: description: OBTenantBackupSpec defines the desired state of OBTenantBackup properties: + encryptionSecret: + type: string obClusterName: type: string path: @@ -5074,8 +5045,6 @@ spec: tenantSecret: type: string type: - description: Foo is an example field of OBTenantBackup. Edit obtenantbackup_types.go - to remove/update type: string required: - obClusterName @@ -5590,6 +5559,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -5599,7 +5570,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -6094,6 +6069,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -6103,7 +6080,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -6563,6 +6544,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -6572,7 +6555,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -6934,6 +6921,8 @@ spec: type: string type: type: string + required: + - path type: object bakDataSource: properties: @@ -6943,7 +6932,11 @@ spec: type: string type: type: string + required: + - path type: object + bakEncryptionSecret: + type: string cancel: type: boolean description: @@ -9025,28 +9018,8 @@ spec: - cpu - memory type: object - storage: - properties: - configStorage: - properties: - size: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - storageClass: - type: string - required: - - size - - storageClass - type: object - required: - - configStorage - type: object required: - image - - storage type: object observerTemplate: properties: @@ -9427,58 +9400,6 @@ rules: - get - patch - update -- apiGroups: - - oceanbase.oceanbase.com - resources: - - obclusterbackups - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - oceanbase.oceanbase.com - resources: - - obclusterbackups/finalizers - verbs: - - update -- apiGroups: - - oceanbase.oceanbase.com - resources: - - obclusterbackups/status - verbs: - - get - - patch - - update -- apiGroups: - - oceanbase.oceanbase.com - resources: - - obclusterrestores - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - oceanbase.oceanbase.com - resources: - - obclusterrestores/finalizers - verbs: - - update -- apiGroups: - - oceanbase.oceanbase.com - resources: - - obclusterrestores/status - verbs: - - get - - patch - - update - apiGroups: - oceanbase.oceanbase.com resources: diff --git a/deploy/tenant_op_activate.yaml b/deploy/tenant_op_activate.yaml index 5c3596450..5926c8e58 100644 --- a/deploy/tenant_op_activate.yaml +++ b/deploy/tenant_op_activate.yaml @@ -13,22 +13,4 @@ metadata: spec: type: "FAILOVER" failover: - standbyTenant: "t1s" -# --- -# apiVersion: oceanbase.oceanbase.com/v1alpha1 -# kind: OBTenantOperation -# metadata: -# labels: -# ref-obcluster: test -# app.kubernetes.io/name: obtenantoperation -# app.kubernetes.io/instance: op-chg-pwd-1 -# app.kubernetes.io/part-of: ob-operator -# app.kubernetes.io/managed-by: kustomize -# app.kubernetes.io/created-by: ob-operator -# name: op-chg-pwd-1 -# namespace: oceanbase -# spec: -# type: "CHANGE_PASSWORD" -# changePwd: -# tenant: "test" -# secretRef: "t1-credential-new" \ No newline at end of file + standbyTenant: "t1s" \ No newline at end of file diff --git a/deploy/tenant_op_switchover.yaml b/deploy/tenant_op_switchover.yaml index 05b37f241..851aed092 100644 --- a/deploy/tenant_op_switchover.yaml +++ b/deploy/tenant_op_switchover.yaml @@ -14,22 +14,4 @@ spec: type: "SWITCHOVER" switchover: primaryTenant: "t1" - standbyTenant: "t1ss" -# --- -# apiVersion: oceanbase.oceanbase.com/v1alpha1 -# kind: OBTenantOperation -# metadata: -# labels: -# ref-obcluster: test -# app.kubernetes.io/name: obtenantoperation -# app.kubernetes.io/instance: op-chg-pwd-1 -# app.kubernetes.io/part-of: ob-operator -# app.kubernetes.io/managed-by: kustomize -# app.kubernetes.io/created-by: ob-operator -# name: op-chg-pwd-1 -# namespace: oceanbase -# spec: -# type: "CHANGE_PASSWORD" -# changePwd: -# tenant: "test" -# secretRef: "t1-credential-new" \ No newline at end of file + standbyTenant: "t1ss" \ No newline at end of file diff --git a/deploy/tenant_op_switchover_back.yaml b/deploy/tenant_op_switchover_back.yaml deleted file mode 100644 index a1e8989a4..000000000 --- a/deploy/tenant_op_switchover_back.yaml +++ /dev/null @@ -1,35 +0,0 @@ -apiVersion: oceanbase.oceanbase.com/v1alpha1 -kind: OBTenantOperation -metadata: - labels: - ref-obcluster: test - app.kubernetes.io/name: obtenantoperation - app.kubernetes.io/instance: op-switchover-back - app.kubernetes.io/part-of: ob-operator - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: ob-operator - name: op-switchover-back - namespace: oceanbase -spec: - type: "SWITCHOVER" - switchover: - primaryTenant: "t1ss" - standbyTenant: "t1" -# --- -# apiVersion: oceanbase.oceanbase.com/v1alpha1 -# kind: OBTenantOperation -# metadata: -# labels: -# ref-obcluster: test -# app.kubernetes.io/name: obtenantoperation -# app.kubernetes.io/instance: op-chg-pwd-1 -# app.kubernetes.io/part-of: ob-operator -# app.kubernetes.io/managed-by: kustomize -# app.kubernetes.io/created-by: ob-operator -# name: op-chg-pwd-1 -# namespace: oceanbase -# spec: -# type: "CHANGE_PASSWORD" -# changePwd: -# tenant: "test" -# secretRef: "t1-credential-new" \ No newline at end of file diff --git a/deploy/tenant_restore_wrong.yaml b/deploy/tenant_restore_wrong.yaml deleted file mode 100644 index 00c76d9f8..000000000 --- a/deploy/tenant_restore_wrong.yaml +++ /dev/null @@ -1,70 +0,0 @@ -apiVersion: oceanbase.oceanbase.com/v1alpha1 -kind: OBTenant -metadata: - name: t1s-wrong - namespace: oceanbase -spec: - obcluster: test - tenantName: t1s_wrong - unitNum: 1 - charset: utf8mb4 - connectWhiteList: '%' - forceDelete: true - tenantRole: STANDBY - credentials: - root: t1s-root - standbyRo: t1s-ro - source: - restore: - # sourceUri: "file:///ob-backup/t1/data_backup_custom1,file:///ob-backup/t1/log_archive_custom1" - archiveSource: - type: NFS - path: "t1/log_archive_custom" - bakDataSource: - type: NFS - path: "t1/data_backup_custom_enc" - until: - unlimited: true - replayLogUntil: - unlimited: true - tenant: t1 - pools: - - zone: zone1 - type: - name: Full - replica: 1 - isActive: true - resource: - maxCPU: 1000m - memorySize: 2Gi - minCPU: 1 - maxIops: 1024 - minIops: 1024 - logDiskSize: - - zone: zone2 - type: - name: Full - replica: 1 - isActive: true - resource: - maxCPU: 1000m - memorySize: 2Gi - minCPU: 1 - maxIops: 1024 - minIops: 1024 - iopsWeight: 2 - logDiskSize: 4Gi - - zone: zone3 - type: - name: Full - replica: 1 - isActive: true - priority: 3 - resource: - maxCPU: 1000m - memorySize: 2Gi - minCPU: 1 - maxIops: 1024 - minIops: 1024 - iopsWeight: 2 - logDiskSize: 4Gi diff --git a/pkg/oceanbase/model/system.go b/pkg/oceanbase/model/system.go index 6b373070c..f61f8a91f 100644 --- a/pkg/oceanbase/model/system.go +++ b/pkg/oceanbase/model/system.go @@ -33,10 +33,10 @@ type OBTenant struct { RecoveryUntilScn int64 `json:"recovery_until_scn" db:"recovery_until_scn"` LogMode string `json:"log_mode" db:"log_mode"` ArbitrationServiceStatus string `json:"arbitration_service_status" db:"arbitration_service_status"` - GmtCreateTime string `json:"gmt_create_time" db:"gmt_create"` - SwitchoverStatus string `json:"switchover_status" db:"switchover_status"` - SwitchoverEpoch int64 `json:"switchover_epoch" db:"switchover_epoch"` - UnitNum int64 `json:"unit_num" db:"unit_num"` + GmtCreateTime string `json:"gmt_create_time,omitempty" db:"gmt_create"` + SwitchoverStatus string `json:"switchover_status,omitempty" db:"switchover_status"` + SwitchoverEpoch int64 `json:"switchover_epoch,omitempty" db:"switchover_epoch"` + UnitNum int64 `json:"unit_num,omitempty" db:"unit_num"` } // OBUnit is the unit model of OB system diff --git a/pkg/resource/observer_task.go b/pkg/resource/observer_task.go index 94332e7d7..b74e3b554 100644 --- a/pkg/resource/observer_task.go +++ b/pkg/resource/observer_task.go @@ -209,22 +209,6 @@ func (m *OBServerManager) CreateOBPVC() error { return errors.Wrap(err, "Create pvc of log") } - if m.OBServer.Spec.MonitorTemplate != nil { - objectMeta = metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-%s", m.OBServer.Name, obagentconst.ConfigVolumeSuffix), - Namespace: m.OBServer.Namespace, - OwnerReferences: ownerReferenceList, - Labels: m.OBServer.Labels, - } - pvc = &corev1.PersistentVolumeClaim{ - ObjectMeta: objectMeta, - Spec: m.generatePVCSpec(fmt.Sprintf("%s-%s", m.OBServer.Name, obagentconst.ConfigVolumeSuffix), m.OBServer.Spec.MonitorTemplate.Storage.ConfigStorage), - } - err = m.Client.Create(m.Ctx, pvc) - if err != nil { - return errors.Wrap(err, "Create pvc of monitor log") - } - } return nil } @@ -428,6 +412,7 @@ func (m *OBServerManager) createOBServerContainer() corev1.Container { readinessProbe.ProbeHandler.TCPSocket = &readinessProbeTCP readinessProbe.PeriodSeconds = oceanbaseconst.ProbeCheckPeriodSeconds readinessProbe.InitialDelaySeconds = oceanbaseconst.ProbeCheckDelaySeconds + readinessProbe.FailureThreshold = 10 startOBServerCmd := "/home/admin/oceanbase/bin/oceanbase-helper start" diff --git a/pkg/resource/obtenantbackuppolicy_task.go b/pkg/resource/obtenantbackuppolicy_task.go index 15363c53e..d11efc976 100644 --- a/pkg/resource/obtenantbackuppolicy_task.go +++ b/pkg/resource/obtenantbackuppolicy_task.go @@ -381,7 +381,7 @@ func (m *ObTenantBackupPolicyManager) PauseBackup() error { if err != nil { return err } - + m.Recorder.Event(m.BackupPolicy, v1.EventTypeNormal, "PauseBackup", "Pause backup policy") return nil } @@ -409,7 +409,8 @@ func (m *ObTenantBackupPolicyManager) ResumeBackup() error { archiveRunning = true } } - return nil + m.Recorder.Event(m.BackupPolicy, v1.EventTypeNormal, "ResumeBackup", "Resume backup policy") + return m.createBackupJobIfNotExists(constants.BackupJobTypeFull) } func (m *ObTenantBackupPolicyManager) syncLatestJobs() error { @@ -486,21 +487,22 @@ func (m *ObTenantBackupPolicyManager) getOperationManager() (*operation.Oceanbas } func (m *ObTenantBackupPolicyManager) getArchiveDestPath() string { - archiveSpec := m.BackupPolicy.Spec.LogArchive - targetDest := archiveSpec.Destination + targetDest := m.BackupPolicy.Spec.LogArchive.Destination if targetDest.Type == constants.BackupDestTypeNFS || isZero(targetDest.Type) { return "file://" + path.Join(backupVolumePath, targetDest.Path) + } else if targetDest.Type == constants.BackupDestTypeOSS && targetDest.OSSAccessSecret != "" { + secret := &v1.Secret{} + err := m.Client.Get(m.Ctx, types.NamespacedName{ + Namespace: m.BackupPolicy.GetNamespace(), + Name: targetDest.OSSAccessSecret, + }, secret) + if err != nil { + m.PrintErrEvent(err) + return "" + } + return strings.Join([]string{targetDest.Path, "access_id=" + string(secret.Data["accessId"]), "access_key=" + string(secret.Data["accessKey"])}, "&") } - secret := &v1.Secret{} - err := m.Client.Get(m.Ctx, types.NamespacedName{ - Namespace: m.BackupPolicy.GetNamespace(), - Name: targetDest.OSSAccessSecret, - }, secret) - if err != nil { - m.PrintErrEvent(err) - return "" - } - return strings.Join([]string{targetDest.Path, "access_id=" + string(secret.Data["accessId"]), "access_key=" + string(secret.Data["accessKey"])}, "&") + return targetDest.Path } func (m *ObTenantBackupPolicyManager) getArchiveDestSettingValue() string { @@ -519,17 +521,19 @@ func (m *ObTenantBackupPolicyManager) getBackupDestPath() string { targetDest := m.BackupPolicy.Spec.DataBackup.Destination if targetDest.Type == constants.BackupDestTypeNFS || isZero(targetDest.Type) { return "file://" + path.Join(backupVolumePath, targetDest.Path) + } else if targetDest.Type == constants.BackupDestTypeOSS && targetDest.OSSAccessSecret != "" { + secret := &v1.Secret{} + err := m.Client.Get(m.Ctx, types.NamespacedName{ + Namespace: m.BackupPolicy.GetNamespace(), + Name: targetDest.OSSAccessSecret, + }, secret) + if err != nil { + m.PrintErrEvent(err) + return "" + } + return strings.Join([]string{targetDest.Path, "access_id=" + string(secret.Data["accessId"]), "access_key=" + string(secret.Data["accessKey"])}, "&") } - secret := &v1.Secret{} - err := m.Client.Get(m.Ctx, types.NamespacedName{ - Namespace: m.BackupPolicy.GetNamespace(), - Name: targetDest.OSSAccessSecret, - }, secret) - if err != nil { - m.PrintErrEvent(err) - return "" - } - return strings.Join([]string{targetDest.Path, "access_id=" + string(secret.Data["accessId"]), "access_key=" + string(secret.Data["accessKey"])}, "&") + return targetDest.Path } func (m *ObTenantBackupPolicyManager) createBackupJob(jobType apitypes.BackupJobType) error {