Chad has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/339032 )

Change subject: clean.py: Rework command execution, reduce code dupe
......................................................................

clean.py: Rework command execution, reduce code dupe

Change-Id: I4cd7ae94ea14292ae72e859c8dbc6c3d8f096519
---
M scap/plugins/clean.py
1 file changed, 17 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/32/339032/1

diff --git a/scap/plugins/clean.py b/scap/plugins/clean.py
index 447f9a7..ed49e9c 100644
--- a/scap/plugins/clean.py
+++ b/scap/plugins/clean.py
@@ -18,31 +18,29 @@
         """ Clean old branches from the cluster for space savings! """
 
         # Update masters
-        with log.Timer('clean-masters', self.get_stats()):
-            clean_job = ssh.Job(self._get_master_list(),
-                                user=self.config['ssh_user'])
-            clean_job.exclude_hosts([socket.getfqdn()])
-            clean_job.shuffle()
-            clean_job.command(self.clean_command(self.config['stage_dir']))
-            clean_job.progress(log.reporter('clean-masters',
-                               self.config['fancy_progress']))
-            succeeded, failed = clean_job.run()
-            if failed:
-                self.get_logger().warning(
-                    '%d masters had clean errors', failed)
+        self.do_stuff(
+            'clean-masters',
+            self._get_master_list(),
+            self.clean_command(self.config['stage_dir'])
+        )
 
         # Update apaches
-        with log.Timer('clean-apaches', self.get_stats()):
-            clean_job = ssh.Job(self._get_target_list(),
-                                user=self.config['ssh_user'])
+        self.do_stuff(
+            'clean-apaches',
+            self._get_target_list(),
+            self.clean_command(self.config['deploy_dir'])
+        )
+
+    def do_stuff(self, description, targets, command):
+        with log.Timer(description, self.get_stats()):
+            clean_job = ssh.Job(targets, user=self.config['ssh_user'])
             clean_job.shuffle()
-            clean_job.command(self.clean_command(self.config['deploy_dir']))
-            clean_job.progress(log.reporter('clean-apaches',
+            clean_job.command(command)
+            clean_job.progress(log.reporter(description,
                                self.config['fancy_progress']))
             succeeded, failed = clean_job.run()
             if failed:
-                self.get_logger().warning(
-                    '%d apaches had clean errors', failed)
+                self.get_logger().warning('%d had clean errors', failed)
 
     def clean_command(self, location):
         path = os.path.join(location, 'php-%s' % self.arguments.branch)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4cd7ae94ea14292ae72e859c8dbc6c3d8f096519
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>

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

Reply via email to