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