LegacyDeploymentApi: Expire old stages that haven't got activated

For about an hour.

refs #13049
This commit is contained in:
Markus Frosch 2016-11-04 16:56:52 +01:00
parent a3d69c4f4c
commit f6a5c8cbc5
1 changed files with 22 additions and 1 deletions

View File

@ -81,8 +81,29 @@ class LegacyDeploymentApi implements DeploymentApiInterface
$moduleName = 'director';
$currentStage = $this->getActiveStageName();
// try to expire old deployments
foreach ($uncollected as $name => $deployment) {
/** @var DirectorDeploymentLog $deployment */
if (
$deployment->get('dump_succeeded') === 'n'
|| $deployment->get('startup_succeeded') === null
) {
$start_time = strtotime($deployment->start_time);
// older than an hour and no startup
if ($start_time + 3600 < time()) {
$deployment->set('startup_succeeded', 'n');
$deployment->set('startup_log', 'Activation timed out...');
$deployment->store();
}
}
}
foreach ($this->listModuleStages($moduleName) as $stage) {
if (array_key_exists($stage, $uncollected)) {
if (
array_key_exists($stage, $uncollected)
&& $uncollected[$stage]->get('startup_succeeded') === null
) {
continue;
}
elseif ($stage === $currentStage) {