Giuseppe Lavagetto has submitted this change and it was merged.

Change subject: varnish: make varnish::instance not depend on ganglia
......................................................................


varnish: make varnish::instance not depend on ganglia

We may have situations where we don't have either ganglia or gmond, so
we don't want to have varnish::instance depend on it; also, the new
syntax using the spaceship operator and tags should be easier to read
and maintain. This is a prerequisite to fix bug #73263

Change-Id: I6ebf100e64cb432bb073831131c6be62dfac5695
Signed-off-by: Giuseppe Lavagetto <[email protected]>
---
A modules/varnish/files/ganglia/check-gmond-restart
M modules/varnish/manifests/instance.pp
M modules/varnish/manifests/monitoring/ganglia.pp
3 files changed, 34 insertions(+), 10 deletions(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/varnish/files/ganglia/check-gmond-restart 
b/modules/varnish/files/ganglia/check-gmond-restart
new file mode 100755
index 0000000..212ea89
--- /dev/null
+++ b/modules/varnish/files/ganglia/check-gmond-restart
@@ -0,0 +1,16 @@
+#!/bin/bash -e
+
+for pidfile in /var/run/varnishd*.pid;
+do
+    PID=$(cat ${pidfile})
+    test -z ${PID} && continue
+    ACTUAL_PID=$(lsof -F p ${pidfile} | sed 's/^p//' -)
+    test -z ${ACTUAL_PID} && continue
+    if [ ${ACTUAL_PID} -ne ${PID} ]; then
+        continue
+    fi;
+    if [ ${pidfile} -nt /var/run/gmond.pid ]; then
+        /usr/sbin/service ganglia-monitor restart
+        break
+    fi
+done
diff --git a/modules/varnish/manifests/instance.pp 
b/modules/varnish/manifests/instance.pp
index d58b719..1193ddd 100644
--- a/modules/varnish/manifests/instance.pp
+++ b/modules/varnish/manifests/instance.pp
@@ -86,7 +86,7 @@
         hasstatus => false,
         pattern   => "/var/run/varnishd${instancesuffix}.pid",
         subscribe => Package['varnish'],
-        before    => Exec['generate varnish.pyconf'],
+        tag       => 'varnish_instance'
     }
 
     # This mechanism with the touch/rm conditionals in the pair of execs
@@ -120,14 +120,5 @@
     monitor_service { "varnish http ${title}":
         description   => "Varnish HTTP ${title}",
         check_command => "check_http_generic!varnishcheck!${port}"
-    }
-
-    # Restart gmond if this varnish instance has been (re)started later
-    # than gmond was started
-    exec { "restart gmond for varnish${instancesuffix}":
-        path    => '/bin:/usr/bin',
-        command => 'true',
-        onlyif  => "test /var/run/varnishd${instancesuffix}.pid -nt 
/var/run/gmond.pid",
-        notify  => Service['gmond'],
     }
 }
diff --git a/modules/varnish/manifests/monitoring/ganglia.pp 
b/modules/varnish/manifests/monitoring/ganglia.pp
index f634b9e..be07a6c 100644
--- a/modules/varnish/manifests/monitoring/ganglia.pp
+++ b/modules/varnish/manifests/monitoring/ganglia.pp
@@ -25,5 +25,22 @@
         notify  => Service['gmond'],
     }
 
+    file { '/usr/local/sbin/check-gmond-restart':
+        ensure => present,
+        source => 'puppet:///modules/varnish/ganglia/check-gmond-restart',
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0544',
+    }
+
+    file { '/etc/cron.d/check-gmond-restart':
+        ensure  => present,
+        content => "*/5 * * * * root /usr/local/sbin/check-gmond-restart > 
/dev/null 2>&1\n",
+        require => File['/usr/local/sbin/check-gmond-restart'],
+    }
+
+    # Dependencies
+    # Exec the config generation AFTER all varnish instances have started
+    Service <| tag == 'varnish_instance' |> -> Exec['generate varnish.pyconf']
     Exec['generate varnish.pyconf'] -> Exec['replace varnish.pyconf']
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6ebf100e64cb432bb073831131c6be62dfac5695
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to