From 225af9233eeb3cbe1ff2408edd27f82f754f267a Mon Sep 17 00:00:00 2001 From: Alexander Grooff Date: Mon, 19 Sep 2022 17:52:32 +0200 Subject: [PATCH 1/2] feat: allow for errors in initial window The API call to fetch playbooks tends to crap out in the beginning, so this initial window of allowing commits is to give it some room. --- src/Ephemeral/EphemeralHypernodeManager.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Ephemeral/EphemeralHypernodeManager.php b/src/Ephemeral/EphemeralHypernodeManager.php index 2767d53..f466d10 100644 --- a/src/Ephemeral/EphemeralHypernodeManager.php +++ b/src/Ephemeral/EphemeralHypernodeManager.php @@ -51,6 +51,8 @@ public function waitForAvailability(string $ephemeralHypernode, int $timeout = 9 $latest = microtime(true); $timeElapsed = 0; $resolved = false; + $interval = 3; + $allowedErrorWindow = 3; while ($timeElapsed < $timeout && !$resolved) { $now = microtime(true); @@ -76,10 +78,19 @@ public function waitForAvailability(string $ephemeralHypernode, int $timeout = 9 // Otherwise, there's an error, and it should be propagated. if ($e->getCode() !== 404) { throw $e; + } elseif ($timeElapsed < $allowedErrorWindow) { + // Some times we get an error where the logbook is not yet available, but it will be soon. + // We allow a small window for this to happen, and then we throw an exception. + sprintf( + 'Got an excepted exception during the allowed error window of HTTP code %d, waiting for %s to become available', + $e->getCode(), + $ephemeralHypernode + ); + continue; } } - sleep(5); + sleep($interval); } if (!$resolved) { From 5a9e5903725c025ab3cd2dfdc6f9579e06ced3f5 Mon Sep 17 00:00:00 2001 From: Alexander Grooff Date: Tue, 20 Sep 2022 10:08:10 +0200 Subject: [PATCH 2/2] typo: excepted -> expected --- src/Ephemeral/EphemeralHypernodeManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Ephemeral/EphemeralHypernodeManager.php b/src/Ephemeral/EphemeralHypernodeManager.php index f466d10..7690f53 100644 --- a/src/Ephemeral/EphemeralHypernodeManager.php +++ b/src/Ephemeral/EphemeralHypernodeManager.php @@ -79,10 +79,10 @@ public function waitForAvailability(string $ephemeralHypernode, int $timeout = 9 if ($e->getCode() !== 404) { throw $e; } elseif ($timeElapsed < $allowedErrorWindow) { - // Some times we get an error where the logbook is not yet available, but it will be soon. + // Sometimes we get an error where the logbook is not yet available, but it will be soon. // We allow a small window for this to happen, and then we throw an exception. sprintf( - 'Got an excepted exception during the allowed error window of HTTP code %d, waiting for %s to become available', + 'Got an expected exception during the allowed error window of HTTP code %d, waiting for %s to become available', $e->getCode(), $ephemeralHypernode );