Skip to content

Instantly share code, notes, and snippets.

@clayg
Created May 2, 2016 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/965ab068d5f0f56ee77bae7dff2e9ebb to your computer and use it in GitHub Desktop.
Save clayg/965ab068d5f0f56ee77bae7dff2e9ebb to your computer and use it in GitHub Desktop.
internal client using daemons lock up
#!/bin/bash
resetswift
pkill -9 -f /etc/swift
swift-init start main
$(swift auth)
CONTAINER="test-container"
swift post $CONTAINER
echo "uploading a bunch of expiring objects, chill..."
# if you have trouble getting it to fail, just make 1000 *BIGGER*
for i in {1..1000}; do
curl -XPUT -H "x-auth-token: ${OS_AUTH_TOKEN}" -H "x-delete-after: 1" ${OS_STORAGE_URL}/${CONTAINER}/obj${i} --data-binary "test"
done
swift-init object-updater once -n
swift-init container-updater once -n
# try a "few" times to get it to hang
for i in {1..30}; do
swift-init object-expirer start
# this bash sillyness seems to block until a new "expir" line
# appears in /var/log/syslog
sh -c 'tail -n 1 --pid=$$ -f /var/log/syslog | { sed "/expir/ q" && kill $$ ;}'
sleep 0.1$RANDOM
swift-init object-expirer stop
if [ $? -ne 0 ]; then
echo "you're hung.."
exit 1
fi
done
# non-existence proof
echo 'LGTM!'
diff --git b/swift/common/middleware/catch_errors.py a/swift/common/middleware/catch_errors.py
index feeca6e..ebafc0e 100644
--- b/swift/common/middleware/catch_errors.py
+++ a/swift/common/middleware/catch_errors.py
@@ -39,6 +39,9 @@ class CatchErrorsContext(WSGIContext):
try:
# catch any errors in the pipeline
resp = self._app_call(env)
+ except SystemExit:
+ # signal handlers can raise SystemExit in call
+ raise
except: # noqa
self.logger.exception(_('Error: An error occurred'))
resp = HTTPServerError(request=Request(env),
diff --git a/swift/common/daemon.py b/swift/common/daemon.py
index 7b2ea93..f39f2ae 100644
--- a/swift/common/daemon.py
+++ b/swift/common/daemon.py
@@ -46,7 +46,6 @@ class Daemon(object):
utils.capture_stdio(self.logger, **kwargs)
def kill_children(*args):
- signal.signal(signal.SIGTERM, signal.SIG_IGN)
os.killpg(0, signal.SIGTERM)
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment