Skip to content

Commit

Permalink
fix: test for 2.0.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI committed Oct 19, 2023
1 parent 69399e8 commit 11bcc17
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 462 deletions.
5 changes: 2 additions & 3 deletions api/v1alpha1/monitor_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
30 changes: 13 additions & 17 deletions api/v1alpha1/obtenantbackuppolicy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
5 changes: 0 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

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

20 changes: 0 additions & 20 deletions config/crd/bases/oceanbase.oceanbase.com_obclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 0 additions & 20 deletions config/crd/bases/oceanbase.oceanbase.com_observers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,6 @@ spec:
- arbitration_service_status
- compatibility_mode
- create_time
- gmt_create_time
- in_recyclebin
- locality
- locked
Expand All @@ -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
Expand Down
20 changes: 0 additions & 20 deletions config/crd/bases/oceanbase.oceanbase.com_obzones.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 11bcc17

Please sign in to comment.