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.1: roachprod: preserve error object in Get #132958

Open
wants to merge 1 commit into
base: release-24.1
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
20 changes: 11 additions & 9 deletions pkg/roachprod/install/cluster_synced.go
Original file line number Diff line number Diff line change
Expand Up @@ -2212,13 +2212,10 @@ func (c *SyncedCluster) Put(
ticker = time.NewTicker(1000 * time.Millisecond)
}
defer ticker.Stop()
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 @@ -2608,7 +2605,12 @@ func (c *SyncedCluster) Get(
ticker = time.NewTicker(1000 * time.Millisecond)
}
defer ticker.Stop()
haveErr := false
var finalErr error
setErr := func(e error) {
if finalErr != nil {
finalErr = e
}
}

var spinner = []string{"|", "/", "-", "\\"}
spinnerIdx := 0
Expand All @@ -2626,7 +2628,7 @@ func (c *SyncedCluster) Get(
linesMu.Lock()
defer linesMu.Unlock()
if r.err != nil {
haveErr = true
setErr(r.err)
lines[r.index] = r.err.Error()
} else {
lines[r.index] = "done"
Expand Down Expand Up @@ -2663,8 +2665,8 @@ func (c *SyncedCluster) Get(
}()
}

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