diff options
| author | 2023-07-24 03:44:16 +0000 | |
|---|---|---|
| committer | 2023-07-24 17:06:42 +0000 | |
| commit | 6d1e348cc37df5f52b06ebcd9b722c03f7021096 (patch) | |
| tree | 9293db96a3042d9fe4bec729d4ff9e76fa969a5d | |
| parent | 66b27cb853cf9194e3a67cab89968a7fa392aebd (diff) | |
Disable RBE env variable when we cannot support RBE
Enabling the RBE variable can cause issues around pool parallelism when
we set the env variable, but don' run the build with RBE due to auth issues.
So, I am explicitly unsetting the variables in those cases.
Bug: b/292224253
Tested: https://b.corp.google.com/issues/292224253#comment26
Change-Id: I19718b4ee6c058ba1b11d3df260421bbf8c9567e
| -rw-r--r-- | ui/build/config.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/ui/build/config.go b/ui/build/config.go index fb5f7dd58..e5c9a5012 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -374,6 +374,11 @@ func NewConfig(ctx Context, args ...string) Config { if err := loadEnvConfig(ctx, ret, bc); err != nil { ctx.Fatalln("Failed to parse env config files: %v", err) } + if !ret.canSupportRBE() { + // Explicitly set USE_RBE env variable to false when we cannot run + // an RBE build to avoid ninja local execution pool issues. + ret.environ.Set("USE_RBE", "false") + } } if distDir, ok := ret.environ.Get("DIST_DIR"); ok { @@ -1374,18 +1379,26 @@ func (c *configImpl) StartGoma() bool { return true } +func (c *configImpl) canSupportRBE() bool { + // Do not use RBE with prod credentials in scenarios when stubby doesn't exist, since + // its unlikely that we will be able to obtain necessary creds without stubby. + authType, _ := c.rbeAuth() + if !c.StubbyExists() && strings.Contains(authType, "use_google_prod_creds") { + return false + } + return true +} + func (c *configImpl) UseRBE() bool { // These alternate modes of running Soong do not use RBE / reclient. if c.Bp2Build() || c.Queryview() || c.ApiBp2build() || c.JsonModuleGraph() { return false } - authType, _ := c.rbeAuth() - // Do not use RBE with prod credentials in scenarios when stubby doesn't exist, since - // its unlikely that we will be able to obtain necessary creds without stubby. - if !c.StubbyExists() && strings.Contains(authType, "use_google_prod_creds") { + if !c.canSupportRBE() { return false } + if v, ok := c.Environment().Get("USE_RBE"); ok { v = strings.TrimSpace(v) if v != "" && v != "false" { |