From fcf7c1368c03feec604c195bee30c0d20a9fa9c2 Mon Sep 17 00:00:00 2001 From: Diego Rodriguez Baquero Date: Wed, 19 Jul 2023 14:24:17 -0500 Subject: [PATCH] Don't run speedtest if current one is valid --- .github/workflows/static-code-analysis.yml | 4 ---- container/shim/src/modules/registration.js | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml index b4b9c0bf..f0b90613 100644 --- a/.github/workflows/static-code-analysis.yml +++ b/.github/workflows/static-code-analysis.yml @@ -33,14 +33,10 @@ jobs: contents: read security-events: write - strategy: - fail-fast: true - steps: - name: Checkout repository uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: diff --git a/container/shim/src/modules/registration.js b/container/shim/src/modules/registration.js index 765e331d..f9269eb2 100644 --- a/container/shim/src/modules/registration.js +++ b/container/shim/src/modules/registration.js @@ -45,11 +45,12 @@ export async function register(initial = false) { verifyHWRequirements(requirements, stats); + let preregisterResponse; if (initial) { - await sendPreRegisterRequest(postOptions({ nodeId: NODE_ID })); + preregisterResponse = await sendPreRegisterRequest(postOptions({ nodeId: NODE_ID })); } - if (VERSION !== DEV_VERSION && initial) { + if (VERSION !== DEV_VERSION && initial && preregisterResponse?.speedtestRequired !== false) { let speedtest; try { speedtest = await getSpeedtest(); @@ -257,6 +258,8 @@ async function sendPreRegisterRequest(postOptions) { } debug("Successful pre-registration"); + + return await res.json(); } catch (err) { debug("Failed pre-registration: %s", err.message); // we don't try again if we fail the pre-registration