commit 83398de5e1172b60c285c6c8ef1c522a49fc0544
Author: Pete Zaitcev <zaitcev@kotori.zaitcev.us>
Date:   Tue Apr 26 13:21:24 2016 -0600

    Destroy gurumed
    
    Sick of maintaining it.
    
    Change-Id: Ie043f5042a60e8f6a393babdc0ae598e7068a22c

diff --git a/etc/object-server.conf-sample b/etc/object-server.conf-sample
index e2bce54..e01193b 100644
--- a/etc/object-server.conf-sample
+++ b/etc/object-server.conf-sample
@@ -149,12 +149,6 @@ use = egg:swift#object
 # logs at startup, but your object servers should continue to function.
 #
 # splice = no
-#
-# Location of so-called "Guru Meditation" dump files, must be writeable
-# by swift to be useable. This is invoked with "swift-init xxxxx dump",
-# which is not supposed to be automated, and thus is not cleaned up
-# by log rotations.
-# gurumed_dir = /var/lib/swift/dump
 
 [filter:healthcheck]
 use = egg:swift#healthcheck
@@ -221,8 +215,6 @@ use = egg:swift#recon
 # ring_check_interval = 15
 # recon_cache_path = /var/cache/swift
 #
-# gurumed_dir = /var/lib/swift/dump
-#
 # limits how long rsync error log lines are
 # 0 means to log the entire line
 # rsync_error_log_line_length = 0
@@ -288,7 +280,6 @@ use = egg:swift#recon
 # slowdown = 0.01
 #
 # recon_cache_path = /var/cache/swift
-# gurumed_dir = /var/lib/swift/dump
 
 [object-auditor]
 # You can override the default log routing for this app here (don't use set!):
@@ -309,7 +300,6 @@ use = egg:swift#recon
 # log_time = 3600
 # zero_byte_files_per_second = 50
 # recon_cache_path = /var/cache/swift
-# gurumed_dir = /var/lib/swift/dump
 
 # Takes a comma separated list of ints. If set, the object auditor will
 # increment a counter for every object whose size is <= to the given break
diff --git a/swift/common/daemon.py b/swift/common/daemon.py
index a3e0dbf..7b2ea93 100644
--- a/swift/common/daemon.py
+++ b/swift/common/daemon.py
@@ -22,7 +22,6 @@ from re import sub
 import eventlet.debug
 
 from swift.common import utils
-from swift.common.guru_meditation import signal_handler as gm_signal_handler
 
 
 class Daemon(object):
@@ -97,11 +96,6 @@ def run_daemon(klass, conf_file, section_name='', once=False, **kwargs):
     if reserve > 0:
         utils.FALLOCATE_RESERVE = reserve
 
-    gurumed_dir = conf.get('gurumed_dir', '/var/lib/swift/dump')
-    signal.signal(signal.SIGUSR1,
-                  lambda *args: gm_signal_handler(gurumed_dir, section_name,
-                                                  *args))
-
     # By default, disable eventlet printing stacktraces
     eventlet_debug = utils.config_true_value(conf.get('eventlet_debug', 'no'))
     eventlet.debug.hub_exceptions(eventlet_debug)
diff --git a/swift/common/guru_meditation.py b/swift/common/guru_meditation.py
deleted file mode 100644
index deb38b4..0000000
--- a/swift/common/guru_meditation.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright (c) 2010-2012 OpenStack Foundation
-# Copyright (c) 2014 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import gc
-import os
-import sys
-import time
-import traceback
-
-#from eventlet.support.greenlets import greenlet
-from greenlet import greenlet
-
-
-class ThreadModel(object):
-    def __init__(self, tid, stack):
-        self.tid = tid
-        self.stack = stack
-
-    def dump(self, report_fp):
-        traceback.print_stack(self.stack, file=report_fp)
-
-
-#  "The frame returned for a non-deadlocked thread may bear no relationship
-#  to that thread's current activity by the time calling code examines the
-#  frame." -- better than nothing
-def get_native_threads():
-    threads = []
-    for threadId, stack in sys._current_frames().items():
-        thread = ThreadModel(threadId, stack)
-        threads.append(thread)
-    return threads
-
-
-def get_green_threads():
-    def _find_objects(t):
-        return [o for o in gc.get_objects() if isinstance(o, t)]
-    threads = []
-    for gt in _find_objects(greenlet):
-        thread = ThreadModel(id(gt), gt.gr_frame)
-        threads.append(thread)
-    return threads
-
-
-def dump_threads(threads, report_fp):
-    for thread in threads:
-        report_fp.write("--- %s\n" % (thread.tid,))
-        thread.dump(report_fp)
-
-
-def signal_handler(gurumed_dir, process_name, _signum, _frame):
-    # We have two sections: native threads and green threads.
-    # But we do not add/re-add sections that Oslo does.
-
-    pid = os.getpid()
-
-    # It would be best to receive a group timestamp from swift-init,
-    # but we cannot do that while using SIGUSR1. Doing what we can for now.
-    nowstr = time.strftime("%Y%m%d.%H%M%S", time.localtime(time.time()))
-    report_fname = "%s.%s.%d" % (nowstr, process_name, pid)
-    report_path = os.path.join(gurumed_dir, report_fname)
-
-    try:
-        report_fp = open(report_path, 'a')
-    except IOError:
-        return
-    report_fp.write("=== %s %d\n" % (process_name, pid))
-
-    nthr_model = get_native_threads()
-    report_fp.write("- Native\n")
-    dump_threads(nthr_model, report_fp)
-
-    gthr_model = get_green_threads()
-    report_fp.write("- Green\n")
-    dump_threads(gthr_model, report_fp)
-
-    report_fp.write("- Done\n")
-    report_fp.close()
diff --git a/swift/common/manager.py b/swift/common/manager.py
index 57a6c16..92d8f4a 100644
--- a/swift/common/manager.py
+++ b/swift/common/manager.py
@@ -370,15 +370,6 @@ class Manager(object):
         """
         return self.reload(**kwargs)
 
-    @command
-    def dump(self, **kwargs):
-        """collect the state dump for debugging
-        """
-        status = 0
-        for server in self.servers:
-            status += server.gurumed(**kwargs)
-        return status
-
     def get_command(self, cmd):
         """Find and return the decorated method named like cmd
 
