Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connector: add fix for long socket paths #733

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
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
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