Skip to content

Commit e3ece17

Browse files
author
releng
committed
Sync from server repo (d8d866f1a61)
1 parent a635dff commit e3ece17

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

vclusterops/https_check_subcluster_sandbox_op.go

+27
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ func (op *httpsCheckSubclusterSandboxOp) processResult(execContext *opEngineExec
157157

158158
// Use updated scInfo
159159
for host, sb := range existingSandboxedHosts {
160+
// Check if existing sandbox is aware of the new subcluster or not
161+
if !op.checkScAwareness(host) {
162+
return fmt.Errorf("target sandbox %s is unaware of the subcluster to be sandboxed - %s\n"+
163+
"Hint: try recreating the sandbox after unsandboxing the existing sandboxed subclusters", op.Sandbox, op.ScToSandbox)
164+
}
160165
// Just need one up host from the existing sandbox
161166
// This will be used to add new subcluster to an existing sandbox
162167
execContext.upHostsToSandboxes[host] = sb
@@ -170,8 +175,30 @@ func (op *httpsCheckSubclusterSandboxOp) processResult(execContext *opEngineExec
170175
break
171176
}
172177
}
178+
173179
return allErrs
174180
}
181+
182+
// Check whether the input host(sandboxed UP host) is aware of the sc to be sandboxed
183+
func (op *httpsCheckSubclusterSandboxOp) checkScAwareness(host string) bool {
184+
for reqHost, result := range op.clusterHTTPRequest.ResultCollection {
185+
if host == reqHost {
186+
subclusterResp := scResps{}
187+
err := op.parseAndCheckResponse(host, result.content, &subclusterResp)
188+
if err != nil {
189+
return false
190+
}
191+
// Check results to see if the sandbox is aware of the target sc to be sandboxed
192+
for _, scInfo := range subclusterResp.SCInfoList {
193+
if scInfo.SCName == op.ScToSandbox {
194+
return true
195+
}
196+
}
197+
}
198+
}
199+
return false
200+
}
201+
175202
func (op *httpsCheckSubclusterSandboxOp) processScInfo(scInfo subclusterSandboxInfo,
176203
execContext *opEngineExecContext) (mainClusterHosts, existingSandboxedHosts map[string]string, keysToRemove map[string]struct{}) {
177204
keysToRemove = make(map[string]struct{})

0 commit comments

Comments
 (0)