@@ -270,26 +270,48 @@ func replicationSandbox(cmd *cobra.Command, args []string) {
270270 withProxySQL , _ := flags .GetBool ("with-proxysql" )
271271 if withProxySQL {
272272 // Determine the sandbox directory that was created
273- sandboxDir := path . Join ( sd . SandboxDir , defaults . Defaults (). MasterSlavePrefix + common . VersionToName ( origin ))
273+ var sandboxDir string
274274 if sd .DirName != "" {
275275 sandboxDir = path .Join (sd .SandboxDir , sd .DirName )
276+ } else if topology == globals .InnoDBClusterLabel {
277+ sandboxDir = path .Join (sd .SandboxDir , defaults .Defaults ().InnoDBClusterPrefix + common .VersionToName (origin ))
278+ } else {
279+ sandboxDir = path .Join (sd .SandboxDir , defaults .Defaults ().MasterSlavePrefix + common .VersionToName (origin ))
276280 }
277281
278- // Read port info from child sandbox descriptions
279- masterDesc , err := common .ReadSandboxDescription (path .Join (sandboxDir , defaults .Defaults ().MasterName ))
280- if err != nil {
281- common .Exitf (1 , "could not read master sandbox description: %s" , err )
282- }
283- masterPort := masterDesc .Port [0 ]
284-
282+ var masterPort int
285283 var slavePorts []int
286- for i := 1 ; i < nodes ; i ++ {
287- nodeDir := path .Join (sandboxDir , fmt .Sprintf ("%s%d" , defaults .Defaults ().NodePrefix , i ))
288- nodeDesc , err := common .ReadSandboxDescription (nodeDir )
284+
285+ if topology == globals .InnoDBClusterLabel {
286+ // InnoDB Cluster: node1 is primary, node2..N are secondaries
287+ primaryDesc , err := common .ReadSandboxDescription (path .Join (sandboxDir , fmt .Sprintf ("%s%d" , defaults .Defaults ().NodePrefix , 1 )))
289288 if err != nil {
290- common .Exitf (1 , "could not read node%d sandbox description: %s" , i , err )
289+ common .Exitf (1 , "could not read primary (node1) sandbox description: %s" , err )
290+ }
291+ masterPort = primaryDesc .Port [0 ]
292+ for i := 2 ; i <= nodes ; i ++ {
293+ nodeDir := path .Join (sandboxDir , fmt .Sprintf ("%s%d" , defaults .Defaults ().NodePrefix , i ))
294+ nodeDesc , err := common .ReadSandboxDescription (nodeDir )
295+ if err != nil {
296+ common .Exitf (1 , "could not read node%d sandbox description: %s" , i , err )
297+ }
298+ slavePorts = append (slavePorts , nodeDesc .Port [0 ])
299+ }
300+ } else {
301+ // Standard replication: master + node1..N-1 as slaves
302+ masterDesc , err := common .ReadSandboxDescription (path .Join (sandboxDir , defaults .Defaults ().MasterName ))
303+ if err != nil {
304+ common .Exitf (1 , "could not read master sandbox description: %s" , err )
305+ }
306+ masterPort = masterDesc .Port [0 ]
307+ for i := 1 ; i < nodes ; i ++ {
308+ nodeDir := path .Join (sandboxDir , fmt .Sprintf ("%s%d" , defaults .Defaults ().NodePrefix , i ))
309+ nodeDesc , err := common .ReadSandboxDescription (nodeDir )
310+ if err != nil {
311+ common .Exitf (1 , "could not read node%d sandbox description: %s" , i , err )
312+ }
313+ slavePorts = append (slavePorts , nodeDesc .Port [0 ])
291314 }
292- slavePorts = append (slavePorts , nodeDesc .Port [0 ])
293315 }
294316
295317 err = sandbox .DeployProxySQLForTopology (sandboxDir , masterPort , slavePorts , 0 , "127.0.0.1" , "" , topology )
0 commit comments