Skip to content

Commit b048580

Browse files
committed
feat: add backupVolume config in cluster createing
1 parent f816f6e commit b048580

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

internal/cli/cluster/create.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ func NewCreateOptions() *CreateOptions {
5555
OBServer: &param.OBServerSpec{
5656
Storage: &param.OBServerStorageSpec{},
5757
},
58-
Parameters: make([]modelcommon.KVPair, 0),
59-
Zones: make(map[string]string),
60-
Topology: make([]param.ZoneTopology, 0),
58+
BackupVolume: &param.NFSVolumeSpec{},
59+
Parameters: make([]modelcommon.KVPair, 0),
60+
Zones: make(map[string]string),
61+
Topology: make([]param.ZoneTopology, 0),
6162
}
6263
}
6364

@@ -75,14 +76,20 @@ func (o *CreateOptions) Validate() error {
7576
}
7677

7778
func (o *CreateOptions) Parse(_ *cobra.Command, args []string) error {
79+
// Parse the zone topology
7880
topology, err := utils.MapZonesToTopology(o.Zones)
7981
if err != nil {
8082
return err
8183
}
84+
// Parse the parameters
8285
parameters, err := utils.MapParameters(o.KvParameters)
8386
if err != nil {
8487
return err
8588
}
89+
// Parse the BackupVolume related flags
90+
if o.BackupVolume.Address == "" || o.BackupVolume.Path == "" {
91+
o.BackupVolume = nil
92+
}
8693
o.Parameters = parameters
8794
o.Topology = topology
8895
o.Name = args[0]
@@ -256,7 +263,7 @@ func buildMonitorTemplate(monitorSpec *param.MonitorSpec) *apitypes.MonitorTempl
256263
return monitorTemplate
257264
}
258265

259-
// Create an OBClusterInstance
266+
// CreateOBClusterInstance creates an OBClusterInstance
260267
func CreateOBClusterInstance(param *CreateOptions) *v1alpha1.OBCluster {
261268
observerTemplate := buildOBServerTemplate(param.OBServer)
262269
monitorTemplate := buildMonitorTemplate(param.Monitor)
@@ -296,6 +303,7 @@ func (o *CreateOptions) AddFlags(cmd *cobra.Command) {
296303
o.AddObserverFlags(cmd)
297304
o.AddZoneFlags(cmd)
298305
o.AddParameterFlags(cmd)
306+
o.AddBackupVolumeFlags(cmd)
299307
}
300308

301309
// AddZoneFlags adds the zone-related flags to the command.
@@ -342,8 +350,8 @@ func (o *CreateOptions) AddMonitorFlags(cmd *cobra.Command) {
342350
// AddBackupVolumeFlags adds the backup-volume-related flags to the command.
343351
func (o *CreateOptions) AddBackupVolumeFlags(cmd *cobra.Command) {
344352
backupVolumeFlags := pflag.NewFlagSet(FLAGSET_BACKUP_VOLUME, pflag.ContinueOnError)
345-
backupVolumeFlags.StringVar(&o.BackupVolume.Address, FLAG_BACKUP_ADDRESS, DEFAULT_BACKUP_ADDRESS, "The storage class of the backup storage")
346-
backupVolumeFlags.StringVar(&o.BackupVolume.Path, FLAG_BACKUP_PATH, DEFAULT_BACKUP_PATH, "The size of the backup storage")
353+
backupVolumeFlags.StringVar(&o.BackupVolume.Address, FLAG_BACKUP_ADDRESS, "", "The storage class of the backup storage")
354+
backupVolumeFlags.StringVar(&o.BackupVolume.Path, FLAG_BACKUP_PATH, "", "The size of the backup storage")
347355
cmd.Flags().AddFlagSet(backupVolumeFlags)
348356
}
349357

internal/cli/cluster/enter.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ const (
7373
DEFAULT_MONITOR_IMAGE = "oceanbase/obagent:4.2.1-100000092023101717"
7474
DEFAULT_MONITOR_CPU = 1
7575
DEFAULT_MONITOR_MEMORY = 1
76-
DEFAULT_BACKUP_ADDRESS = "local-path"
77-
DEFAULT_BACKUP_PATH = "/opt/nfs"
7876

7977
// Default values for Parameter flag
8078
DEFAULT_MIN_FULL_RESOURCE_POOL_MEMORY = "2147483648"

0 commit comments

Comments
 (0)