Skip to content

Commit

Permalink
Sync from server repo (174b36d11c)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Spilchen committed Oct 26, 2023
1 parent 6866bdf commit c1901cb
Show file tree
Hide file tree
Showing 66 changed files with 284 additions and 284 deletions.
18 changes: 9 additions & 9 deletions vclusterops/add_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ type VAddNodeOptions struct {
func VAddNodeOptionsFactory() VAddNodeOptions {
opt := VAddNodeOptions{}
// set default values to the params
opt.SetDefaultValues()
opt.setDefaultValues()

return opt
}

func (o *VAddNodeOptions) SetDefaultValues() {
o.DatabaseOptions.SetDefaultValues()
func (o *VAddNodeOptions) setDefaultValues() {
o.DatabaseOptions.setDefaultValues()

o.SCName = new(string)
o.SkipRebalanceShards = new(bool)
Expand Down Expand Up @@ -81,7 +81,7 @@ func (o *VAddNodeOptions) validateExtraOptions() error {

func (o *VAddNodeOptions) validateParseOptions(log vlog.Printer) error {
// batch 1: validate required parameters
err := o.ValidateBaseOptions("db_add_node", log)
err := o.validateBaseOptions("db_add_node", log)
if err != nil {
return err
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func (vcc *VClusterCommands) VAddNode(options *VAddNodeOptions) (VCoordinationDa
}

// get hosts from config file and options.
hosts, err := options.GetHosts(options.Config)
hosts, err := options.getHosts(options.Config)
if err != nil {
return vdb, err
}
Expand Down Expand Up @@ -190,8 +190,8 @@ func (vcc *VClusterCommands) VAddNode(options *VAddNodeOptions) (VCoordinationDa
}

certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert}
clusterOpEngine := MakeClusterOpEngine(instructions, &certs)
if runError := clusterOpEngine.Run(vcc.Log); runError != nil {
clusterOpEngine := makeClusterOpEngine(instructions, &certs)
if runError := clusterOpEngine.run(vcc.Log); runError != nil {
return vdb, fmt.Errorf("fail to complete add node operation, %w", runError)
}
return vdb, nil
Expand Down Expand Up @@ -299,8 +299,8 @@ func (vcc *VClusterCommands) trimNodesInCatalog(vdb *VCoordinationDatabase,
}

certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert}
clusterOpEngine := MakeClusterOpEngine(instructions, &certs)
err := clusterOpEngine.Run(vcc.Log)
clusterOpEngine := makeClusterOpEngine(instructions, &certs)
err := clusterOpEngine.run(vcc.Log)
if err != nil {
vcc.Log.Error(err, "fail to trim nodes from catalog, %v")
return err
Expand Down
22 changes: 11 additions & 11 deletions vclusterops/add_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ type VAddSubclusterInfo struct {
func VAddSubclusterOptionsFactory() VAddSubclusterOptions {
opt := VAddSubclusterOptions{}
// set default values to the params
opt.SetDefaultValues()
opt.setDefaultValues()

return opt
}

func (options *VAddSubclusterOptions) SetDefaultValues() {
options.DatabaseOptions.SetDefaultValues()
func (options *VAddSubclusterOptions) setDefaultValues() {
options.DatabaseOptions.setDefaultValues()

options.SCName = new(string)
options.IsPrimary = new(bool)
Expand All @@ -71,7 +71,7 @@ func (options *VAddSubclusterOptions) SetDefaultValues() {
}

func (options *VAddSubclusterOptions) validateRequiredOptions(log vlog.Printer) error {
err := options.ValidateBaseOptions("db_add_subcluster", log)
err := options.validateBaseOptions("db_add_subcluster", log)
if err != nil {
return err
}
Expand All @@ -83,7 +83,7 @@ func (options *VAddSubclusterOptions) validateRequiredOptions(log vlog.Printer)
}

func (options *VAddSubclusterOptions) validateEonOptions(config *ClusterConfig) error {
isEon, err := options.IsEonMode(config)
isEon, err := options.isEonMode(config)
if err != nil {
return err
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func (options *VAddSubclusterOptions) analyzeOptions() (err error) {
return nil
}

func (options *VAddSubclusterOptions) ValidateAnalyzeOptions(config *ClusterConfig, vcc *VClusterCommands) error {
func (options *VAddSubclusterOptions) validateAnalyzeOptions(config *ClusterConfig, vcc *VClusterCommands) error {
if err := options.validateParseOptions(config, vcc); err != nil {
return err
}
Expand All @@ -184,7 +184,7 @@ func (vcc *VClusterCommands) VAddSubcluster(options *VAddSubclusterOptions) erro
* - Give the instructions to the VClusterOpEngine to run
*/

err := options.ValidateAnalyzeOptions(options.Config, vcc)
err := options.validateAnalyzeOptions(options.Config, vcc)
if err != nil {
return err
}
Expand All @@ -199,7 +199,7 @@ func (vcc *VClusterCommands) VAddSubcluster(options *VAddSubclusterOptions) erro
ControlSetSize: *options.ControlSetSize,
CloneSC: *options.CloneSC,
}
addSubclusterInfo.DBName, addSubclusterInfo.Hosts, err = options.GetNameAndHosts(options.Config)
addSubclusterInfo.DBName, addSubclusterInfo.Hosts, err = options.getNameAndHosts(options.Config)
if err != nil {
return err
}
Expand All @@ -211,10 +211,10 @@ func (vcc *VClusterCommands) VAddSubcluster(options *VAddSubclusterOptions) erro

// Create a VClusterOpEngine, and add certs to the engine
certs := HTTPSCerts{key: options.Key, cert: options.Cert, caCert: options.CaCert}
clusterOpEngine := MakeClusterOpEngine(instructions, &certs)
clusterOpEngine := makeClusterOpEngine(instructions, &certs)

// Give the instructions to the VClusterOpEngine to run
runError := clusterOpEngine.Run(vcc.Log)
runError := clusterOpEngine.run(vcc.Log)
if runError != nil {
return fmt.Errorf("fail to add subcluster %s, %w", addSubclusterInfo.SCName, runError)
}
Expand All @@ -241,7 +241,7 @@ func (vcc *VClusterCommands) produceAddSubclusterInstructions(addSubclusterInfo
usePassword := false
if addSubclusterInfo.Password != nil {
usePassword = true
err := options.ValidateUserName(vcc.Log)
err := options.validateUserName(vcc.Log)
if err != nil {
return instructions, err
}
Expand Down
2 changes: 1 addition & 1 deletion vclusterops/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (c *ClusterConfig) GetPathPrefix(dbName string) (catalogPrefix string,
dbConfig.Nodes[0].DepotPath, nil
}

func (c *DatabaseConfig) GetHosts() []string {
func (c *DatabaseConfig) getHosts() []string {
var hostList []string

for _, vnode := range c.Nodes {
Expand Down
16 changes: 8 additions & 8 deletions vclusterops/cluster_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ const respSuccStatusCode = 0
// 3. The local node has not yet joined the cluster; the HTTP server will accept connections once the node joins the cluster.
// HTTPCheckDBRunningOp in create_db need to check all scenarios to see any HTTP running
// For HTTPSPollNodeStateOp in start_db, it requires only handling the first and second scenarios
func (hostResult *HostHTTPResult) IsUnauthorizedRequest() bool {
func (hostResult *HostHTTPResult) isUnauthorizedRequest() bool {
return hostResult.statusCode == UnauthorizedCode
}

// IsSuccess returns true if status code is 200
func (hostResult *HostHTTPResult) IsSuccess() bool {
// isSuccess returns true if status code is 200
func (hostResult *HostHTTPResult) isSuccess() bool {
return hostResult.statusCode == SuccessCode
}

// check only password and certificate for start_db
func (hostResult *HostHTTPResult) IsPasswordAndCertificateError(log vlog.Printer) bool {
if !hostResult.IsUnauthorizedRequest() {
func (hostResult *HostHTTPResult) isPasswordAndCertificateError(log vlog.Printer) bool {
if !hostResult.isUnauthorizedRequest() {
return false
}
resultString := fmt.Sprintf("%v", hostResult)
Expand All @@ -119,12 +119,12 @@ func (hostResult *HostHTTPResult) IsPasswordAndCertificateError(log vlog.Printer
return false
}

func (hostResult *HostHTTPResult) IsInternalError() bool {
func (hostResult *HostHTTPResult) isInternalError() bool {
return hostResult.statusCode == InternalErrorCode
}

func (hostResult *HostHTTPResult) IsHTTPRunning() bool {
if hostResult.isPassing() || hostResult.IsUnauthorizedRequest() || hostResult.IsInternalError() {
func (hostResult *HostHTTPResult) isHTTPRunning() bool {
if hostResult.isPassing() || hostResult.isUnauthorizedRequest() || hostResult.isInternalError() {
return true
}
return false
Expand Down
6 changes: 3 additions & 3 deletions vclusterops/cluster_op_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type VClusterOpEngine struct {
execContext *OpEngineExecContext
}

func MakeClusterOpEngine(instructions []ClusterOp, certs *HTTPSCerts) VClusterOpEngine {
func makeClusterOpEngine(instructions []ClusterOp, certs *HTTPSCerts) VClusterOpEngine {
newClusterOpEngine := VClusterOpEngine{}
newClusterOpEngine.instructions = instructions
newClusterOpEngine.certs = certs
Expand All @@ -38,8 +38,8 @@ func (opEngine *VClusterOpEngine) shouldGetCertsFromOptions() bool {
return (opEngine.certs.key != "" && opEngine.certs.cert != "" && opEngine.certs.caCert != "")
}

func (opEngine *VClusterOpEngine) Run(log vlog.Printer) error {
execContext := MakeOpEngineExecContext(log)
func (opEngine *VClusterOpEngine) run(log vlog.Printer) error {
execContext := makeOpEngineExecContext(log)
opEngine.execContext = &execContext

findCertsInOptions := opEngine.shouldGetCertsFromOptions()
Expand Down
4 changes: 2 additions & 2 deletions vclusterops/cluster_op_engine_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type OpEngineExecContext struct {
dbInfo string // store the db info that retrieved from communal storage
}

func MakeOpEngineExecContext(log vlog.Printer) OpEngineExecContext {
func makeOpEngineExecContext(log vlog.Printer) OpEngineExecContext {
newOpEngineExecContext := OpEngineExecContext{}
newOpEngineExecContext.dispatcher = MakeHTTPRequestDispatcher(log)
newOpEngineExecContext.dispatcher = makeHTTPRequestDispatcher(log)

return newOpEngineExecContext
}
4 changes: 2 additions & 2 deletions vclusterops/cluster_op_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func TestSkipExecuteOp(t *testing.T) {
opWithSkipDisabled := makeMockOp(false)
instructions := []ClusterOp{&opWithSkipDisabled, &opWithSkipEnabled}
certs := HTTPSCerts{key: "key", cert: "cert", caCert: "ca-cert"}
opEngn := MakeClusterOpEngine(instructions, &certs)
err := opEngn.Run(vlog.Printer{})
opEngn := makeClusterOpEngine(instructions, &certs)
err := opEngn.run(vlog.Printer{})
assert.Equal(t, nil, err)
assert.True(t, opWithSkipDisabled.calledPrepare)
assert.True(t, opWithSkipDisabled.calledExecute)
Expand Down
24 changes: 12 additions & 12 deletions vclusterops/coordinator_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func MakeVCoordinationDatabase() VCoordinationDatabase {
return VCoordinationDatabase{}
}

func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabaseOptions, log vlog.Printer) error {
func (vdb *VCoordinationDatabase) setFromCreateDBOptions(options *VCreateDatabaseOptions, log vlog.Printer) error {
// build after validating the options
err := options.ValidateAnalyzeOptions(log)
err := options.validateAnalyzeOptions(log)
if err != nil {
return err
}
Expand Down Expand Up @@ -103,7 +103,7 @@ func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabas
vdb.UseDepot = true
}
if *options.GetAwsCredentialsFromEnv {
err := vdb.GetAwsCredentialsFromEnv()
err := vdb.getAwsCredentialsFromEnv()
if err != nil {
return err
}
Expand All @@ -113,7 +113,7 @@ func (vdb *VCoordinationDatabase) SetFromCreateDBOptions(options *VCreateDatabas
// section 3: build VCoordinationNode info
for _, host := range vdb.HostList {
vNode := MakeVCoordinationNode()
err := vNode.SetFromCreateDBOptions(options, host)
err := vNode.setFromCreateDBOptions(options, host)
if err != nil {
return err
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func (vdb *VCoordinationDatabase) addHosts(hosts []string) error {
Address: host,
Name: name,
}
vNode.SetFromNodeConfig(&nodeConfig, vdb)
vNode.setFromNodeConfig(&nodeConfig, vdb)
err := vdb.addNode(&vNode)
if err != nil {
return err
Expand All @@ -162,7 +162,7 @@ func (vdb *VCoordinationDatabase) addHosts(hosts []string) error {
return nil
}

func (vdb *VCoordinationDatabase) SetFromClusterConfig(dbName string,
func (vdb *VCoordinationDatabase) setFromClusterConfig(dbName string,
clusterConfig *ClusterConfig) error {
// we trust the information in the config file
// so we do not perform validation here
Expand Down Expand Up @@ -190,7 +190,7 @@ func (vdb *VCoordinationDatabase) SetFromClusterConfig(dbName string,
vdb.HostNodeMap = makeVHostNodeMap()
for _, nodeConfig := range dbConfig.Nodes {
vnode := VCoordinationNode{}
vnode.SetFromNodeConfig(nodeConfig, vdb)
vnode.setFromNodeConfig(nodeConfig, vdb)
err = vdb.addNode(&vnode)
if err != nil {
return err
Expand All @@ -200,10 +200,10 @@ func (vdb *VCoordinationDatabase) SetFromClusterConfig(dbName string,
return nil
}

// Copy copies the receiver's fields into a new VCoordinationDatabase struct and
// copy copies the receiver's fields into a new VCoordinationDatabase struct and
// returns that struct. You can choose to copy only a subset of the receiver's hosts
// by passing a slice of hosts to keep.
func (vdb *VCoordinationDatabase) Copy(targetHosts []string) VCoordinationDatabase {
func (vdb *VCoordinationDatabase) copy(targetHosts []string) VCoordinationDatabase {
v := VCoordinationDatabase{
Name: vdb.Name,
CatalogPrefix: vdb.CatalogPrefix,
Expand Down Expand Up @@ -316,7 +316,7 @@ func (vdb *VCoordinationDatabase) genCatalogPath(nodeName string) string {
}

// set aws id key and aws secret key
func (vdb *VCoordinationDatabase) GetAwsCredentialsFromEnv() error {
func (vdb *VCoordinationDatabase) getAwsCredentialsFromEnv() error {
awsIDKey := os.Getenv("AWS_ACCESS_KEY_ID")
if awsIDKey == "" {
return fmt.Errorf("unable to get AWS ID key from environment variable")
Expand Down Expand Up @@ -371,7 +371,7 @@ func MakeVCoordinationNode() VCoordinationNode {
return VCoordinationNode{}
}

func (vnode *VCoordinationNode) SetFromCreateDBOptions(
func (vnode *VCoordinationNode) setFromCreateDBOptions(
options *VCreateDatabaseOptions,
host string,
) error {
Expand Down Expand Up @@ -407,7 +407,7 @@ func (vnode *VCoordinationNode) SetFromCreateDBOptions(
return fmt.Errorf("fail to set up vnode from options: host %s does not exist in options", host)
}

func (vnode *VCoordinationNode) SetFromNodeConfig(nodeConfig *NodeConfig, vdb *VCoordinationDatabase) {
func (vnode *VCoordinationNode) setFromNodeConfig(nodeConfig *NodeConfig, vdb *VCoordinationDatabase) {
// we trust the information in the config file
// so we do not perform validation here
vnode.Address = nodeConfig.Address
Expand Down
Loading

0 comments on commit c1901cb

Please sign in to comment.