[icinga-checkins] icinga.org: icingaweb2-module-director/next: LegacyDeploymentApi: Expire old stages that haven't got activated

git at icinga.org git at icinga.org
Fri Nov 4 16:56:54 CET 2016


Module: icingaweb2-module-director
Branch: next
Commit: f6a5c8cbc59953ce057c4c09dd8a52b344e0c7f4
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=f6a5c8cbc59953ce057c4c09dd8a52b344e0c7f4

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Fri Nov  4 16:56:52 2016 +0100

LegacyDeploymentApi: Expire old stages that haven't got activated

For about an hour.

refs #13049

---

 library/Director/Core/LegacyDeploymentApi.php |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/library/Director/Core/LegacyDeploymentApi.php b/library/Director/Core/LegacyDeploymentApi.php
index be44300..24dd072 100644
--- a/library/Director/Core/LegacyDeploymentApi.php
+++ b/library/Director/Core/LegacyDeploymentApi.php
@@ -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) {



More information about the icinga-checkins mailing list