@@ -721,7 +712,7 @@ class Server(object):
         """
         conf_files = self.conf_files(**kwargs)
         if not conf_files:
-            return None
+            return {}
 
         pids = self.get_running_pids(**kwargs)
 
@@ -776,35 +767,3 @@ class Server(object):
 
         """
         return self.kill_running_pids(**kwargs)
-
-    def gurumed(self, **kwargs):
-        """Send guru meditation signals to servers
-
-        :returns: 1 if error, 0 if success (signalling no servers is success)
-        """
-
-        def _signal_pids(self, sig, **kwargs):
-            """
-            This is like self.signal_pids, but uses killpg instead of kill.
-            That takes care of children nicely, in case of e.g. auditors.
-            """
-            status = 0
-            verbose = kwargs.get('verbose')
-            for pid_file, pid in self.iter_pid_files(**kwargs):
-                try:
-                    if verbose:
-                        print(_('Guru Meditation %s  pid: %s') % (
-                            self.server, pid))
-                    os.killpg(pid, sig)
-                except OSError as e:
-                    # Not checking errno.ESRCH, because we run right after the
-                    # stock self.signal_pids() anyway, it took care of this.
-                    if e.errno == errno.EPERM:
-                        print(_("No permission to signal PID %d") % pid)
-                    status |= 1
-            return status
-
-        # XXX Write a header to the dump in case server ignores signals
-
-        status = _signal_pids(self, signal.SIGUSR1, **kwargs)
-        return status
diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py
index 60deb6b..2c169eb 100644
--- a/swift/common/wsgi.py
+++ b/swift/common/wsgi.py
@@ -36,7 +36,6 @@ from six import StringIO
 from six.moves.urllib.parse import unquote
 
 from swift.common import utils, constraints
-from swift.common.guru_meditation import signal_handler as gm_signal_handler
 from swift.common.storage_policy import BindPortsCache
 from swift.common.swob import Request
 from swift.common.utils import capture_stdio, disable_fallocate, \
@@ -392,7 +391,7 @@ def loadapp(conf_file, global_conf=None, allow_modify_pipeline=True):
     return ctx.create()
 
 
-def run_server(conf, name, logger, sock, global_conf=None):
+def run_server(conf, logger, sock, global_conf=None):
     # Ensure TZ environment variable exists to avoid stat('/etc/localtime') on
     # some platforms. This locks in reported times to the timezone in which
     # the server first starts running in locations that periodically change
@@ -416,7 +415,6 @@ def run_server(conf, name, logger, sock, global_conf=None):
                                   thread=True)
     eventlet_debug = config_true_value(conf.get('eventlet_debug', 'no'))
     eventlet.debug.hub_exceptions(eventlet_debug)
-
     wsgi_logger = NullLogger()
     if eventlet_debug:
         # let eventlet.wsgi.server log to stderr
@@ -905,15 +903,9 @@ def run_wsgi(conf_path, app_section, *args, **kwargs):
     # redirect errors to logger and close stdio
     capture_stdio(logger)
 
-    gurumed_dir = conf.get('gurumed_dir', '/var/lib/swift/dump')
-    signal.signal(signal.SIGUSR1,
-                  lambda *args: gm_signal_handler(gurumed_dir, app_section,
-                                                  *args))
-
     no_fork_sock = strategy.no_fork_sock()
     if no_fork_sock:
