Move startRBE error handling to the main goroutine
When called from the startRBE goroutine, the panic ctx.Fatalf triggered by is unhandled and causes the process to exit without cleaning up the terminal. Move most of the quick checks to a checkRBERequirements function called on the main goroutine so they can be reported immediately before running Soong and Kati, and recover any panics from startRBE and report them after waiting on rbeCh. Bug: 293501187 Test: gcertdestroy && m nothing Change-Id: I62c84c93ab0a7f0e4f2ab2cc64b22e2070dd6e4c
This commit is contained in:
@@ -283,11 +283,16 @@ func Build(ctx Context, config Config) {
|
||||
}
|
||||
|
||||
rbeCh := make(chan bool)
|
||||
var rbePanic any
|
||||
if config.StartRBE() {
|
||||
cleanupRBELogsDir(ctx, config)
|
||||
checkRBERequirements(ctx, config)
|
||||
go func() {
|
||||
defer func() {
|
||||
rbePanic = recover()
|
||||
close(rbeCh)
|
||||
}()
|
||||
startRBE(ctx, config)
|
||||
close(rbeCh)
|
||||
}()
|
||||
defer DumpRBEMetrics(ctx, config, filepath.Join(config.LogsDir(), "rbe_metrics.pb"))
|
||||
} else {
|
||||
@@ -345,6 +350,11 @@ func Build(ctx Context, config Config) {
|
||||
}
|
||||
|
||||
<-rbeCh
|
||||
if rbePanic != nil {
|
||||
// If there was a ctx.Fatal in startRBE, rethrow it.
|
||||
panic(rbePanic)
|
||||
}
|
||||
|
||||
if what&RunNinja != 0 {
|
||||
if what&RunKati != 0 {
|
||||
installCleanIfNecessary(ctx, config)
|
||||
|
Reference in New Issue
Block a user