@@ -157,6 +157,11 @@ func (op *httpsCheckSubclusterSandboxOp) processResult(execContext *opEngineExec
157
157
158
158
// Use updated scInfo
159
159
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
+ }
160
165
// Just need one up host from the existing sandbox
161
166
// This will be used to add new subcluster to an existing sandbox
162
167
execContext .upHostsToSandboxes [host ] = sb
@@ -170,8 +175,30 @@ func (op *httpsCheckSubclusterSandboxOp) processResult(execContext *opEngineExec
170
175
break
171
176
}
172
177
}
178
+
173
179
return allErrs
174
180
}
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
+
175
202
func (op * httpsCheckSubclusterSandboxOp ) processScInfo (scInfo subclusterSandboxInfo ,
176
203
execContext * opEngineExecContext ) (mainClusterHosts , existingSandboxedHosts map [string ]string , keysToRemove map [string ]struct {}) {
177
204
keysToRemove = make (map [string ]struct {})
0 commit comments