diff --git a/internal/pkg/cppdependencyscanner/BUILD.bazel b/internal/pkg/cppdependencyscanner/BUILD.bazel index 964dcf2b..267641cd 100644 --- a/internal/pkg/cppdependencyscanner/BUILD.bazel +++ b/internal/pkg/cppdependencyscanner/BUILD.bazel @@ -8,6 +8,7 @@ go_library( deps = [ "//api/scandeps", "//internal/pkg/cppdependencyscanner/depsscannerclient", + "//internal/pkg/features", "//internal/pkg/ipc", "@com_github_bazelbuild_remote_apis_sdks//go/pkg/command", "@com_github_bazelbuild_remote_apis_sdks//go/pkg/outerr", diff --git a/internal/pkg/cppdependencyscanner/cppdepscanner.go b/internal/pkg/cppdependencyscanner/cppdepscanner.go index 60932b34..004a9e59 100644 --- a/internal/pkg/cppdependencyscanner/cppdepscanner.go +++ b/internal/pkg/cppdependencyscanner/cppdepscanner.go @@ -29,6 +29,7 @@ import ( pb "github.com/bazelbuild/reclient/api/scandeps" "github.com/bazelbuild/reclient/internal/pkg/cppdependencyscanner/depsscannerclient" + "github.com/bazelbuild/reclient/internal/pkg/features" "github.com/bazelbuild/reclient/internal/pkg/ipc" "github.com/bazelbuild/remote-apis-sdks/go/pkg/command" @@ -93,5 +94,5 @@ var connect = func(ctx context.Context, address string) (pb.CPPDepsScannerClient // New creates new DepsScanner. func New(ctx context.Context, executor executor, cacheDir, logDir string, cacheSizeMaxMb int, useDepsCache bool, depsScannerAddress, proxyServerAddress string) (DepsScanner, error) { // TODO (b/258275137): make connTimeout configurable and move somewhere more appropriate when reconnect logic is implemented. - return depsscannerclient.New(ctx, executor, cacheDir, cacheSizeMaxMb, useDepsCache, logDir, depsScannerAddress, proxyServerAddress, 30*time.Second, connect) + return depsscannerclient.New(ctx, executor, cacheDir, cacheSizeMaxMb, useDepsCache, logDir, depsScannerAddress, proxyServerAddress, features.GetConfig().DepsScannerConnectTimeout, connect) } diff --git a/internal/pkg/features/features.go b/internal/pkg/features/features.go index eb0f0883..e098fba5 100644 --- a/internal/pkg/features/features.go +++ b/internal/pkg/features/features.go @@ -17,6 +17,7 @@ package features import ( "flag" + "time" ) // Config is the feature configuration in use. @@ -53,6 +54,10 @@ type Config struct { // If false, disables the credential cache even if the auth mechanism claims it is cachable. // It is enabled by default. EnableCredentialCache bool + + // DepsScannerConnectTimeout is the number of seconds to wait before timing out on connecting + // to the deps scanner service. + DepsScannerConnectTimeout time.Duration } var config = &Config{} @@ -71,4 +76,5 @@ func init() { flag.BoolVar(&GetConfig().ExperimentalExitOnStuckActions, "experimental_exit_on_stuck_actions", false, "Stops reproxy with exit_code=1 if the command didn't finish within 2*reclient_timeout") flag.BoolVar(&GetConfig().EnableCredentialCache, "enable_creds_cache", true, "If false, disables the credentials cache even if used auth mechanism supports it") flag.IntVar(&GetConfig().ExperimentalGomaDepsCacheSize, "experimental_goma_deps_cache_size", 300000, "Maximum number of entries to hold in the experimental deps cache.") + flag.DurationVar(&GetConfig().DepsScannerConnectTimeout, "depsscan_connect_timeout", 60*time.Second, "Number of seconds to wait before timing out on deps scanner connection attempt") }