Skip to content

Commit

Permalink
Merge pull request #1198 from balena-os/ryan/ip-retries
Browse files Browse the repository at this point in the history
remove nested retries in getDutIp function
  • Loading branch information
flowzone-app[bot] authored Jul 23, 2024
2 parents 953c866 + fc8a487 commit 527ab00
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions core/lib/common/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,19 @@ module.exports = class Worker {
return doRequest({ method: 'POST', uri: `${this.url}/proxy`, body: proxy, json: true });
}

// the default doRequest parameters lead to 5 retries
// the /dut/ip endpoint takes around 10s to scan on the worker side
// setting tries to 50 here leads to 50*([default doRequest interval = 2] + ~10) = 600s/10 mins
async getDutIp(
target,
timeout = {
interval: 1000,
tries: 30,
},
tries = 50
) {
return retry(
() => {
return doRequest({
uri: `${this.url}/dut/ip`,
body: { target },
json: true,
});
},
{
max_tries: timeout.tries,
interval: timeout.interval,
throw_original: true,
},
return doRequest({
uri: `${this.url}/dut/ip`,
body: { target },
json: true,
},
tries
);
}

Expand Down

0 comments on commit 527ab00

Please sign in to comment.