-        run_server(conf, app_section, logger, no_fork_sock,
-                   global_conf=global_conf)
+        run_server(conf, logger, no_fork_sock, global_conf=global_conf)
         return 0
 
     def kill_children(*args):
@@ -940,7 +932,7 @@ def run_wsgi(conf_path, app_section, *args, **kwargs):
                 signal.signal(signal.SIGHUP, signal.SIG_DFL)
                 signal.signal(signal.SIGTERM, signal.SIG_DFL)
                 strategy.post_fork_hook()
-                run_server(conf, app_section, logger, sock)
+                run_server(conf, logger, sock)
                 strategy.log_sock_exit(sock, sock_info)
                 return 0
             else:
diff --git a/test/unit/common/test_gurumed.py b/test/unit/common/test_gurumed.py
deleted file mode 100644
index c01c345..0000000
--- a/test/unit/common/test_gurumed.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright (c) 2012 OpenStack Foundation
-# Copyright (c) 2014 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import stat
-import tempfile
-import unittest
-from shutil import rmtree
-
-from swift.common.guru_meditation import signal_handler as gm_signal_handler
-
-
-class TestGuruMeditation(unittest.TestCase):
-
-    def setUp(self):
-        self.testdir = tempfile.mkdtemp()
-
-    def test_handler(self):
-        process_name = 'gurumed-test'
-        gm_signal_handler(self.testdir, process_name, -1, None)
-
-        files = os.listdir(self.testdir)
-        self.assertEquals(len(files), 1)
-        self.assertTrue(files[0].find(process_name) != -1)
-
-        path = os.path.join(self.testdir, files[0])
-        report_fd = open(path, 'r')
-        report_body = report_fd.read()
-        report_fd.close()
-
-        # This does not test much of actual functioning, but at least we
-        # didn't crash the whole test suite while groping for threads,
-        # and we wrote something resembling the first line of the output.
-        self.assertEquals(report_body[:4 + len(process_name)],
-                          '=== ' + process_name)
-
-    def test_permissions(self):
-        process_name = 'gurumed-test'
-
-        os.chmod(self.testdir, stat.S_IRUSR)
-        gm_signal_handler(self.testdir, process_name, -1, None)
-        # Note that we catch IOError and return quetly.
-
-        files = os.listdir(self.testdir)
-        self.assertEquals(len(files), 0)
-
-    def tearDown(self):
-        os.chmod(self.testdir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
-        rmtree(self.testdir)
diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py
index e8dfce9..a0e06f8 100644
--- a/test/unit/common/test_wsgi.py
+++ b/test/unit/common/test_wsgi.py
@@ -373,7 +373,7 @@ class TestWSGI(unittest.TestCase):
                             conf = wsgi.appconfig(conf_file)
                             logger = logging.getLogger('test')
                             sock = listen(('localhost', 0))
-                            wsgi.run_server(conf, 'proxy-server', logger, sock)
+                            wsgi.run_server(conf, logger, sock)
         self.assertEqual('HTTP/1.0',
                          _wsgi.HttpProtocol.default_request_version)
         self.assertEqual(30, _wsgi.WRITE_TIMEOUT)
@@ -423,7 +423,7 @@ class TestWSGI(unittest.TestCase):
                 conf = wsgi.appconfig(conf_file)
                 logger = logging.getLogger('test')
                 sock = listen(('localhost', 0))
-                wsgi.run_server(conf, 'proxy-server', logger, sock)
+                wsgi.run_server(conf, logger, sock)
 
         self.assertTrue(_wsgi.server.called)
         args, kwargs = _wsgi.server.call_args
@@ -460,8 +460,7 @@ class TestWSGI(unittest.TestCase):
                                 conf = wsgi.appconfig(conf_dir)
                                 logger = logging.getLogger('test')
                                 sock = listen(('localhost', 0))
-                                wsgi.run_server(
-                                    conf, 'proxy-server', logger, sock)
+                                wsgi.run_server(conf, logger, sock)
                                 self.assertTrue(os.environ['TZ'] is not '')
 
         self.assertEqual('HTTP/1.0',
@@ -516,7 +515,7 @@ class TestWSGI(unittest.TestCase):
                         conf = wsgi.appconfig(conf_file)
                         logger = logging.getLogger('test')
                         sock = listen(('localhost', 0))
-                        wsgi.run_server(conf, 'proxy-server', logger, sock)
+                        wsgi.run_server(conf, logger, sock)
         self.assertEqual('HTTP/1.0',
                          _wsgi.HttpProtocol.default_request_version)
         self.assertEqual(30, _wsgi.WRITE_TIMEOUT)
