Skip to content

Add configurable timeout for brancher creation #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ docker build -t "$DOCKER_TAG" -f "./ci/build/Dockerfile" \
```

This will give you a locally built image:
```console
$ docker images | grep hypernode_deploy_dev
```bash
docker images | grep hypernode_deploy_dev
localhost/hypernode_deploy_dev latest 5280aaef3a82 52 seconds ago 842 MB
```

For a Magento application, make sure you git clone a fresh version or remove <code>app/etc/env.php</code> first.

That you could then use like:
```console
$ rm -Rf vendor
$ docker run --rm -it --env SSH_PRIVATE_KEY="$(cat ~/.ssh/yourdeploykey | base64)" -v ${PWD}:/build hypernode_deploy_dev:latest hypernode-deploy build -vvv
$ docker run --rm -it --env SSH_PRIVATE_KEY="$(cat ~/.ssh/yourdeploykey | base64)" -v ${PWD}:/build hypernode_deploy_dev:latest hypernode-deploy deploy staging -vvv
```bash
rm -Rf vendor
docker run --rm -it --env SSH_PRIVATE_KEY="$(cat ~/.ssh/yourdeploykey | base64)" -v ${PWD}:/build hypernode_deploy_dev:latest hypernode-deploy build -vvv
docker run --rm -it --env SSH_PRIVATE_KEY="$(cat ~/.ssh/yourdeploykey | base64)" -v ${PWD}:/build hypernode_deploy_dev:latest hypernode-deploy deploy staging -vvv
```
FYI: If you deploy to a brancher node you probably need the HYPERNODE_API_TOKEN environment variable. Get it from the parent server, located at <code>/etc/hypernode/hypernode_api_token</code>.

## Tests

Expand All @@ -61,3 +64,12 @@ To run the static tests, please run the following commands:
composer --working-dir tools install
tools/vendor/bin/grumphp run --config tools/grumphp.yml
```

## Configurable Brancher options

### Brancher timeout
The default timeout for Brancher creation is 1500 seconds. To change this, add the following in your <code>deploy.php</code>:
```php
$brancherStage = $configuration->addStage('stage_name', 'host');
$brancherStage->addBrancherServer('parent_to_base_brancher_on', [], ['hn_brancher_timeout' => 2700])
```
7 changes: 5 additions & 2 deletions src/DeployRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DeployRunner
{
public const TASK_BUILD = 'build';
public const TASK_DEPLOY = 'deploy';
public const OPTION_HN_BRANCHER_TIMEOUT = 'hn_brancher_timeout';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would optimally go to the hypernode-deploy-configuration so that it becomes available for autocomplete in IDEs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps an environment variable would be more fitting?


private TaskFactory $taskFactory;
private InputInterface $input;
Expand Down Expand Up @@ -275,7 +276,7 @@ private function maybeConfigureBrancherServer(Server $server, bool $reuseBranche
$settings = $serverOptions[Server::OPTION_HN_BRANCHER_SETTINGS] ?? [];
$labels = $serverOptions[Server::OPTION_HN_BRANCHER_LABELS] ?? [];

$this->log->info(sprintf('Creating an brancher Hypernode based on %s.', $parentApp));
$this->log->info(sprintf('Creating a brancher Hypernode based on %s.', $parentApp));
if ($settings) {
$this->log->info(
sprintf('Settings to be applied: [%s].', implode(', ', $settings))
Expand All @@ -299,7 +300,9 @@ private function maybeConfigureBrancherServer(Server $server, bool $reuseBranche

try {
$this->log->info('Waiting for brancher Hypernode to become available...');
$this->brancherHypernodeManager->waitForAvailability($brancherApp);
$timeout = $serverOptions[self::OPTION_HN_BRANCHER_TIMEOUT] ?? 1500;
$this->log->info(sprintf('Timeout for brancher creation is set at %d seconds.', $timeout));
$this->brancherHypernodeManager->waitForAvailability($brancherApp, $timeout);
$this->log->info('Brancher Hypernode has become available!');
} catch (CreateBrancherHypernodeFailedException | TimeoutException $e) {
if (in_array($brancherApp, $this->brancherHypernodesRegistered)) {
Expand Down