Skip to content

Commit

Permalink
[BugFix] Add namespace to service domain (#529)
Browse files Browse the repository at this point in the history
* [BugFix] Add namespace to service domain

Signed-off-by: yandongxiao <[email protected]>

* [BugFix] Fix Ci

Signed-off-by: yandongxiao <[email protected]>

---------

Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao authored May 15, 2024
1 parent 63aad4d commit 7506809
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
5 changes: 5 additions & 0 deletions doc/deploy_warehouse_howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ You can choose one of the following methods to deploy a warehouse:
1. Deploy Warehouse by YAML Manifest
2. Deploy Warehouse by Helm Chart

> If you deploy StarRocks Cluster with BE and CN nodes, they are added to the `default_warehouse` in StarRocks by
> default. You can also define a Warehouse CR named `default-warehouse` to add more BE and CN nodes to the warehouse.
### 2.1 Deploy Warehouse by YAML Manifest

First, we need to install StarRocksWarehouse CRD and restart the StarRocks operator to make it aware of the new CRD.
Expand Down Expand Up @@ -136,11 +139,13 @@ kubectl -n starrocks patch warehouse wh1 --type='merge' -p '{"spec":{"template":
### 3.4 Delete the Warehouse

If you deployed the warehouse by YAML manifest, you can delete it by running the following command:

```bash
kubectl delete -f warehouse.yaml
```

If you deployed the warehouse by Helm chart, you can delete it by running the following command:

```bash
helm -n starrocks uninstall wh1
```
18 changes: 10 additions & 8 deletions pkg/subcontrollers/cn/cn_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
// Component CN needs to connect to mysql and execute sql statements. E.g.: When StarRocksWarehouse is deleted, the
// related 'DROP WAREHOUSE <name>' statement needs to be executed.
type SQLExecutor struct {
RootPassword string
FeServiceName string
FeServicePort string
RootPassword string
FeServiceName string
FeServiceNamespace string
FeServicePort string
}

// NewSQLExecutor creates a SQLExecutor instance. It will get the root password, fe service name, and fe service port
Expand Down Expand Up @@ -66,9 +67,10 @@ func NewSQLExecutor(ctx context.Context, k8sClient client.Client, namespace, ali
}

return &SQLExecutor{
RootPassword: rootPassword,
FeServiceName: feServiceName,
FeServicePort: feServicePort,
RootPassword: rootPassword,
FeServiceName: feServiceName,
FeServiceNamespace: namespace,
FeServicePort: feServicePort,
}, nil
}

Expand All @@ -77,8 +79,8 @@ func NewSQLExecutor(ctx context.Context, k8sClient client.Client, namespace, ali
func (executor *SQLExecutor) Execute(ctx context.Context, db *sql.DB, statements string) error {
var err error
if db == nil {
db, err = sql.Open("mysql", fmt.Sprintf("root:%s@tcp(%s:%s)/",
executor.RootPassword, executor.FeServiceName, executor.FeServicePort))
db, err = sql.Open("mysql", fmt.Sprintf("root:%s@tcp(%s.%s:%s)/",
executor.RootPassword, executor.FeServiceName, executor.FeServiceNamespace, executor.FeServicePort))
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/subcontrollers/cn/cn_mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ func TestNewSQLExecutor(t *testing.T) {
name: "my-sts",
},
want: &SQLExecutor{
RootPassword: "123456",
FeServiceName: "fe",
FeServicePort: "9030",
RootPassword: "123456",
FeServiceName: "fe",
FeServiceNamespace: "default",
FeServicePort: "9030",
},
wantErr: assert.NoError,
},
Expand Down

0 comments on commit 7506809

Please sign in to comment.