Skip to content

Commit c3e76e2

Browse files
Copilottdgroot
andcommitted
Address code review nitpicks
- Remove unnecessary empty line in checkSshReachability loop - Add REUSED_SSH_CHECK_TIMEOUT_RATIO constant for timeout allocation Co-authored-by: tdgroot <1165302+tdgroot@users.noreply.github.com>
1 parent 447b1d9 commit c3e76e2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/Brancher/BrancherHypernodeManager.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
class BrancherHypernodeManager
1616
{
17+
/**
18+
* Ratio of timeout to allocate for initial SSH check when reusing a Brancher.
19+
* The remaining time is reserved for logbook flow checks if SSH fails.
20+
*/
21+
private const REUSED_SSH_CHECK_TIMEOUT_RATIO = 0.5;
22+
1723
private LoggerInterface $log;
1824
private HypernodeClient $hypernodeClient;
1925

@@ -121,7 +127,6 @@ private function checkSshReachability(
121127
$consecutiveSuccesses = 0;
122128

123129
while ((microtime(true) - $startTime) < $timeout) {
124-
125130
$connection = @fsockopen(sprintf("%s.hypernode.io", $brancherHypernode), 22);
126131
if ($connection) {
127132
fclose($connection);
@@ -234,8 +239,8 @@ private function waitForAvailabilityInternal(
234239
)
235240
);
236241

237-
// Allocate 50% of timeout for initial SSH check to leave time for fallback
238-
$sshCheckTimeout = (int) ($timeout * 0.5);
242+
// Allocate a portion of timeout for initial SSH check to leave time for fallback
243+
$sshCheckTimeout = (int) ($timeout * self::REUSED_SSH_CHECK_TIMEOUT_RATIO);
239244
$sshCheckStartTime = microtime(true);
240245

241246
if ($this->checkSshReachability($brancherHypernode, $sshCheckTimeout, $reachabilityCheckCount, $reachabilityCheckInterval)) {

0 commit comments

Comments
 (0)