Skip to content

Commit

Permalink
Sync from server repo (52bb39c07ad)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Spilchen committed Feb 6, 2024
1 parent fe6d9f1 commit 8e74a02
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
7 changes: 4 additions & 3 deletions vclusterops/create_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ func (vcc *VClusterCommands) produceCreateDBBootstrapInstructions(

nmaStartNodeOp := makeNMAStartNodeOp(vcc.Log, bootstrapHost, *options.StartUpConf)

httpsPollBootstrapNodeStateOp, err := makeHTTPSPollNodeStateOp(vcc.Log, bootstrapHost, true, /* useHTTPPassword */
*options.UserName, options.Password)
httpsPollBootstrapNodeStateOp, err := makeHTTPSPollNodeStateOpWithTimeoutAndCommand(vcc.Log, bootstrapHost, true, /* useHTTPPassword */
*options.UserName, options.Password, *options.TimeoutNodeStartupSeconds, CreateDBCmd)
if err != nil {
return instructions, err
}
Expand Down Expand Up @@ -621,7 +621,8 @@ func (vcc *VClusterCommands) produceAdditionalCreateDBInstructions(vdb *VCoordin
username := *options.UserName

if !*options.SkipStartupPolling {
httpsPollNodeStateOp, err := makeHTTPSPollNodeStateOp(vcc.Log, hosts, true, username, options.Password)
httpsPollNodeStateOp, err := makeHTTPSPollNodeStateOpWithTimeoutAndCommand(vcc.Log, hosts, true, username, options.Password,
*options.TimeoutNodeStartupSeconds, CreateDBCmd)
if err != nil {
return instructions, err
}
Expand Down
9 changes: 6 additions & 3 deletions vclusterops/https_poll_node_state_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const httpRequestTimeoutSeconds = 30
const (
StartDBCmd CmdType = iota
StartNodeCmd
CreateDBCmd
)

type CmdType int
Expand All @@ -41,6 +42,8 @@ func (cmd CmdType) String() string {
return "start_db"
case StartNodeCmd:
return "restart_node"
case CreateDBCmd:
return "create_db"
}
return "unknown_operation"
}
Expand Down Expand Up @@ -100,7 +103,6 @@ func makeHTTPSPollNodeStateOp(logger vlog.Printer, hosts []string,
}

func (op *httpsPollNodeStateOp) getPollingTimeout() int {
// a negative value indicates no timeout and should never be used for this op
return util.Max(op.timeout, 0)
}

Expand Down Expand Up @@ -175,9 +177,10 @@ func (op *httpsPollNodeStateOp) shouldStopPolling() (bool, error) {
op.name)
return true, fmt.Errorf("[%s] wrong password/certificate for https service on host %s, but the nodes' startup have been in progress."+
"Please use vsql to check the nodes' status and manually run sync_catalog vsql command 'select sync_catalog()'", op.name, host)
case CreateDBCmd:
return true, fmt.Errorf("[%s] wrong password/certificate for https service on host %s",
op.name, host)
}
return true, fmt.Errorf("[%s] wrong password/certificate for https service on host %s",
op.name, host)
}
if result.isPassing() {
// parse the /nodes/{node} endpoint response
Expand Down
15 changes: 14 additions & 1 deletion vclusterops/https_poll_node_state_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/vertica/vcluster/vclusterops/vlog"
)

func TestTimeoutCase(t *testing.T) {
func TestTimeoutErrorCase(t *testing.T) {
var instructions []clusterOp
// use a non-existing IP to test the timeout error
// 192.0.2.1 is one that is reserved for test purpose (by RFC 5737)
Expand All @@ -33,8 +33,21 @@ func TestTimeoutCase(t *testing.T) {
assert.Nil(t, err)
instructions = append(instructions, &httpsPollNodeStateOp)

// default timeout value for the op
certs := httpsCerts{}
clusterOpEngine := makeClusterOpEngine(instructions, &certs)
err = clusterOpEngine.run(vlog.Printer{})
// expect timeout error in http response
assert.ErrorContains(t, err, "[HTTPSPollNodeStateOp] cannot connect to host 192.0.2.1, please check if the host is still alive")

// negative timeout value for the op (treated as 0, means no polling)
instructions = make([]clusterOp, 0)
httpsPollNodeStateOp, err = makeHTTPSPollNodeStateOpWithTimeoutAndCommand(vlog.Printer{}, hosts, true, username, &password,
-100, CreateDBCmd)
assert.Nil(t, err)
instructions = append(instructions, &httpsPollNodeStateOp)
clusterOpEngine = makeClusterOpEngine(instructions, &certs)
err = clusterOpEngine.run(vlog.Printer{})
// no polling is done, directly error out
assert.ErrorContains(t, err, "reached polling timeout of 0 seconds")
}
2 changes: 2 additions & 0 deletions vclusterops/nma_show_restore_points_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ type RestorePoint struct {
Index int
// The timestamp when the restore point was created.
Timestamp string
// The version of Vertica running when the restore point was created.
VerticaVersion string
}

func (op *nmaShowRestorePointsOp) processResult(execContext *opEngineExecContext) error {
Expand Down
2 changes: 1 addition & 1 deletion vclusterops/revive_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestFindSpecifiedRestorePoint(t *testing.T) {
*options.RestorePoint.ID = expectedID
_, err = options.findSpecifiedRestorePoint(allRestorePoints)
expectedErr := fmt.Errorf("found 2 restore points instead of 1: " +
"[{Archive:archive1 ID:id3 Index:2 Timestamp:} {Archive:archive1 ID:id3 Index:3 Timestamp:}]")
"[{Archive:archive1 ID:id3 Index:2 Timestamp: VerticaVersion:} {Archive:archive1 ID:id3 Index:3 Timestamp: VerticaVersion:}]")
assert.EqualError(t, err, expectedErr.Error())

// Test case: No matching restore points found
Expand Down

0 comments on commit 8e74a02

Please sign in to comment.