Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the new option --memory-meta-storage #200

Merged
merged 18 commits into from
May 28, 2024
6 changes: 6 additions & 0 deletions cmd/gtctl/cluster_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type clusterCreateCliOptions struct {
Config string
GreptimeBinVersion string
EnableCache bool
EnableEtcd bool

// Common options.
Timeout int
Expand Down Expand Up @@ -109,6 +110,7 @@ func NewCreateClusterCommand(l logger.Logger) *cobra.Command {
cmd.Flags().StringVar(&options.GreptimeDBClusterValuesFile, "greptimedb-cluster-values-file", "", "The values file for greptimedb cluster.")
cmd.Flags().StringVar(&options.EtcdClusterValuesFile, "etcd-cluster-values-file", "", "The values file for etcd cluster.")
cmd.Flags().StringVar(&options.GreptimeDBOperatorValuesFile, "greptimedb-operator-values-file", "", "The values file for greptimedb operator.")
cmd.Flags().BoolVarP(&options.EnableEtcd, "memory-meta-storage", "m", true, "Bootstrap the whole cluster without installing etcd for testing purposes through using the memory storage of metasrv in bare-metal mode.")

return cmd
}
Expand Down Expand Up @@ -178,11 +180,15 @@ func NewCluster(args []string, options *clusterCreateCliOptions, l logger.Logger
}

var cluster opt.Operations

zyy17 marked this conversation as resolved.
Show resolved Hide resolved
if options.BareMetal {

l.V(0).Infof("Creating GreptimeDB cluster '%s' on bare-metal", logger.Bold(clusterName))

var opts []baremetal.Option
opts = append(opts, baremetal.WithEnableCache(options.EnableCache))
opts = append(opts, baremetal.WithEnableEtcd(options.EnableEtcd))
zyy17 marked this conversation as resolved.
Show resolved Hide resolved

if len(options.GreptimeBinVersion) > 0 {
opts = append(opts, baremetal.WithGreptimeVersion(options.GreptimeBinVersion))
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/cluster/baremetal/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Cluster struct {
config *config.BareMetalClusterConfig
createNoDirs bool
enableCache bool
enableEtcd bool

am artifacts.Manager
mm metadata.Manager
Expand Down Expand Up @@ -84,6 +85,12 @@ func WithEnableCache(enableCache bool) Option {
}
}

func WithEnableEtcd(enableEtcd bool) Option {
return func(c *Cluster) {
c.enableEtcd = enableEtcd
}
}

func WithCreateNoDirs() Option {
return func(c *Cluster) {
c.createNoDirs = true
Expand Down
7 changes: 4 additions & 3 deletions pkg/cluster/baremetal/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ func (c *Cluster) Create(ctx context.Context, options *opt.CreateOptions) error
}
return nil
}

if err := withSpinner("Etcd Cluster", c.createEtcdCluster); err != nil {
return err
if c.enableEtcd {
if err := withSpinner("Etcd Cluster", c.createEtcdCluster); err != nil {
return err
}
}
if err := withSpinner("GreptimeDB Cluster", c.createCluster); err != nil {
if err := c.Wait(ctx, true); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/components/metasrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ CHECKER:
}

func (m *metaSrv) BuildArgs(params ...interface{}) []string {

zyy17 marked this conversation as resolved.
Show resolved Hide resolved
logLevel := m.config.LogLevel
if logLevel == "" {
logLevel = DefaultLogLevel
Expand All @@ -124,6 +125,7 @@ func (m *metaSrv) BuildArgs(params ...interface{}) []string {
fmt.Sprintf("--server-addr=%s", m.config.ServerAddr),
}
args = GenerateAddrArg("--http-addr", m.config.HTTPAddr, nodeID, args)

args = GenerateAddrArg("--bind-addr", bindAddr, nodeID, args)

if len(m.config.Config) > 0 {
Expand Down
Loading