Madhuvishy has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/334433 )

Change subject: toolschecker: Split each check into a separate uwsgi application
......................................................................


toolschecker: Split each check into a separate uwsgi application

Change-Id: I4095763b46b38b3c4e3900cd1b9fcbea43713f9f
---
A modules/toollabs/manifests/check.pp
M modules/toollabs/manifests/checker.pp
M modules/toollabs/templates/toolschecker.nginx.erb
M modules/toollabs/templates/toolschecker.upstart.erb
4 files changed, 126 insertions(+), 19 deletions(-)

Approvals:
  Madhuvishy: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/toollabs/manifests/check.pp 
b/modules/toollabs/manifests/check.pp
new file mode 100644
index 0000000..73d7476
--- /dev/null
+++ b/modules/toollabs/manifests/check.pp
@@ -0,0 +1,29 @@
+define toollabs::check (
+    $path,
+) {
+
+    $check_name = $title
+
+    # cheap way to ensure uniqueness across resources
+    toollabs::check::path {$path: }
+
+    file { "/etc/init/toolschecker/toolschecker_${check_name}.conf":
+        ensure  => present,
+        content => template('toollabs/toolschecker.upstart.erb'),
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0644',
+        require => File['etc/init/toolschecker'],
+        notify  => Service["toolschecker_${check_name}"],
+    }
+
+    service { "toolschecker_${check_name}":
+        ensure  => running,
+    }
+}
+
+# lint:ignore:autoloader_layout
+define toollabs::check::path {
+}
+
+# lint:endignore
diff --git a/modules/toollabs/manifests/checker.pp 
b/modules/toollabs/manifests/checker.pp
index c9125bd..25bd1e9 100644
--- a/modules/toollabs/manifests/checker.pp
+++ b/modules/toollabs/manifests/checker.pp
@@ -55,6 +55,13 @@
         mode   => '0755',
     }
 
+    file { '/etc/init/toolschecker':
+        ensure => directory,
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0644',
+    }
+
     # We need this host's puppet cert and key (readable) so we can check
     #  puppet status
     file { '/var/lib/toolschecker/puppetcerts/cert.pem':
@@ -73,15 +80,6 @@
         source => "/var/lib/puppet/ssl/private_keys/${::fqdn}.pem",
     }
 
-    file { '/etc/init/toolschecker.conf':
-        ensure  => present,
-        content => template('toollabs/toolschecker.upstart.erb'),
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0644',
-        notify  => Service['toolschecker'],
-    }
-
     sudo::user { 'tools.toolschecker':
         privileges => [
             'ALL=(tools.toolschecker-k8s-ws) NOPASSWD: ALL',
@@ -89,14 +87,91 @@
         ],
     }
 
