@@ -291,22 +291,24 @@ private function maybeConfigureBrancherServer(Server $server, bool $reuseBranche
291
291
$ data ['labels ' ] = $ labels ;
292
292
if ($ reuseBrancher && $ brancherApp = $ this ->brancherHypernodeManager ->reuseExistingBrancherHypernode ($ parentApp , $ labels )) {
293
293
$ this ->log ->info (sprintf ('Found existing brancher Hypernode, name is %s. ' , $ brancherApp ));
294
- $ server ->setHostname (sprintf ("%s.hypernode.io " , $ brancherApp ));
295
294
} else {
296
295
$ brancherApp = $ this ->brancherHypernodeManager ->createForHypernode ($ parentApp , $ data );
297
296
$ this ->log ->info (sprintf ('Successfully requested brancher Hypernode, name is %s. ' , $ brancherApp ));
298
- $ server ->setHostname (sprintf ("%s.hypernode.io " , $ brancherApp ));
299
297
$ this ->brancherHypernodesRegistered [] = $ brancherApp ;
298
+ }
300
299
301
- try {
302
- $ this ->log ->info ('Waiting for brancher Hypernode to become available... ' );
303
- $ this ->brancherHypernodeManager ->waitForAvailability ($ brancherApp );
304
- $ this ->log ->info ('Brancher Hypernode has become available! ' );
305
- } catch (CreateBrancherHypernodeFailedException | TimeoutException $ e ) {
300
+ try {
301
+ $ this ->log ->info ('Waiting for brancher Hypernode to become available... ' );
302
+ $ this ->brancherHypernodeManager ->waitForAvailability ($ brancherApp );
303
+ $ this ->log ->info ('Brancher Hypernode has become available! ' );
304
+ } catch (CreateBrancherHypernodeFailedException | TimeoutException $ e ) {
305
+ if (in_array ($ brancherApp , $ this ->brancherHypernodesRegistered )) {
306
306
$ this ->brancherHypernodeManager ->cancel ($ brancherApp );
307
- throw $ e ;
308
307
}
308
+
309
+ throw $ e ;
309
310
}
311
+ $ server ->setHostname (sprintf ("%s.hypernode.io " , $ brancherApp ));
310
312
}
311
313
}
312
314
0 commit comments