Andrew Bogott has submitted this change and it was merged.
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(-)
Approvals:
Andrew Bogott: Verified; Looks good to me, approved
diff --git a/OpenStackManager.php b/OpenStackManager.php
index a7e174d..69955b3 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 = 1440;
+
$dir = dirname( __FILE__ ) . '/';
$wgExtensionMessagesFiles['OpenStackManager'] = $dir .
'OpenStackManager.i18n.php';
diff --git a/nova/OpenStackNovaInstance.php b/nova/OpenStackNovaInstance.php
index 603ecbf..44d5325 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->puppettimestamp;
+ $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: merged
Gerrit-Change-Id: I7b4f09a6a07cc58cd2a141cf071bcdc37872f0fe
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/OpenStackManager
Gerrit-Branch: master
Gerrit-Owner: Andrew Bogott <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits