Skip to content

Commit

Permalink
network-tunnel: retain last logged error of tunnel and bubble up
Browse files Browse the repository at this point in the history
  • Loading branch information
mdibaiee committed Oct 29, 2024
1 parent e7ea6a8 commit f978f82
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion go/network-tunnel/network_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os/exec"
"syscall"

cerrors "github.com/estuary/connectors/go/connector-errors"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -112,7 +113,7 @@ func (t *SshTunnel) Start() error {
// an error that we would like to surface to the user without logging anything further
// ourselves
if err == io.EOF {
os.Exit(1)
return cerrors.NewTransparentError(err)
}
return fmt.Errorf("reading READY signal from network-tunnel: %w", err)
} else if !bytes.Equal(readyBuf, ready) {
Expand Down
2 changes: 1 addition & 1 deletion materialize-elasticsearch/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (c config) toClient(disableRetry bool) (*client, error) {
var tunnel = sshConfig.CreateTunnel()

if err := tunnel.Start(); err != nil {
return nil, fmt.Errorf("error starting network tunnel: %w", err)
return nil, err
}

// If SSH Tunnel is configured, we are going to create a tunnel from localhost:9200 to
Expand Down
2 changes: 1 addition & 1 deletion materialize-mongodb/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (d *driver) connect(ctx context.Context, cfg config) (*mongo.Client, error)
var tunnel = sshConfig.CreateTunnel()

if err := tunnel.Start(); err != nil {
return nil, fmt.Errorf("error starting network tunnel: %w", err)
return nil, err
}
}

Expand Down
2 changes: 1 addition & 1 deletion materialize-mysql/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func newMysqlDriver() *sql.Driver {
// FIXME/question: do we need to shut down the tunnel manually if it is a child process?
// at the moment tunnel.Stop is not being called anywhere, but if the connector shuts down, the child process also shuts down.
if err := tunnel.Start(); err != nil {
return fmt.Errorf("error starting network tunnel: %w", err)
return err
}
}

Expand Down
2 changes: 1 addition & 1 deletion materialize-postgres/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func newPostgresDriver() *sql.Driver {
// FIXME/question: do we need to shut down the tunnel manually if it is a child process?
// at the moment tunnel.Stop is not being called anywhere, but if the connector shuts down, the child process also shuts down.
if err := tunnel.Start(); err != nil {
return fmt.Errorf("error starting network tunnel: %w", err)
return err
}
}

Expand Down
2 changes: 1 addition & 1 deletion materialize-redshift/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func newRedshiftDriver() *sql.Driver {
var tunnel = sshConfig.CreateTunnel()

if err := tunnel.Start(); err != nil {
return fmt.Errorf("error starting network tunnel: %w", err)
return err
}
}

Expand Down
2 changes: 1 addition & 1 deletion source-mongodb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (d *driver) Connect(ctx context.Context, cfg config) (*mongo.Client, error)
var tunnel = sshConfig.CreateTunnel()

if err := tunnel.Start(); err != nil {
return nil, fmt.Errorf("error starting network tunnel: %w", err)
return nil, err
}
} else if isDocDB {
return nil, fmt.Errorf("the provided address %q appears to be for Amazon DocumentDB, which requires an SSH tunnel configuration", cfg.Address)
Expand Down
2 changes: 1 addition & 1 deletion source-mysql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func connectMySQL(ctx context.Context, name string, cfg json.RawMessage) (sqlcap
// FIXME/question: do we need to shut down the tunnel manually if it is a child process?
// at the moment tunnel.Stop is not being called anywhere, but if the connector shuts down, the child process also shuts down.
if err := tunnel.Start(); err != nil {
return nil, fmt.Errorf("error starting network tunnel: %w", err)
return nil, err
}
}

Expand Down
2 changes: 1 addition & 1 deletion source-oracle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func connectOracle(ctx context.Context, name string, cfg json.RawMessage) (sqlca
db.tunnel = sshConfig.CreateTunnel()

if err := db.tunnel.Start(); err != nil {
return nil, fmt.Errorf("error starting network tunnel: %w", err)
return nil, err
}
}

Expand Down
2 changes: 1 addition & 1 deletion source-postgres/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func connectPostgres(ctx context.Context, name string, cfg json.RawMessage) (sql
// FIXME/question: do we need to shut down the tunnel manually if it is a child process?
// at the moment tunnel.Stop is not being called anywhere, but if the connector shuts down, the child process also shuts down.
if err := tunnel.Start(); err != nil {
return nil, fmt.Errorf("error starting network tunnel: %w", err)
return nil, err
}
}

Expand Down
2 changes: 1 addition & 1 deletion source-sqlserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func connectSQLServer(ctx context.Context, name string, cfg json.RawMessage) (sq
// FIXME/question: do we need to shut down the tunnel manually if it is a child process?
// at the moment tunnel.Stop is not being called anywhere, but if the connector shuts down, the child process also shuts down.
if err := tunnel.Start(); err != nil {
return nil, fmt.Errorf("error starting network tunnel: %w", err)
return nil, err
}
}

Expand Down

0 comments on commit f978f82

Please sign in to comment.