Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/Brancher/BrancherHypernodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public function waitForAvailability(string $brancherHypernode, int $timeout = 15
try {
$flows = $this->hypernodeClient->logbook->getList($brancherHypernode);
$relevantFlows = array_filter($flows, fn(Flow $flow) => $flow->name === 'ensure_app');
$failedFlows = array_filter($flows, fn(Flow $flow) => $flow->isReverted());
$completedFlows = array_filter($flows, fn(Flow $flow) => $flow->isComplete());
$failedFlows = array_filter($relevantFlows, fn(Flow $flow) => $flow->isReverted());
$completedFlows = array_filter($relevantFlows, fn(Flow $flow) => $flow->isComplete());

if (count($failedFlows) === count($relevantFlows)) {
throw new CreateBrancherHypernodeFailedException();
Expand Down
18 changes: 10 additions & 8 deletions src/DeployRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,24 @@ private function maybeConfigureBrancherServer(Server $server, bool $reuseBranche
$data['labels'] = $labels;
if ($reuseBrancher && $brancherApp = $this->brancherHypernodeManager->reuseExistingBrancherHypernode($parentApp, $labels)) {
$this->log->info(sprintf('Found existing brancher Hypernode, name is %s.', $brancherApp));
$server->setHostname(sprintf("%s.hypernode.io", $brancherApp));
} else {
$brancherApp = $this->brancherHypernodeManager->createForHypernode($parentApp, $data);
$this->log->info(sprintf('Successfully requested brancher Hypernode, name is %s.', $brancherApp));
$server->setHostname(sprintf("%s.hypernode.io", $brancherApp));
$this->brancherHypernodesRegistered[] = $brancherApp;
}

try {
$this->log->info('Waiting for brancher Hypernode to become available...');
$this->brancherHypernodeManager->waitForAvailability($brancherApp);
$this->log->info('Brancher Hypernode has become available!');
} catch (CreateBrancherHypernodeFailedException | TimeoutException $e) {
try {
$this->log->info('Waiting for brancher Hypernode to become available...');
$this->brancherHypernodeManager->waitForAvailability($brancherApp);
$this->log->info('Brancher Hypernode has become available!');
} catch (CreateBrancherHypernodeFailedException | TimeoutException $e) {
if (in_array($brancherApp, $this->brancherHypernodesRegistered)) {
$this->brancherHypernodeManager->cancel($brancherApp);
throw $e;
}

throw $e;
}
$server->setHostname(sprintf("%s.hypernode.io", $brancherApp));
}
}

Expand Down
Loading