Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cmd/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,32 @@ func singleSandbox(cmd *cobra.Command, args []string) {
if err != nil {
common.Exitf(1, globals.ErrCreatingSandbox, err)
}

flags := cmd.Flags()
withProxySQL, _ := flags.GetBool("with-proxysql")
if withProxySQL {
// Determine the sandbox directory that was created
origin := args[0]
if args[0] != sd.BasedirName {
origin = sd.BasedirName
}
sandboxDir := path.Join(sd.SandboxDir, defaults.Defaults().SandboxPrefix+common.VersionToName(origin))
if sd.DirName != "" {
sandboxDir = path.Join(sd.SandboxDir, sd.DirName)
Comment on lines +469 to +475
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sandbox directory calculation doesn’t match the logic used in sandbox.createSingleSandbox when sd.DirName is empty. In particular, if the user supplies --binary-version and the basedir directory name differs from sd.Version (e.g. basedir name contains dots or other characters), createSingleSandbox uses defaults.Defaults().SandboxPrefix + sd.BasedirName (no VersionToName conversion), but this code applies common.VersionToName(origin) and can point to a non-existent directory. Consider mirroring the exact directory naming logic from createSingleSandbox: if sd.DirName is empty, build the dir name based on whether sd.Version != sd.BasedirName and only apply VersionToName to sd.Version in the sd.Version == sd.BasedirName case.

Suggested change
origin := args[0]
if args[0] != sd.BasedirName {
origin = sd.BasedirName
}
sandboxDir := path.Join(sd.SandboxDir, defaults.Defaults().SandboxPrefix+common.VersionToName(origin))
if sd.DirName != "" {
sandboxDir = path.Join(sd.SandboxDir, sd.DirName)
var sandboxDir string
if sd.DirName != "" {
// If a custom directory name was specified, use it directly.
sandboxDir = path.Join(sd.SandboxDir, sd.DirName)
} else {
// Mirror the naming logic from createSingleSandbox when DirName is empty.
prefix := defaults.Defaults().SandboxPrefix
if sd.BasedirName != "" && sd.Version != sd.BasedirName {
// When the basedir name differs from the version (e.g. provided via --binary-version),
// use the basedir name as-is without applying VersionToName.
sandboxDir = path.Join(sd.SandboxDir, prefix+sd.BasedirName)
} else {
// When the basedir name matches the version (or is empty), apply VersionToName to the version.
sandboxDir = path.Join(sd.SandboxDir, prefix+common.VersionToName(sd.Version))
}

Copilot uses AI. Check for mistakes.
}

// Read port info from sandbox description
sbDesc, err := common.ReadSandboxDescription(sandboxDir)
if err != nil {
common.Exitf(1, "could not read sandbox description: %s", err)
}
masterPort := sbDesc.Port[0]

err = sandbox.DeployProxySQLForTopology(sandboxDir, masterPort, nil, 0, "127.0.0.1")
if err != nil {
common.Exitf(1, "ProxySQL deployment failed: %s", err)
}
}
}

var singleCmd = &cobra.Command{
Expand Down Expand Up @@ -488,4 +514,5 @@ func init() {
singleCmd.PersistentFlags().Bool(globals.MasterLabel, false, "Make the server replication ready")
singleCmd.PersistentFlags().Int(globals.ServerIdLabel, 0, "Overwrite default server-id")
setPflag(singleCmd, globals.PromptLabel, "", "", globals.PromptValue, "Default prompt for the single client", false)
singleCmd.PersistentFlags().Bool("with-proxysql", false, "Deploy ProxySQL alongside the single sandbox")
}
Loading