Skip to content

Commit 5074948

Browse files
committed
Revert "Feature(cluster add): add deploy type parameter"
This reverts commit 828680a.
1 parent a703f1e commit 5074948

File tree

7 files changed

+12
-71
lines changed

7 files changed

+12
-71
lines changed

cli/cli/cli.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ type CurveAdm struct {
6969
clusterName string // current cluster name
7070
clusterTopologyData string // cluster topology
7171
clusterPoolData string // cluster pool
72-
clusterType string // cluster type like develop, production, etc.
7372
monitor storage.Monitor
7473
}
7574

@@ -196,7 +195,7 @@ func (curveadm *CurveAdm) init() error {
196195
curveadm.clusterTopologyData = cluster.Topology
197196
curveadm.clusterPoolData = cluster.Pool
198197
curveadm.monitor = monitor
199-
curveadm.clusterType = cluster.Type
198+
200199
return nil
201200
}
202201

@@ -277,7 +276,6 @@ func (curveadm *CurveAdm) ClusterUUId() string { return curveadm.c
277276
func (curveadm *CurveAdm) ClusterName() string { return curveadm.clusterName }
278277
func (curveadm *CurveAdm) ClusterTopologyData() string { return curveadm.clusterTopologyData }
279278
func (curveadm *CurveAdm) ClusterPoolData() string { return curveadm.clusterPoolData }
280-
func (curveadm *CurveAdm) ClusterType() string { return curveadm.clusterType }
281279
func (curveadm *CurveAdm) Monitor() storage.Monitor { return curveadm.monitor }
282280

283281
func (curveadm *CurveAdm) GetHost(name string) (*hosts.HostConfig, error) {

cli/command/cluster/add.go

+2-24
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,12 @@ var (
4747
CHECK_TOPOLOGY_PLAYBOOK_STEPS = []int{
4848
playbook.CHECK_TOPOLOGY,
4949
}
50-
SUPPORTED_DEPLOY_TYPES = []string{
51-
"production",
52-
"test",
53-
"develop",
54-
}
5550
)
5651

5752
type addOptions struct {
5853
name string
5954
description string
6055
filename string
61-
deployType string
6256
}
6357

6458
func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command {
@@ -69,9 +63,6 @@ func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command {
6963
Short: "Add cluster",
7064
Args: utils.ExactArgs(1),
7165
Example: ADD_EXAMPLE,
72-
PreRunE: func(cmd *cobra.Command, args []string) error {
73-
return checkAddOptions(cmd)
74-
},
7566
RunE: func(cmd *cobra.Command, args []string) error {
7667
options.name = args[0]
7768
return runAdd(curveadm, options)
@@ -82,7 +73,7 @@ func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command {
8273
flags := cmd.Flags()
8374
flags.StringVarP(&options.description, "description", "m", "", "Description for cluster")
8475
flags.StringVarP(&options.filename, "topology", "f", "", "Specify the path of topology file")
85-
flags.StringVar(&options.deployType, "type", "develop", "Specify the type of cluster")
76+
8677
return cmd
8778
}
8879

@@ -143,19 +134,6 @@ func checkTopology(curveadm *cli.CurveAdm, data string, options addOptions) erro
143134
return pb.Run()
144135
}
145136

146-
func checkAddOptions(cmd *cobra.Command) error {
147-
deployType, err := cmd.Flags().GetString("deploy-type")
148-
if err != nil {
149-
return err
150-
}
151-
for _, t := range SUPPORTED_DEPLOY_TYPES {
152-
if deployType == t {
153-
return nil
154-
}
155-
}
156-
return errno.ERR_UNSUPPORT_DEPLOY_TYPE.F("deploy type: %s", deployType)
157-
}
158-
159137
func runAdd(curveadm *cli.CurveAdm, options addOptions) error {
160138
// 1) check wether cluster already exist
161139
name := options.name
@@ -185,7 +163,7 @@ func runAdd(curveadm *cli.CurveAdm, options addOptions) error {
185163

186164
// 4) insert cluster (with topology) into database
187165
uuid := uuid.NewString()
188-
err = storage.InsertCluster(name, uuid, options.description, data, options.deployType)
166+
err = storage.InsertCluster(name, uuid, options.description, data)
189167
if err != nil {
190168
return errno.ERR_INSERT_CLUSTER_FAILED.E(err)
191169
}

cli/command/cluster/import.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func importCluster(storage *storage.Storage, dbfile, name string) error {
100100
}
101101

102102
// insert cluster
103-
err = storage.InsertCluster(name, cluster.UUId, cluster.Description, cluster.Topology, cluster.Type)
103+
err = storage.InsertCluster(name, cluster.UUId, cluster.Description, cluster.Topology)
104104
if err != nil {
105105
return err
106106
}

cli/command/deploy.go

-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ func displayDeployTitle(curveadm *cli.CurveAdm, dcs []*topology.DeployConfig) {
302302
curveadm.WriteOutln("Cluster Name : %s", curveadm.ClusterName())
303303
curveadm.WriteOutln("Cluster Kind : %s", dcs[0].GetKind())
304304
curveadm.WriteOutln("Cluster Services: %s", serviceStats(dcs))
305-
curveadm.WriteOutln("Cluster Type : %s", curveadm.ClusterType())
306305
curveadm.WriteOutln("")
307306
}
308307

internal/errno/errno.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,8 @@ var (
254254
ERR_NO_SERVICES_MATCHED = EC(210006, "no services matched")
255255
// TODO: please check pool set disk type
256256
ERR_INVALID_DISK_TYPE = EC(210007, "poolset disk type must be lowercase and can only be one of ssd, hdd and nvme")
257-
ERR_UNSUPPORT_DEPLOY_TYPE = EC(210008, "unknown deploy type")
258-
ERR_NO_LEADER_OR_RANDOM_CONTAINER_FOUND = EC(210009, "no leader or random container found")
259-
257+
ERR_NO_LEADER_OR_RANDOM_CONTAINER_FOUND = EC(210008, "no leader or random container found")
258+
260259
// 220: commad options (client common)
261260
ERR_UNSUPPORT_CLIENT_KIND = EC(220000, "unsupport client kind")
262261
// 221: command options (client/bs)

internal/storage/sql.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ type Cluster struct {
103103
Topology string
104104
Pool string
105105
Current bool
106-
Type string
107106
}
108107

109108
var (
@@ -117,21 +116,15 @@ var (
117116
topology TEXT NULL,
118117
pool TEXT NULL,
119118
create_time DATE NOT NULL,
120-
current INTEGER DEFAULT 0,
121-
type TEXT NOT NULL
119+
current INTEGER DEFAULT 0
122120
)
123121
`
124122

125123
// insert cluster
126124
InsertCluster = `
127-
INSERT INTO clusters(uuid, name, description, topology, type, pool, create_time)
128-
VALUES(?, ?, ?, ?, ?, "", datetime('now','localtime'))
125+
INSERT INTO clusters(uuid, name, description, topology, pool, create_time)
126+
VALUES(?, ?, ?, ?, "", datetime('now','localtime'))
129127
`
130-
// check new cluster column
131-
GetTypeFiled = `SELECT COUNT(*) FROM pragma_table_info('clusters') WHERE name = 'type'`
132-
133-
// update new cluster column
134-
UpdateCluster = `ALTER TABLE clusters ADD COLUMN type TEXT NOT NULL DEFAULT 'develop'`
135128

136129
// delete cluster
137130
DeleteCluster = `DELETE from clusters WHERE name = ?`

internal/storage/storage.go

+3-29
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,7 @@ func (s *Storage) init() error {
9191
}
9292
}
9393

94-
flag, err := s.CheckTypeFiledExist()
95-
if err != nil {
96-
return err
97-
}
98-
if !flag {
99-
_, err = s.db.Write(UpdateCluster)
100-
}
101-
return err
94+
return nil
10295
}
10396

10497
func (s *Storage) write(query string, args ...any) error {
@@ -167,26 +160,8 @@ func (s *Storage) GetHostses() ([]Hosts, error) {
167160
}
168161

169162
// cluster
170-
func (s *Storage) InsertCluster(name, uuid, description, topology, deployType string) error {
171-
return s.write(InsertCluster, uuid, name, description, topology, deployType)
172-
}
173-
174-
func (s *Storage) CheckTypeFiledExist() (bool, error) {
175-
result, err := s.db.Query(GetTypeFiled)
176-
if err != nil {
177-
return false, err
178-
}
179-
defer result.Close()
180-
181-
var isFiledExist bool
182-
for result.Next() {
183-
err = result.Scan(&isFiledExist)
184-
if err != nil {
185-
return false, err
186-
}
187-
break
188-
}
189-
return isFiledExist, nil
163+
func (s *Storage) InsertCluster(name, uuid, description, topology string) error {
164+
return s.write(InsertCluster, uuid, name, description, topology)
190165
}
191166

192167
func (s *Storage) DeleteCluster(name string) error {
@@ -212,7 +187,6 @@ func (s *Storage) getClusters(query string, args ...interface{}) ([]Cluster, err
212187
&cluster.Pool,
213188
&cluster.CreateTime,
214189
&cluster.Current,
215-
&cluster.Type,
216190
)
217191
if err != nil {
218192
return nil, err

0 commit comments

Comments
 (0)