debugd: return download error if download is not attempted due to retry backoff

This commit is contained in:
Malte Poll 2022-03-30 13:25:34 +02:00 committed by Malte Poll
parent 995f2f6270
commit 7143b29caf
2 changed files with 2 additions and 5 deletions

View File

@ -37,7 +37,7 @@ func (d *Download) DownloadCoordinator(ctx context.Context, ip string) error {
serverAddr := net.JoinHostPort(ip, debugd.DebugdPort)
// only retry download from same endpoint after backoff
if lastAttempt, ok := d.attemptedDownloads[serverAddr]; ok && time.Since(lastAttempt) < debugd.CoordinatorDownloadRetryBackoff {
return nil
return fmt.Errorf("download failed too recently: %v / %v", time.Since(lastAttempt), debugd.CoordinatorDownloadRetryBackoff)
}
log.Printf("Trying to download coordinator from %s\n", ip)
d.attemptedDownloads[serverAddr] = time.Now()

View File

@ -52,10 +52,7 @@ func TestDownloadCoordinator(t *testing.T) {
attemptedDownloads: map[string]time.Time{
"192.0.2.0:4000": time.Now(),
},
expectDownloadErr: false,
expectFile: false,
expectSystemdAction: false,
expectDeployed: false,
expectDownloadErr: true,
},
"download rpc call error is detected": {
server: fakeOnlyDownloadServer{