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

Further bump timeouts when behind SOCKS proxy #4725

Merged
merged 2 commits into from
Jan 17, 2025
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
2 changes: 1 addition & 1 deletion config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
const (
initialReadTimeout = 1 * time.Second
readTimeout = 5 * time.Second
readTimeoutBehindProxy = 15 * time.Second
readTimeoutBehindProxy = time.Minute
// PackagesDirName is where packages go underneath viamDotDir.
PackagesDirName = "packages"
// LocalPackagesSuffix is used by the local package manager.
Expand Down
26 changes: 22 additions & 4 deletions internal/cloud/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package cloud
import (
"context"
"errors"
"os"
"sync"
"time"

Expand All @@ -16,8 +17,13 @@ import (
"go.viam.com/rdk/resource"
)

// SubtypeName is a constant that identifies the internal cloud connection resource subtype string.
const SubtypeName = "cloud_connection"
const (
// SubtypeName is a constant that identifies the internal cloud connection resource
// subtype string.
SubtypeName = "cloud_connection"
connectTimeout = 5 * time.Second
connectTimeoutBehindProxy = time.Minute
)

// API is the fully qualified API for the internal cloud connection service.
var API = resource.APINamespaceRDKInternal.WithServiceType(SubtypeName)
Expand Down Expand Up @@ -74,7 +80,13 @@ func (cm *cloudManagedService) AcquireConnection(ctx context.Context) (string, r
}

ctx = rpc.ContextWithDialer(ctx, cm.dialer)
timeOutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
timeout := connectTimeout
// When environment indicates we are behind a proxy, bump timeout. Network
// operations tend to take longer when behind a proxy.
if os.Getenv(rpc.SocksProxyEnvVar) != "" {
timeout = connectTimeoutBehindProxy
}
timeOutCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
conn, err := config.CreateNewGRPCClient(timeOutCtx, &cm.cloudCfg, cm.logger)
return cm.cloudCfg.ID, conn, err
Expand All @@ -93,7 +105,13 @@ func (cm *cloudManagedService) AcquireConnectionAPIKey(ctx context.Context,
}

ctx = rpc.ContextWithDialer(ctx, cm.dialer)
timeOutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
timeout := connectTimeout
// When environment indicates we are behind a proxy, bump timeout. Network
// operations tend to take longer when behind a proxy.
if os.Getenv(rpc.SocksProxyEnvVar) != "" {
timeout = connectTimeoutBehindProxy
}
timeOutCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
conn, err := config.CreateNewGRPCClientWithAPIKey(timeOutCtx, &cm.cloudCfg, apiKey, apiKeyID, cm.logger)
return cm.cloudCfg.ID, conn, err
Expand Down
2 changes: 1 addition & 1 deletion logging/net_appender.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
writeBatchSize = 100
errUninitializedConnection = errors.New("sharedConn is true and connection is not initialized")
logWriteTimeout = 4 * time.Second
logWriteTimeoutBehindProxy = 12 * time.Second
logWriteTimeoutBehindProxy = time.Minute
)

// CloudConfig contains the necessary inputs to send logs to the app backend over grpc.
Expand Down
Loading