Skip to content

Commit 9dc3e92

Browse files
authored
Fixed some problems found in testings (#574)
1 parent 0e0696e commit 9dc3e92

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

api/constants/tenant.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const (
3131
TenantOpAddResourcePools types.TenantOperationType = "ADD_RESOURCE_POOLS"
3232
TenantOpDeleteResourcePools types.TenantOperationType = "DELETE_RESOURCE_POOLS"
3333
TenantOpModifyResourcePools types.TenantOperationType = "MODIFY_RESOURCE_POOLS"
34-
TenantOpSetCharset types.TenantOperationType = "SET_CHARSET"
3534
)
3635

3736
const (

api/v1alpha1/obtenant_webhook.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,21 @@ func (r *OBTenant) ValidateCreate() (admission.Warnings, error) {
109109

110110
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
111111
func (r *OBTenant) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
112-
_ = old
112+
oldTenant, ok := old.(*OBTenant)
113+
if !ok {
114+
return nil, apierrors.NewBadRequest("Invalid old object")
115+
}
113116
if r.Status.Status == tenantstatus.Running {
114117
switch {
115-
case r.Spec.ClusterName != old.(*OBTenant).Spec.ClusterName:
118+
case r.Spec.ClusterName != oldTenant.Spec.ClusterName:
116119
return nil, apierrors.NewBadRequest("Cannot change clusterName when tenant is running")
117-
case r.Spec.TenantName != old.(*OBTenant).Spec.TenantName:
120+
case r.Spec.TenantName != oldTenant.Spec.TenantName:
118121
return nil, apierrors.NewBadRequest("Cannot change tenantName when tenant is running")
119122
}
120123
}
124+
if r.Spec.Charset != oldTenant.Spec.Charset {
125+
return nil, apierrors.NewBadRequest("Cannot change charset of tenant")
126+
}
121127
return nil, r.validateMutation()
122128
}
123129

api/v1alpha1/obtenantbackuppolicy_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func validateScheduleFormat(schedule string, fldPath *field.Path) *field.Error {
293293
return nil
294294
}
295295

296-
func (r *OBTenantBackupPolicy) validateDestination(cluster *OBCluster, dest *apitypes.BackupDestination, fieldName string) *field.Error {
296+
func (r *OBTenantBackupPolicy) validateDestination(cluster *OBCluster, dest *apitypes.BackupDestination, fieldName string) error {
297297
if dest.Type == constants.BackupDestTypeNFS && cluster.Spec.BackupVolume == nil {
298298
return field.Invalid(field.NewPath("spec").Child("backupVolume"), cluster.Spec.BackupVolume, "backupVolume of obcluster is required when backing up data to NFS")
299299
}

api/v1alpha1/obtenantoperation_webhook.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (r *OBTenantOperation) Default() {
6969
} else if r.Spec.Type == constants.TenantOpSwitchover && r.Spec.Switchover != nil {
7070
targetTenantName = r.Spec.Switchover.PrimaryTenant
7171
secondaryTenantName = r.Spec.Switchover.StandbyTenant
72-
} else if (r.Spec.Type == constants.TenantOpUpgrade || r.Spec.Type == constants.TenantOpReplayLog) && r.Spec.TargetTenant != nil {
72+
} else if r.Spec.TargetTenant != nil {
7373
targetTenantName = *r.Spec.TargetTenant
7474
}
7575
references := r.GetOwnerReferences()
@@ -261,10 +261,6 @@ func (r *OBTenantOperation) validateMutation() error {
261261
if r.Spec.ConnectWhiteList == "" {
262262
allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("connectWhiteList"), "connectWhiteList is required"))
263263
}
264-
case constants.TenantOpSetCharset:
265-
if r.Spec.Charset == "" {
266-
allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("charset"), "charset is required"))
267-
}
268264
case constants.TenantOpAddResourcePools:
269265
if len(r.Spec.AddResourcePools) == 0 {
270266
allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("addResourcePools"), "addResourcePools is required"))

internal/resource/obtenantoperation/obtenantoperation_task.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,6 @@ func UpdateOBTenantResource(m *ObTenantOperationManager) tasktypes.TaskError {
361361
obtenant.Spec.UnitNumber = m.Resource.Spec.UnitNumber
362362
case constants.TenantOpSetConnectWhiteList:
363363
obtenant.Spec.ConnectWhiteList = m.Resource.Spec.ConnectWhiteList
364-
case constants.TenantOpSetCharset:
365-
obtenant.Spec.Charset = m.Resource.Spec.Charset
366364
case constants.TenantOpAddResourcePools:
367365
for _, pool := range m.Resource.Spec.AddResourcePools {
368366
obtenant.Spec.Pools = append(obtenant.Spec.Pools, pool)

internal/resource/obtenantoperation/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ See the Mulan PSL v2 for more details.
1313
package obtenantoperation
1414

1515
import (
16+
"time"
17+
1618
"github.com/pkg/errors"
1719
"k8s.io/apimachinery/pkg/types"
1820
"k8s.io/client-go/util/retry"
@@ -98,6 +100,7 @@ func (m *ObTenantOperationManager) waitForOBTenantToBeStatus(waitSeconds int, ma
98100
if matcher(tenant) {
99101
return nil
100102
}
103+
time.Sleep(time.Second)
101104
}
102105
return errors.Errorf("wait for tenant %s to be in desired status timeout", m.Resource.Name)
103106
}

0 commit comments

Comments
 (0)