-
Notifications
You must be signed in to change notification settings - Fork 8
Cleanup Brancher nodes by labels #66
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you're changing some of the configuration loading. Is that necessary for specifying extra input for labels?
/** @var string $stageName */ | ||
$stageName = $input->getArgument('stage'); | ||
if ($stageName) { | ||
$config = $this->configurationLoader->load( | ||
$input->getOption('file') ?: 'deploy.php' | ||
); | ||
foreach ($config->getStages() as $stage) { | ||
if ($stage->getName() !== $stageName) { | ||
continue; | ||
} | ||
foreach ($stage->getServers() as $server) { | ||
if (!($server instanceof BrancherServer)) { | ||
continue; | ||
} | ||
$labels = $server->getLabels(); | ||
$hypernode = $server->getOptions()[Server::OPTION_HN_PARENT_APP]; | ||
$brancherHypernodes = $this->brancherHypernodeManager->queryBrancherHypernodes( | ||
$hypernode, | ||
$labels | ||
); | ||
$this->brancherHypernodeManager->cancel(...$brancherHypernodes); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could refactor it in a method cancelBasedOnLabel
or something to keep this method concise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion! Will do
The configuration loading was moved into a separate class and I also removed the |
0b837b4
to
37f6d78
Compare
Depends on and needs to be merged after #65.
This allows brancher nodes to be cleaned up by labels. Hypernode Deploy will look up existing brancher nodes using the API, match them with the labels of the given stage and delete them.
This is an explicit feature, so it is necessary to call
hypernode-deploy cleanup <target>
on a specific point of the pipeline configuration (for example after a PR is closed).