From eab093c3156d0503597663458430576f97194a01 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Tue, 3 Jan 2023 10:16:22 +0100 Subject: [PATCH] Cleanup: Log about Hypernode and labels used for cleanup --- ci/test/run-brancher.sh | 1 + src/Command/Cleanup.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ci/test/run-brancher.sh b/ci/test/run-brancher.sh index 8fa5814..d25dc06 100755 --- a/ci/test/run-brancher.sh +++ b/ci/test/run-brancher.sh @@ -79,4 +79,5 @@ $DP rm -f deployment-report.json $DP hypernode-deploy cleanup test -vvv | tee cleanup.log # Run tests on cleanup +grep -F "Cleaning up Brancher instances based on Hypernode hndeployintegr8 with labels [gitref=${GITHUB_SHA:-unknown}]" cleanup.log grep "Stopping brancher Hypernode ${BRANCHER_INSTANCE}..." cleanup.log diff --git a/src/Command/Cleanup.php b/src/Command/Cleanup.php index 6232b15..946f39c 100644 --- a/src/Command/Cleanup.php +++ b/src/Command/Cleanup.php @@ -11,6 +11,7 @@ use Hypernode\DeployConfiguration\BrancherServer; use Hypernode\DeployConfiguration\Configuration; use Hypernode\DeployConfiguration\Server; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -23,12 +24,14 @@ class Cleanup extends Command private DeployerLoader $deployerLoader; private ConfigurationLoader $configurationLoader; private BrancherHypernodeManager $brancherHypernodeManager; + private LoggerInterface $logger; public function __construct( ReportLoader $reportLoader, DeployerLoader $deployerLoader, ConfigurationLoader $configurationLoader, - BrancherHypernodeManager $brancherHypernodeManager + BrancherHypernodeManager $brancherHypernodeManager, + LoggerInterface $logger ) { parent::__construct(); @@ -36,6 +39,7 @@ public function __construct( $this->deployerLoader = $deployerLoader; $this->configurationLoader = $configurationLoader; $this->brancherHypernodeManager = $brancherHypernodeManager; + $this->logger = $logger; } protected function configure() @@ -89,6 +93,13 @@ private function cancelByStage(string $stageName, Configuration $config): void } $labels = $server->getLabels(); $hypernode = $server->getOptions()[Server::OPTION_HN_PARENT_APP]; + $this->logger->debug( + sprintf( + 'Cleaning up Brancher instances based on Hypernode %s with labels [%s]', + $hypernode, + implode(', ', $labels), + ) + ); $brancherHypernodes = $this->brancherHypernodeManager->queryBrancherHypernodes( $hypernode, $labels