Skip to content

Commit dbf5d47

Browse files
committed
roachtest: allow saving clusters more generally
Even if neither --debug nor --debug-always are specified.
1 parent 7cc372f commit dbf5d47

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pkg/cmd/roachtest/cluster.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,12 @@ func (c *clusterImpl) Save(ctx context.Context, msg string, l *logger.Logger) {
11091109
c.destroyState.mu.Unlock()
11101110
}
11111111

1112+
func (c *clusterImpl) saved() bool {
1113+
c.destroyState.mu.Lock()
1114+
defer c.destroyState.mu.Unlock()
1115+
return c.destroyState.mu.saved
1116+
}
1117+
11121118
var errClusterNotFound = errors.New("cluster not found")
11131119

11141120
// validateCluster takes a cluster and checks that the reality corresponds to

pkg/cmd/roachtest/test_runner.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,12 @@ func (r *testRunner) runWorker(
987987
// Continue with a fresh cluster.
988988
c = nil
989989
case NoDebug:
990-
// On any test failure or error, we destroy the cluster. We could be
991-
// more selective, but this sounds safer.
992-
l.PrintfCtx(ctx, "destroying cluster %s because: %s", c, failureMsg)
993-
c.Destroy(context.Background(), closeLogger, l)
990+
if !c.saved() {
991+
// On any test failure or error, we destroy the cluster. We could be
992+
// more selective, but this sounds safer.
993+
l.PrintfCtx(ctx, "destroying cluster %s because: %s", c, failureMsg)
994+
c.Destroy(context.Background(), closeLogger, l)
995+
}
994996
c = nil
995997
}
996998
}

0 commit comments

Comments
 (0)