Skip to content

Commit

Permalink
Sync from server repo (163c6de)
Browse files Browse the repository at this point in the history
  • Loading branch information
roypaulin committed Jan 30, 2024
1 parent 50409d2 commit 29203c0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
42 changes: 31 additions & 11 deletions vclusterops/https_re_ip_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,33 @@ import (
"github.com/vertica/vcluster/vclusterops/util"
)

// ReIPNoClusterQuorumError is an error to indicate
// that cluster quorum was lost before a re-ip.
// This is emitted from this op. Callers can do type checking to perform an
// action based on the error.
type ReIPNoClusterQuorumError struct {
Detail string
}

func (e *ReIPNoClusterQuorumError) Error() string {
return e.Detail
}

type httpsReIPOp struct {
opBase
opHTTPSBase
hostToReIP []string
reIPList map[string]ReIPInfo
nodeNamesList []string
upHosts []string
hostToReIP []string
reIPList map[string]ReIPInfo
nodeNamesToReIP []string
upHosts []string
}

func makeHTTPSReIPOp(nodeNamesList, hostToReIP []string,
func makeHTTPSReIPOp(nodeNamesToReIP, hostToReIP []string,
useHTTPPassword bool, userName string, httpsPassword *string) (httpsReIPOp, error) {
op := httpsReIPOp{}
op.name = "HTTPSReIpOp"
op.useHTTPPassword = useHTTPPassword
op.nodeNamesList = nodeNamesList
op.nodeNamesToReIP = nodeNamesToReIP
op.hostToReIP = hostToReIP

if useHTTPPassword {
Expand All @@ -52,8 +64,16 @@ func makeHTTPSReIPOp(nodeNamesList, hostToReIP []string,
return op, nil
}

func (op *httpsReIPOp) setupClusterHTTPRequest(hosts []string) error {
for i, host := range hosts {
func (op *httpsReIPOp) setupClusterHTTPRequest(hostsToReIP []string) error {
// At this point there must be more up nodes than hosts to re-ip.
// Failure to meet that requirement would most likely mean that we have lost
// quorum and a cluster restart is needed
if len(op.upHosts) < len(hostsToReIP) {
return &ReIPNoClusterQuorumError{
Detail: fmt.Sprintf("[%s] %d up nodes are not enough for re-ip", op.name, len(op.upHosts)),
}
}
for i, host := range hostsToReIP {
httpRequest := hostHTTPRequest{}
httpRequest.Method = PutMethod
nodesInfo, ok := op.reIPList[host]
Expand All @@ -79,8 +99,8 @@ func (op *httpsReIPOp) setupClusterHTTPRequest(hosts []string) error {
func (op *httpsReIPOp) prepare(execContext *opEngineExecContext) error {
op.reIPList = make(map[string]ReIPInfo)
// update reIPList from input node names and execContext.networkProfiles
for i := 0; i < len(op.nodeNamesList); i++ {
nodeNameToReIP := op.nodeNamesList[i]
for i := 0; i < len(op.nodeNamesToReIP); i++ {
nodeNameToReIP := op.nodeNamesToReIP[i]
targetAddress := op.hostToReIP[i]
profile, ok := execContext.networkProfiles[targetAddress]
if !ok {
Expand All @@ -98,7 +118,7 @@ func (op *httpsReIPOp) prepare(execContext *opEngineExecContext) error {
// use up hosts to execute the HTTP re-IP endpoint
op.upHosts = execContext.upHosts
execContext.dispatcher.setup(op.upHosts)
return op.setupClusterHTTPRequest(op.nodeNamesList)
return op.setupClusterHTTPRequest(op.nodeNamesToReIP)
}

func (op *httpsReIPOp) execute(execContext *opEngineExecContext) error {
Expand Down
2 changes: 1 addition & 1 deletion vclusterops/start_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type VStartNodesInfo struct {
// The IP address that we intend to re-IP can be obtained from a set of nodes provided as input
// within VStartNodesOptions struct
ReIPList []string
// The node names that we intend to start can be acquired from a set of nodes provided as input
// The names of the nodes that we intend to re-IP can be acquired from a set of nodes provided as input
// within the VStartNodesOptions struct
NodeNamesToStart []string
// the hosts that we want to start
Expand Down

0 comments on commit 29203c0

Please sign in to comment.