Skip to content

Commit

Permalink
feat: add backupVolume config in cluster createing
Browse files Browse the repository at this point in the history
  • Loading branch information
lizzy-0323 committed Oct 17, 2024
1 parent f816f6e commit b048580
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 14 additions & 6 deletions internal/cli/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ func NewCreateOptions() *CreateOptions {
OBServer: &param.OBServerSpec{
Storage: &param.OBServerStorageSpec{},
},
Parameters: make([]modelcommon.KVPair, 0),
Zones: make(map[string]string),
Topology: make([]param.ZoneTopology, 0),
BackupVolume: &param.NFSVolumeSpec{},
Parameters: make([]modelcommon.KVPair, 0),
Zones: make(map[string]string),
Topology: make([]param.ZoneTopology, 0),
}
}

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

func (o *CreateOptions) Parse(_ *cobra.Command, args []string) error {
// Parse the zone topology
topology, err := utils.MapZonesToTopology(o.Zones)
if err != nil {
return err
}
// Parse the parameters
parameters, err := utils.MapParameters(o.KvParameters)
if err != nil {
return err
}
// Parse the BackupVolume related flags
if o.BackupVolume.Address == "" || o.BackupVolume.Path == "" {
o.BackupVolume = nil
}
o.Parameters = parameters
o.Topology = topology
o.Name = args[0]
Expand Down Expand Up @@ -256,7 +263,7 @@ func buildMonitorTemplate(monitorSpec *param.MonitorSpec) *apitypes.MonitorTempl
return monitorTemplate
}

// Create an OBClusterInstance
// CreateOBClusterInstance creates an OBClusterInstance
func CreateOBClusterInstance(param *CreateOptions) *v1alpha1.OBCluster {
observerTemplate := buildOBServerTemplate(param.OBServer)
monitorTemplate := buildMonitorTemplate(param.Monitor)
Expand Down Expand Up @@ -296,6 +303,7 @@ func (o *CreateOptions) AddFlags(cmd *cobra.Command) {
o.AddObserverFlags(cmd)
o.AddZoneFlags(cmd)
o.AddParameterFlags(cmd)
o.AddBackupVolumeFlags(cmd)
}

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

Expand Down
2 changes: 0 additions & 2 deletions internal/cli/cluster/enter.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ const (
DEFAULT_MONITOR_IMAGE = "oceanbase/obagent:4.2.1-100000092023101717"
DEFAULT_MONITOR_CPU = 1
DEFAULT_MONITOR_MEMORY = 1
DEFAULT_BACKUP_ADDRESS = "local-path"
DEFAULT_BACKUP_PATH = "/opt/nfs"

// Default values for Parameter flag
DEFAULT_MIN_FULL_RESOURCE_POOL_MEMORY = "2147483648"
Expand Down

0 comments on commit b048580

Please sign in to comment.