Skip to content
Merged
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
26 changes: 12 additions & 14 deletions lib/tc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,25 @@ const delay = (ms) => new Promise((result) => setTimeout(result, ms));
async function getDefaultInterface() {
const command =
"sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'";
const result = await shell(command);

if (result.stdout.length === 0 && result.stderr.length > 0) {
throw new Error(
'There was an error getting the default interface:\n\n' + result.stderr
);
} else if (result.stdout.length === 0) {
// lets do one retry
// The GitHub Actions sometimes cannot find the interface
await delay(1000);
// Retry a few times since GitHub Actions sometimes temporarily loses the default route
for (let attempt = 0; attempt < 3; attempt++) {
const result = await shell(command);
if (result.stdout.length === 0) {
const result = await shell('sudo ip route show');
if (result.stdout.length > 0) {
return result.stdout;
}
if (result.stderr.length > 0) {
throw new Error(
`There was an error getting the default interface ${result.stdout}`
'There was an error getting the default interface:\n\n' + result.stderr
);
}
return result.stdout;
await delay(1000);
}

return result.stdout;
const result = await shell('sudo ip route show');
throw new Error(
`There was an error getting the default interface ${result.stdout}`
);
}

async function moduleProbe() {
Expand Down
Loading