-    service { 'toolschecker':
-        ensure  => running,
-        require => File['/run/toolschecker'],
+    $checks = {
+        'self'                   => {
+            path                 => '/self'
+        },
+        'puppet_catalog'         => {
+            path                 => '/labs-puppetmaster/eqiad',
+        },
+        'labs_private'           => {
+            path                 => '/labs-dns/private',
+        },
+        'nfs_showmount'          => {
+            path                 => '/nfs/showmount',
+        },
+        'ldap'                   => {
+            path                 => '/ldap',
+        },
+        'nfs_home'               => {
+            path                 => '/nfs/home',
+        },
+        'redis'                  => {
+            path                 => '/redis',
+        },
+        'labsdb_labsdb1001'      => {
+            path                 => '/labsdb/labsdb1001',
+        },
+        'labsdb_labsdb1003'      => {
+            path                 => '/labsdb/labsdb1003',
+        },
+        'labsdb_labsdb1005'      => {
+            path                 => '/labsdb/labsdb1005',
+        },
+        'labsdb_labsdb1001rw'    => {
+            path                 => '/labsdb/labsdb1001rw',
+        },
+        'labsdb_labsdb1003rw'    => {
+            path                 => '/labsdb/labsdb1003rw',
+        },
+        'labsdb_labsdb1004rw'    => {
+            path                 => '/labsdb/labsdb1004rw',
+        },
+        'toolsdb'                => {
+            path                 => '/toolsdb',
+        },
+        'dumps'                  => {
+            path                 => '/dumps',
+        },
+        'continuous_job_trusty'  => {
+            path                 => '/continuous/trusty',
+        },
+        'continuous_job_precise' => {
+            path                 => '/continuous/precise',
+        },
+        'grid_start_trusty'      => {
+            path                 => '/grid/start/trusty',
+        },
+        'grid_start_precise'     => {
+            path                 => '/grid/start/precise',
+        },
+        'cron'                   => {
+            path                 => '/toolscron',
+        },
+        'flannel_etcd'           => {
+            path                 => '/etcd/flannel',
+        },
+        'kubernetes_etcd'        => {
+            path                 => '/k8s/flannel',
+        },
+        'kubernetes_nodes_ready' => {
+            path                 => '/k8s/nodes/ready',
+        },
+        'webservice_kubernetes'  => {
+            path                 => '/webservice/kubernetes',
+        },
+        'service_start'          => {
+            path                 => '/service/start',
+        },
     }
 
+    create_resources(toollabs::check, $checks)
 
     nginx::site { 'toolschecker-nginx':
         require => Service['toolschecker'],
         content => template('toollabs/toolschecker.nginx.erb'),
     }
+
+    File['/run/toolschecker'] -> Toollabs::Check[keys($checks)] -> 
Nginx::Site['toolschecker-nginx']
+
 }
diff --git a/modules/toollabs/templates/toolschecker.nginx.erb 
b/modules/toollabs/templates/toolschecker.nginx.erb
index 3f49c76..ba8eb3f 100644
--- a/modules/toollabs/templates/toolschecker.nginx.erb
+++ b/modules/toollabs/templates/toolschecker.nginx.erb
@@ -1,12 +1,15 @@
-upstream toolschecker {
-    server unix:/run/toolschecker/toolschecker.sock;
+<% @checks.each_key do |check_name| %>
+upstream toolschecker_<%= check_name %> {
+    server unix:/run/toolschecker/toolschecker_<%= check_name %>.sock;
 }
+<% end %>
 
 server {
     listen 80;
-
-    location / {
+    <% @checks.each_pair do |check_name, value| %>
+    location <%= value['path'] %> {
         include uwsgi_params;
-        uwsgi_pass toolschecker;
+        uwsgi_pass toolschecker_<%= check_name %>;
     }
+    <% end %>
 }
diff --git a/modules/toollabs/templates/toolschecker.upstart.erb 
b/modules/toollabs/templates/toolschecker.upstart.erb
index 0893032..0e13fed 100644
--- a/modules/toollabs/templates/toolschecker.upstart.erb
+++ b/modules/toollabs/templates/toolschecker.upstart.erb
@@ -1,5 +1,5 @@
 # This file is managed by Puppet
-description "toolchecker UWSGI application"
+description "toolchecker UWSGI application - check <%= @check_name %>"
 
 start on (filesystem and net-device-up IFACE!=lo)
 stop on runlevel [!2345]
@@ -17,7 +17,7 @@
                     --harakiri-verbose \
                     
--wsgi-file=/usr/local/lib/python2.7/dist-packages/toolschecker.py \
                     --callable=app \
-                    --socket=/run/toolschecker/toolschecker.sock \
+                    --socket=/run/toolschecker/toolschecker_<%= @check_name 
%>.sock \
                     --chmod-socket=664 \
                     --die-on-term
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4095763b46b38b3c4e3900cd1b9fcbea43713f9f
Gerrit-PatchSet: 7
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Madhuvishy <mviswanat...@wikimedia.org>
Gerrit-Reviewer: Madhuvishy <mviswanat...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to