Skip to content

Commit fcda865

Browse files
author
smiletan
committed
drop node compatible rename compute group name
1 parent cc86d90 commit fcda865

File tree

8 files changed

+181
-70
lines changed

8 files changed

+181
-70
lines changed

api/disaggregated/v1/types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,12 @@ type ComputeGroupStatus struct {
385385
// the service that can access the compute group pods.
386386
ServiceName string `json:"serviceName,omitempty"`
387387

388-
//
388+
//the unique id of compute group in kubernetes, this field is part of compute group statefulset.
389389
UniqueId string `json:"uniqueId,omitempty"`
390390

391+
//the compute group id in doris meta, this response to the backend's tag "compute_group_id";
392+
ComputeGroupId string `json:"computeGroupId,omitempty"`
393+
391394
//AvailableStatus represents the compute group available or not.
392395
AvailableStatus AvailableStatus `json:"availableStatus,omitempty"`
393396

api/disaggregated/v1/unique_id.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
package v1
1919

2020
import (
21-
"crypto/sha256"
22-
"math/big"
23-
"strings"
21+
"crypto/sha256"
22+
"math/big"
23+
"strings"
2424
)
2525

2626
/*
@@ -80,6 +80,7 @@ func (ddc *DorisDisaggregatedCluster) GetMSServiceName() string {
8080
return ddc.Name + "-" + "ms"
8181
}
8282

83+
//the first deployed used computegroup name, when user rename the compute group name by sql command `ALTER SYSTEM RENAME COMPUTE GROUP <old_name> <new_name>`, this function will not right.
8384
func (ddc *DorisDisaggregatedCluster) GetCGName(cg *ComputeGroup) string {
8485
// use uniqueId as compute group name, the uniqueId restrict not empty, and the computegroup's name should use "_" not "-"
8586
return strings.ReplaceAll(cg.UniqueId, "-", "_")

config/crd/bases/crds.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15953,6 +15953,10 @@ spec:
1595315953
description: AvailableStatus represents the compute group available
1595415954
or not.
1595515955
type: string
15956+
computeGroupId:
15957+
description: the compute group id in doris meta, this response
15958+
to the backend's tag "compute_group_id";
15959+
type: string
1595615960
phase:
1595715961
description: Phase represent the stage of reconciling.
1595815962
type: string
@@ -15973,6 +15977,8 @@ spec:
1597315977
format: int32
1597415978
type: integer
1597515979
uniqueId:
15980+
description: the unique id of compute group in kubernetes, this
15981+
field is part of compute group statefulset.
1597615982
type: string
1597715983
type: object
1597815984
type: array

config/crd/bases/disaggregated.cluster.doris.com_dorisdisaggregatedclusters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6826,6 +6826,10 @@ spec:
68266826
description: AvailableStatus represents the compute group available
68276827
or not.
68286828
type: string
6829+
computeGroupId:
6830+
description: the compute group id in doris meta, this response
6831+
to the backend's tag "compute_group_id";
6832+
type: string
68296833
phase:
68306834
description: Phase represent the stage of reconciling.
68316835
type: string
@@ -6846,6 +6850,8 @@ spec:
68466850
format: int32
68476851
type: integer
68486852
uniqueId:
6853+
description: the unique id of compute group in kubernetes, this
6854+
field is part of compute group statefulset.
68496855
type: string
68506856
type: object
68516857
type: array

helm-charts/doris-operator/crds/disaggregated.cluster.doris.com_dorisdisaggregatedclusters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6826,6 +6826,10 @@ spec:
68266826
description: AvailableStatus represents the compute group available
68276827
or not.
68286828
type: string
6829+
computeGroupId:
6830+
description: the compute group id in doris meta, this response
6831+
to the backend's tag "compute_group_id";
6832+
type: string
68296833
phase:
68306834
description: Phase represent the stage of reconciling.
68316835
type: string
@@ -6846,6 +6850,8 @@ spec:
68466850
format: int32
68476851
type: integer
68486852
uniqueId:
6853+
description: the unique id of compute group in kubernetes, this
6854+
field is part of compute group statefulset.
68496855
type: string
68506856
type: object
68516857
type: array

pkg/common/utils/mysql/mysql.go

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
package mysql
1919

2020
import (
21-
"database/sql"
22-
"encoding/json"
23-
"fmt"
24-
_ "github.com/go-sql-driver/mysql"
25-
"github.com/jmoiron/sqlx"
26-
"k8s.io/klog/v2"
21+
"database/sql"
22+
"encoding/json"
23+
"fmt"
24+
"os"
25+
26+
_ "github.com/go-sql-driver/mysql"
27+
"github.com/jmoiron/sqlx"
28+
"k8s.io/klog/v2"
29+
)
30+
31+
const (
32+
COMPUTE_GROUP_ID = "compute_group_id"
2733
)
2834

2935
type DBConfig struct {
@@ -34,11 +40,20 @@ type DBConfig struct {
3440
Database string
3541
}
3642

43+
func NewDBConfig() DBConfig {
44+
return DBConfig{
45+
Database: "mysql",
46+
}
47+
}
48+
3749
type DB struct {
3850
*sqlx.DB
3951
}
4052

4153
func NewDorisSqlDB(cfg DBConfig) (*DB, error) {
54+
if os.Getenv("DEBUG") == "true" {
55+
cfg.Host = "10.152.183.86"
56+
}
4257
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", cfg.User, cfg.Password, cfg.Host, cfg.Port, cfg.Database)
4358
db, err := sqlx.Open("mysql", dsn)
4459
if err != nil {
@@ -168,27 +183,27 @@ func (db *DB) GetObservers() ([]*Frontend, error) {
168183
return res, nil
169184
}
170185

171-
func (db *DB) GetBackendsByCGName(cgName string) ([]*Backend, error) {
186+
func (db *DB) GetBackendsByComputeGroupId(cgid string) ([]*Backend, error) {
172187
backends, err := db.ShowBackends()
173188
if err != nil {
174-
klog.Errorf("GetBackendsByCGName show backends failed, err: %s\n", err.Error())
189+
klog.Errorf("GetBackendsByComputeGroupId show backends failed, err: %s\n", err.Error())
175190
return nil, err
176191
}
177192
var res []*Backend
178193
for _, be := range backends {
179194
var m map[string]interface{}
180195
err := json.Unmarshal([]byte(be.Tag), &m)
181196
if err != nil {
182-
klog.Errorf("GetBackendsByCGName backends tag stirng to map failed, tag: %s, err: %s\n", be.Tag, err.Error())
197+
klog.Errorf("GetBackendsByComputeGroupId backends tag stirng to map failed, tag: %s, err: %s\n", be.Tag, err.Error())
183198
return nil, err
184199
}
185-
if _, ok := m["compute_group_name"]; !ok {
186-
klog.Errorf("GetBackendsByCGName backends tag get compute_group_name failed, tag: %s, err: %s\n", be.Tag, err.Error())
200+
if _, ok := m[COMPUTE_GROUP_ID]; !ok {
201+
klog.Errorf("GetBackendsByComputeGroupId backends tag get compute_group_name failed, tag: %s, err: %s\n", be.Tag, err.Error())
187202
return nil, err
188203
}
189204

190-
cgNameFromTag := fmt.Sprintf("%s", m["compute_group_name"])
191-
if cgNameFromTag == cgName {
205+
computegroupId := fmt.Sprintf("%s", m[COMPUTE_GROUP_ID])
206+
if computegroupId == cgid {
192207
res = append(res, be)
193208
}
194209
}

0 commit comments

Comments
 (0)