Skip to content

Commit

Permalink
fix PR
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-sun-star committed Mar 13, 2024
1 parent ba16178 commit 72933d9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 27 deletions.
2 changes: 0 additions & 2 deletions config/crd/bases/oceanbase.oceanbase.com_obclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1751,8 +1751,6 @@ spec:
serviceAccount:
default: default
type: string
sourceOBClusterConnection:
type: string
topology:
items:
properties:
Expand Down
2 changes: 0 additions & 2 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1774,8 +1774,6 @@ spec:
serviceAccount:
default: default
type: string
sourceOBClusterConnection:
type: string
topology:
items:
properties:
Expand Down
9 changes: 2 additions & 7 deletions internal/resource/obcluster/obcluster_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"strings"
"time"

"github.com/google/uuid"
"github.com/pkg/errors"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -434,9 +433,7 @@ func (m *OBClusterManager) ValidateUpgradeInfo() tasktypes.TaskError {
return errors.Wrapf(err, "Failed to get version of obcluster %s", m.OBCluster.Name)
}
// Get target version and patch
parts := strings.Split(uuid.New().String(), "-")
suffix := parts[len(parts)-1]
jobName := fmt.Sprintf("%s-%s", "oceanbase-upgrade", suffix)
jobName := fmt.Sprintf("%s-%s", "oceanbase-upgrade", rand.String(6))
var backoffLimit int32
var ttl int32 = 300
container := corev1.Container{
Expand Down Expand Up @@ -718,12 +715,10 @@ func (m *OBClusterManager) CreateServiceForMonitor() tasktypes.TaskError {
ownerReferenceList = append(ownerReferenceList, ownerReference)
selector := make(map[string]string)
selector[oceanbaseconst.LabelRefOBCluster] = m.OBCluster.Name
parts := strings.Split(uuid.New().String(), "-")
suffix := parts[len(parts)-1]
monitorService := corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Namespace: m.OBCluster.Namespace,
Name: fmt.Sprintf("svc-monitor-%s-%s", m.OBCluster.Name, suffix),
Name: fmt.Sprintf("svc-monitor-%s-%s", m.OBCluster.Name, rand.String(6)),
OwnerReferences: ownerReferenceList,
},
Spec: corev1.ServiceSpec{
Expand Down
7 changes: 2 additions & 5 deletions internal/resource/obzone/obzone_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ package obzone

import (
"fmt"
"strings"
"time"

"github.com/google/uuid"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/client-go/util/retry"

v1alpha1 "github.com/oceanbase/ob-operator/api/v1alpha1"
Expand All @@ -40,9 +39,7 @@ func (m *OBZoneManager) getOceanbaseOperationManager() (*operation.OceanbaseOper
}

func (m *OBZoneManager) generateServerName() string {
parts := strings.Split(uuid.New().String(), "-")
suffix := parts[len(parts)-1]
return fmt.Sprintf("%s-%d-%s-%s", m.OBZone.Spec.ClusterName, m.OBZone.Spec.ClusterId, m.OBZone.Spec.Topology.Zone, suffix)
return fmt.Sprintf("%s-%d-%s-%s", m.OBZone.Spec.ClusterName, m.OBZone.Spec.ClusterId, m.OBZone.Spec.Topology.Zone, rand.String(6))
}

func (m *OBZoneManager) AddZone() tasktypes.TaskError {
Expand Down
14 changes: 3 additions & 11 deletions internal/resource/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
"time"

"github.com/go-logr/logr"
"github.com/google/uuid"
"github.com/pkg/errors"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/rand"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/oceanbase/ob-operator/api/v1alpha1"
Expand Down Expand Up @@ -192,14 +192,8 @@ func GetJob(c client.Client, namespace string, jobName string) (*batchv1.Job, er
return job, err
}

func randomStr() string {
parts := strings.Split(uuid.New().String(), "-")
suffix := parts[len(parts)-1]
return suffix
}

func RunJob(c client.Client, logger *logr.Logger, namespace string, jobName string, image string, cmd string) (string, error) {
fullJobName := fmt.Sprintf("%s-%s", jobName, randomStr())
fullJobName := fmt.Sprintf("%s-%s", jobName, rand.String(6))
var backoffLimit int32
var ttl int32 = 300
container := corev1.Container{
Expand Down Expand Up @@ -298,9 +292,7 @@ func ExecuteUpgradeScript(c client.Client, logger *logr.Logger, obcluster *v1alp
}
}

parts := strings.Split(uuid.New().String(), "-")
suffix := parts[len(parts)-1]
jobName := fmt.Sprintf("%s-%s", "script-runner", suffix)
jobName := fmt.Sprintf("%s-%s", "script-runner", rand.String(6))
var backoffLimit int32
var ttl int32 = 300
container := corev1.Container{
Expand Down

0 comments on commit 72933d9

Please sign in to comment.