Andrew Bogott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/102155


Change subject: Check the puppetstatus timestamp.
......................................................................

Check the puppetstatus timestamp.

Previously we might have been reporting 'ok' from days ago.

Change-Id: I7b4f09a6a07cc58cd2a141cf071bcdc37872f0fe
---
M OpenStackManager.php
M nova/OpenStackNovaInstance.php
2 files changed, 14 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenStackManager 
refs/changes/55/102155/1

diff --git a/OpenStackManager.php b/OpenStackManager.php
index a7e174d..1797e38 100644
--- a/OpenStackManager.php
+++ b/OpenStackManager.php
@@ -137,6 +137,10 @@
 // Custom namespace for projects
 $wgOpenStackManagerProjectNamespace = NS_NOVA_RESOURCE;
 
+// Puppetstatus interval in minutes.  After this much time puppet status
+// will be deemed stale
+$wgPuppetInterval = 120;
+
 $dir = dirname( __FILE__ ) . '/';
 
 $wgExtensionMessagesFiles['OpenStackManager'] = $dir . 
'OpenStackManager.i18n.php';
diff --git a/nova/OpenStackNovaInstance.php b/nova/OpenStackNovaInstance.php
index 603ecbf..ed68054 100644
--- a/nova/OpenStackNovaInstance.php
+++ b/nova/OpenStackNovaInstance.php
@@ -132,11 +132,21 @@
        }
 
        function getPuppetStatus() {
+               global $wgPuppetInterval;
+
                $metadata = OpenStackNovaController::_get_property( 
$this->instance, 'metadata' );
                if ( ! property_exists( $metadata, 'puppetstatus' ) ) {
                        return 'unknown';
                }
+               if ( ! property_exists( $metadata, 'puppettimestamp' ) ) {
+                       return 'unknown';
+               }
                $status = $metadata->puppetstatus;
+               $timestamp = $metadata->puppetstatus;
+               $elapsed = ( time() - $timestamp ) / 60;
+               if ( $elapsed > $wgPuppetInterval ) {
+                       return 'stale';
+               }
                if ( $status == 'changed' ) {
                        return 'ok';
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/102155
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b4f09a6a07cc58cd2a141cf071bcdc37872f0fe
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Andrew Bogott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to