From 22e184c66905dd20510725ab017702021fa8bddb Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 27 Sep 2023 14:12:12 +0800 Subject: [PATCH] chore: address some problems in PR comments --- deploy/tenant.yaml | 1 + distribution/oceanbase/build.sh | 2 +- pkg/oceanbase/const/config/tenant.go | 5 +++-- pkg/oceanbase/operation/restore.go | 6 +++--- pkg/resource/obtenantrestore_manager.go | 3 +-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/deploy/tenant.yaml b/deploy/tenant.yaml index 935c51396..9597c0a9d 100644 --- a/deploy/tenant.yaml +++ b/deploy/tenant.yaml @@ -22,6 +22,7 @@ spec: minCPU: 2 maxIops: 1024 minIops: 1024 + iopsWeight: logDiskSize: - zone: zone2 type: diff --git a/distribution/oceanbase/build.sh b/distribution/oceanbase/build.sh index 2f9547be8..e5f41d612 100755 --- a/distribution/oceanbase/build.sh +++ b/distribution/oceanbase/build.sh @@ -1,2 +1,2 @@ #!/bin/bash -docker build -t $1 --build-arg GOPROXY=$(go env GOPROXY) --build-arg VERSION=$2 . +docker build -t $1 --build-arg GOPROXY=${GOPROXY} --build-arg VERSION=$2 . diff --git a/pkg/oceanbase/const/config/tenant.go b/pkg/oceanbase/const/config/tenant.go index 32f1e061f..724dda307 100644 --- a/pkg/oceanbase/const/config/tenant.go +++ b/pkg/oceanbase/const/config/tenant.go @@ -15,6 +15,7 @@ package config import "time" const ( - TenantSqlTimeout = 600 * time.Second - PollingJobSleepTime = 1 * time.Second + TenantSqlTimeout = 600 * time.Second + PollingJobSleepTime = 1 * time.Second + TenantRestoreTimeOut = 600 * time.Second ) diff --git a/pkg/oceanbase/operation/restore.go b/pkg/oceanbase/operation/restore.go index a809e502e..dce41c7ae 100644 --- a/pkg/oceanbase/operation/restore.go +++ b/pkg/oceanbase/operation/restore.go @@ -14,10 +14,10 @@ package operation import ( "fmt" - "time" "github.com/pkg/errors" + "github.com/oceanbase/ob-operator/pkg/oceanbase/const/config" "github.com/oceanbase/ob-operator/pkg/oceanbase/const/sql" "github.com/oceanbase/ob-operator/pkg/oceanbase/model" ) @@ -33,7 +33,7 @@ func (m *OceanbaseOperationManager) SetRestorePassword(password string) error { func (m *OceanbaseOperationManager) StartRestoreWithLimit(tenantName, uri, restoreOption string, limitKey, limitValue any) error { sqlStatement := fmt.Sprintf(sql.StartRestoreWithLimit, tenantName, limitKey) - err := m.ExecWithTimeout(600*time.Second, sqlStatement, uri, limitValue, restoreOption) + err := m.ExecWithTimeout(config.TenantRestoreTimeOut, sqlStatement, uri, limitValue, restoreOption) if err != nil { m.Logger.Error(err, "Got exception when start restore with limit") return errors.Wrap(err, "Start restore with limit") @@ -42,7 +42,7 @@ func (m *OceanbaseOperationManager) StartRestoreWithLimit(tenantName, uri, resto } func (m *OceanbaseOperationManager) StartRestoreUnlimited(tenantName, uri, restoreOption string) error { - err := m.ExecWithTimeout(600*time.Second, fmt.Sprintf(sql.StartRestoreUnlimited, tenantName), uri, restoreOption) + err := m.ExecWithTimeout(config.TenantRestoreTimeOut, fmt.Sprintf(sql.StartRestoreUnlimited, tenantName), uri, restoreOption) if err != nil { m.Logger.Error(err, "Got exception when start restore unlimited") return errors.Wrap(err, "Start restore unlimited") diff --git a/pkg/resource/obtenantrestore_manager.go b/pkg/resource/obtenantrestore_manager.go index 4c3e390e7..26ab4f1e9 100644 --- a/pkg/resource/obtenantrestore_manager.go +++ b/pkg/resource/obtenantrestore_manager.go @@ -117,8 +117,7 @@ func (m *ObTenantRestoreManager) checkRestoreProgress() error { m.Recorder.Event(m.Resource, corev1.EventTypeWarning, "Restore job is failed", "Restore job is failed") m.Resource.Status.Status = constants.RestoreJobFailed } - } - if restoreJob == nil { + } else { restoreHistory, err := con.GetLatestRestoreHistoryOfTenant(m.Resource.Spec.TargetTenant) if err != nil { return err