jenkins-bot has submitted this change and it was merged.

Change subject: Add an hhvm-graceful-all command
......................................................................


Add an hhvm-graceful-all command

Add a new command that can be used to perform a rolling restart of HHVM
across the cluster.

Bug: T103886
Change-Id: Ic937aea94c5c5eea1a24df1d253f6e448cd99c65
---
A bin/hhvm-graceful-all
M scap/__init__.py
M scap/main.py
3 files changed, 52 insertions(+), 1 deletion(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/bin/hhvm-graceful-all b/bin/hhvm-graceful-all
new file mode 100755
index 0000000..8cafdb9
--- /dev/null
+++ b/bin/hhvm-graceful-all
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Restart HHVM across the entire cluster
+#
+# Copyright © 2015 Wikimedia Foundation and contributors
+
+import os
+import sys
+
+# Add scap package to search path
+script = os.path.realpath(sys.argv[0])
+scap_src = os.path.dirname(os.path.dirname(script))
+sys.path.append(scap_src)
+
+import scap
+scap.HHVMGracefulAll.run()
diff --git a/scap/__init__.py b/scap/__init__.py
index d628c73..84af164 100644
--- a/scap/__init__.py
+++ b/scap/__init__.py
@@ -8,6 +8,7 @@
 """
 from .main import (
     CompileWikiversions,
+    HHVMGracefulAll,
     MWVersionsInUse,
     PurgeL10nCache,
     RebuildCdbs,
@@ -24,6 +25,7 @@
 
 __all__ = (
     'CompileWikiversions',
+    'HHVMGracefulAll',
     'MWVersionsInUse',
     'PurgeL10nCache',
     'RebuildCdbs',
@@ -40,6 +42,7 @@
 
 any((
     CompileWikiversions,
+    HHVMGracefulAll,
     MWVersionsInUse,
     PurgeL10nCache,
     RebuildCdbs,
diff --git a/scap/main.py b/scap/main.py
index f36c4bf..b4f4c9e 100644
--- a/scap/main.py
+++ b/scap/main.py
@@ -263,6 +263,7 @@
                 self.get_logger().warning(
                     '%d hosts failed to restart HHVM', failed)
                 self.soft_errors = True
+            self.get_stats().increment('deploy.restart')
 
     def _after_lock_release(self):
         self.announce('Finished scap: %s (duration: %s)',
@@ -473,7 +474,7 @@
 
 
 class RestartHHVM(cli.Application):
-    """Restart the HHVM fcgi process
+    """Restart the HHVM fcgi process on the local server
 
     #. Depool the server if registered with pybal
     #. Wait for pending requests to complete
@@ -524,3 +525,33 @@
                 '/usr/sbin/service apache2 start', self.get_logger())
 
         return 0
+
+
+class HHVMGracefulAll(cli.Application):
+    """Perform a rolling restart of HHVM across the cluster."""
+
+    def _process_arguments(self, args, extra_args):
+        if hasattr(args, 'message'):
+            args.message = ' '.join(args.message) or '(no message)'
+        return args, extra_args
+
+    @cli.argument('message', nargs='*', help='Log message for SAL')
+    def main(self, *extra_args):
+        exit_code = 0
+        self.announce('Restarting HHVM: %s', self.arguments.message)
+
+        target_hosts = utils.read_dsh_hosts_file(self.config['dsh_targets'])
+        succeeded, failed = tasks.restart_hhvm(
+            target_hosts, self.config,
+            # Use a batch size of 5% of the total target list
+            len(target_hosts) // 20)
+        if failed:
+            self.get_logger().warning(
+                '%d hosts failed to restart HHVM', failed)
+            exit_code = 1
+
+        self.announce('Finished HHVM restart: %s (duration: %s)',
+            self.arguments.message, utils.human_duration(self.get_duration()))
+        self.get_stats().increment('deploy.restart')
+
+        return exit_code

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic937aea94c5c5eea1a24df1d253f6e448cd99c65
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/tools/scap
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: 20after4 <mmod...@wikimedia.org>
Gerrit-Reviewer: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: Thcipriani <tcipri...@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