Skip to content

Commit

Permalink
fix: verify logic cluster when import cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
YenchangChan committed Mar 19, 2024
1 parent 052c902 commit 7517874
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions service/clickhouse/clickhouse_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ func GetCkClusterConfig(conf *model.CKManClickHouseConfig) (string, error) {
}
}

if conf.LogicCluster != nil {
query := fmt.Sprintf("SELECT count() FROM system.clusters WHERE cluster = '%s'", *conf.LogicCluster)
value, err = service.QueryInfo(query)
if err != nil {
return model.E_DATA_SELECT_FAILED, err
}
c := value[1][0].(uint64)
if c == 0 {
return model.E_RECORD_NOT_FOUND, fmt.Errorf("logic cluster %s not exist", *conf.LogicCluster)
}
}

value, err = service.QueryInfo("SELECT version()")
if err != nil {
return model.E_DATA_SELECT_FAILED, err
Expand Down

0 comments on commit 7517874

Please sign in to comment.