Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-24.2: roachprod: preserve error object in Get #132959

Open
wants to merge 1 commit into
base: release-24.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions pkg/roachprod/install/cluster_synced.go
Original file line number Diff line number Diff line change
Expand Up @@ -2221,13 +2221,10 @@ func (c *SyncedCluster) Put(
close(results)
}()

var errOnce sync.Once
var finalErr error
setErr := func(e error) {
if e != nil {
errOnce.Do(func() {
finalErr = e
})
if finalErr != nil {
finalErr = e
}
}

Expand Down Expand Up @@ -2571,24 +2568,30 @@ func (c *SyncedCluster) Get(
close(results)
}()

var finalErr error
setErr := func(e error) {
if finalErr != nil {
finalErr = e
}
}

defer spinner.Start()()
haveErr := false
for {
r, ok := <-results
if !ok {
break
}
if r.err != nil {
haveErr = true
setErr(r.err)
nodeTaskStatus(nodes[r.index], r.err.Error(), true)
} else {
nodeTaskStatus(nodes[r.index], "done", true)
}
}
spinner.MaybeLogTasks(l)

if haveErr {
return errors.Newf("get %s failed", src)
if finalErr != nil {
return errors.Wrapf(finalErr, "get %s failed", src)
}
return nil
}
Expand Down