Skip to content

Commit

Permalink
Make deps scanner connect timeout configurable.
Browse files Browse the repository at this point in the history
Adds a flag to set connection timeout to deps scanner, defaults to 60
seconds.

Bug: 352206623
Test: presubmits
Change-Id: I63e754d1780d49116ce84c279dd9bf4236eee9ad
GitOrigin-RevId: 56e5e9f24039cce777134fba61a53e068831479d
  • Loading branch information
MikeS-rec authored and copybara-github committed Aug 9, 2024
1 parent f01fb83 commit 981e9fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/pkg/cppdependencyscanner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/cppdependencyscanner/cppdepscanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
6 changes: 6 additions & 0 deletions internal/pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package features

import (
"flag"
"time"
)

// Config is the feature configuration in use.
Expand Down Expand Up @@ -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{}
Expand All @@ -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")
}

0 comments on commit 981e9fd

Please sign in to comment.