Skip to content

Commit

Permalink
Sync from server repo (e2dcd49aaa4)
Browse files Browse the repository at this point in the history
  • Loading branch information
releng committed Nov 20, 2024
1 parent 46d6fdd commit 5ee583d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion vclusterops/https_get_up_nodes_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,15 @@ func (op *httpsGetUpNodesOp) collectUnsandboxingHosts(nodesStates nodesStateInfo
mainNodeFound := false
sandboxNodeFound := false
for _, node := range nodesStates.NodeList {
if node.State == util.NodeUpState {
// We can only send unsandbox commands from nodes that are in the UP or UNKNOWN state (in a sandbox)
// If the node is in any other states, it cannot unsandbox or cannot receive https requests
if node.State == util.NodeUpState || node.State == util.NodeUnknownState {
// A sandbox could consist of multiple subclusters.
// We need to run unsandbox command on the other subcluster node in the same sandbox
// Find a node from same sandbox but different subcluster, if exists
if node.Sandbox == op.sandbox && node.Subcluster != op.scName {
sandboxInfo[node.Address] = node.Sandbox
sandboxNodeFound = true
}
// Get one main cluster host
if node.Sandbox == "" && !mainNodeFound {
Expand Down
7 changes: 6 additions & 1 deletion vclusterops/https_poll_node_state_indirect_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (
"github.com/vertica/vcluster/vclusterops/util"
)

// httpsPollNodeStateIndirectOp allows polling for the state of nodes when those nodes certainly
// or possibly cannot be polled directly for their state. For example, compute nodes, or nodes of
// unknown type. Instead of calling the nodes endpoint directly on each host for info about only
// that node, it calls the nodes endpoint for all nodes on a separate slice of hosts (e.g. primary
// UP nodes in the same sandbox) which should know the states of all the nodes being checked.
type httpsPollNodeStateIndirectOp struct {
opBase
opHTTPSBase
Expand Down Expand Up @@ -224,7 +229,7 @@ func (op *httpsPollNodeStateIndirectOp) shouldStopPolling() (bool, error) {
return true, err
}

// check which nodes have COMPUTE status
// check which nodes have desired state, e.g. COMPUTE, UP, etc.
upNodeCount := 0
for _, nodeInfo := range nodesInformation.NodeList {
_, ok := op.checkedHostsToState[nodeInfo.Address]
Expand Down
10 changes: 7 additions & 3 deletions vclusterops/https_unsandbox_subcluster_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"

mapset "github.com/deckarep/golang-set/v2"
"github.com/vertica/vcluster/vclusterops/util"
)

Expand Down Expand Up @@ -75,21 +76,24 @@ func (op *httpsUnsandboxingOp) setupRequestBody() error {
}

func (op *httpsUnsandboxingOp) prepare(execContext *opEngineExecContext) error {
sandboxes := mapset.NewSet[string]()
var mainHost string
if len(execContext.upHostsToSandboxes) == 0 {
return fmt.Errorf(`[%s] Cannot find any up hosts in OpEngineExecContext`, op.name)
}
// use an UP host in main cluster to execute the https post request
// use an UP host in main cluster and UP host in separate sc in same sandbox to execute the https post request
for h, sb := range execContext.upHostsToSandboxes {
if !sandboxes.Contains(sb) {
op.hosts = append(op.hosts, h)
sandboxes.Add(sb)
}
if sb == "" {
mainHost = h
break
}
}
if mainHost == "" {
return fmt.Errorf(`[%s] Cannot find any up hosts of main cluster in OpEngineExecContext`, op.name)
}
op.hosts = []string{mainHost}
err := op.setupRequestBody()
if err != nil {
return err
Expand Down

0 comments on commit 5ee583d

Please sign in to comment.