Skip to content

Commit 604bb00

Browse files
craig[bot]renatolabs
craig[bot]
andcommitted
Merge #124721
124721: roachprod: fix check for errors in `find-ports` r=srosenberg,herkolategan a=renatolabs When finding ports, we only check for the `err` return value from `runCmdOnSingleNode`. However, that function only returns an error if there is a string expansion error. For command errors, the caller needs to check `res.Err`, which was not happening before. Informs: #124715 Co-authored-by: Renato Costa <[email protected]>
2 parents 108c66b + 21e229d commit 604bb00

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pkg/roachprod/install/cluster_synced.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -1146,14 +1146,20 @@ func defaultCmdOpts(debugName string) RunCmdOptions {
11461146
// - specifying the stdin, stdout, and stderr streams
11471147
// - specifying the remote session options
11481148
// - whether the command should be run with the ROACHPROD env variable (true for all user commands)
1149+
//
1150+
// NOTE: do *not* return a `nil` `*RunResultDetails` in this function:
1151+
// we want to support callers being able to use
1152+
// `errors.CombineErrors(err, res.Err)` when they don't care about the
1153+
// origin of the error.
11491154
func (c *SyncedCluster) runCmdOnSingleNode(
11501155
ctx context.Context, l *logger.Logger, node Node, cmd string, opts RunCmdOptions,
11511156
) (*RunResultDetails, error) {
1157+
var noResult RunResultDetails
11521158
// Argument template expansion is node specific (e.g. for {store-dir}).
11531159
e := expander{node: node}
11541160
expandedCmd, err := e.expand(ctx, l, c, cmd)
11551161
if err != nil {
1156-
return nil, errors.WithDetailf(err, "error expanding command: %s", cmd)
1162+
return &noResult, errors.WithDetailf(err, "error expanding command: %s", cmd)
11571163
}
11581164

11591165
nodeCmd := expandedCmd

pkg/roachprod/install/services.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ func (c *SyncedCluster) FindOpenPorts(
425425
}
426426

427427
res, err := c.runCmdOnSingleNode(ctx, l, node, buf.String(), defaultCmdOpts("find-ports"))
428-
if err != nil {
429-
return nil, transientFailure(errors.Wrapf(err, "output:\n%s", res.CombinedOut))
428+
if findPortsErr := errors.CombineErrors(err, res.Err); findPortsErr != nil {
429+
return nil, transientFailure(errors.Wrapf(findPortsErr, "output:\n%s", res.CombinedOut))
430430
}
431431
ports, err = stringToIntegers(strings.TrimSpace(res.CombinedOut))
432432
if err != nil {

0 commit comments

Comments
 (0)