Skip to content

Commit

Permalink
connector: add fix for long socket paths
Browse files Browse the repository at this point in the history
Now relative path is used instead of real for console socket.
It is used to prevent console socket path from being too long.
  • Loading branch information
better0fdead authored and LeonidVas committed Nov 3, 2022
1 parent e43946e commit 1e2d4a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

- A unix domain socket pathname (used in cartridge-cli to connect to instances) longer
than the value defined by the system resulted in a connection error.
It now works fine or throws a human readable error if we can't work around this
limitation by connecting to an instance with a relative socket path.

### Added

- Tarantool benchmark tool update (select and update operations):
Expand Down
15 changes: 15 additions & 0 deletions cli/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package connector
import (
"fmt"
"net"
"os"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -49,6 +51,19 @@ func Connect(connString string, opts Opts) (*Conn, error) {

connOpts := getConnOpts(connString, opts.Username, opts.Password)

if _, err := os.Stat(connOpts.Address); err == nil {
workDir, err := os.Getwd()
if err != nil {
return nil, err
}
os.Chdir(filepath.Dir(connOpts.Address))
connOpts.Address = "./" + filepath.Base(connOpts.Address)
defer os.Chdir(workDir)
if len(connOpts.Address) > 108 {
return nil, fmt.Errorf("Address is exceeding sun_path limit.(108 bytes)")
}
}

// connect to specified address
plainTextConn, err := net.Dial(connOpts.Network, connOpts.Address)
if err != nil {
Expand Down

0 comments on commit 1e2d4a0

Please sign in to comment.