Skip to content

Commit

Permalink
Sync from server repo (d8d866f1a61)
Browse files Browse the repository at this point in the history
  • Loading branch information
releng committed Jan 17, 2025
1 parent a635dff commit e3ece17
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions vclusterops/https_check_subcluster_sandbox_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ func (op *httpsCheckSubclusterSandboxOp) processResult(execContext *opEngineExec

// Use updated scInfo
for host, sb := range existingSandboxedHosts {
// Check if existing sandbox is aware of the new subcluster or not
if !op.checkScAwareness(host) {
return fmt.Errorf("target sandbox %s is unaware of the subcluster to be sandboxed - %s\n"+
"Hint: try recreating the sandbox after unsandboxing the existing sandboxed subclusters", op.Sandbox, op.ScToSandbox)
}
// Just need one up host from the existing sandbox
// This will be used to add new subcluster to an existing sandbox
execContext.upHostsToSandboxes[host] = sb
Expand All @@ -170,8 +175,30 @@ func (op *httpsCheckSubclusterSandboxOp) processResult(execContext *opEngineExec
break
}
}

return allErrs
}

// Check whether the input host(sandboxed UP host) is aware of the sc to be sandboxed
func (op *httpsCheckSubclusterSandboxOp) checkScAwareness(host string) bool {
for reqHost, result := range op.clusterHTTPRequest.ResultCollection {
if host == reqHost {
subclusterResp := scResps{}
err := op.parseAndCheckResponse(host, result.content, &subclusterResp)
if err != nil {
return false
}
// Check results to see if the sandbox is aware of the target sc to be sandboxed
for _, scInfo := range subclusterResp.SCInfoList {
if scInfo.SCName == op.ScToSandbox {
return true
}
}
}
}
return false
}

func (op *httpsCheckSubclusterSandboxOp) processScInfo(scInfo subclusterSandboxInfo,
execContext *opEngineExecContext) (mainClusterHosts, existingSandboxedHosts map[string]string, keysToRemove map[string]struct{}) {
keysToRemove = make(map[string]struct{})
Expand Down

0 comments on commit e3ece17

Please sign in to comment.