From ae6826734fb56a2358bc528550fff54e5ada5d8b Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Thu, 6 Dec 2018 14:23:44 +0000 Subject: [PATCH] Catch exception of ring sync fails It is possible for swift-storage units to attempt to request rings from a proxy unit that is no longer serving them so instead of raising an exception we catch it and move on since there will likely be a another proxy notification waiting to be consumed. Change-Id: Ib2e634d2ed3509bfe2aa9b792cc17c2ed89029f1 Closes-Bug: #1765203 --- hooks/swift_storage_hooks.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hooks/swift_storage_hooks.py b/hooks/swift_storage_hooks.py index 5eecdab..0a21ca3 100755 --- a/hooks/swift_storage_hooks.py +++ b/hooks/swift_storage_hooks.py @@ -24,6 +24,7 @@ import socket import subprocess import tempfile +from subprocess import CalledProcessError _path = os.path.dirname(os.path.realpath(__file__)) _root = os.path.abspath(os.path.join(_path, '..')) @@ -71,6 +72,7 @@ from charmhelpers.core.hookenv import ( status_set, ingress_address, DEBUG, + WARNING, ) from charmhelpers.fetch import ( @@ -303,7 +305,16 @@ def swift_storage_relation_changed(): CONFIGS.write('/etc/rsync-juju.d/050-swift-storage.conf') CONFIGS.write('/etc/swift/swift.conf') - fetch_swift_rings(rings_url) + # NOTE(hopem): retries are handled in the function but it is possible that + # we are attempting to get rings from a proxy that is no + # longer publiscising them so lets catch the error, log a + # message and hope that the good rings_url us waiting to be + # consumed. + try: + fetch_swift_rings(rings_url) + except CalledProcessError: + log("Failed to sync rings from {} - no longer available from that " + "unit?".format(rings_url), level=WARNING) @hooks.hook('swift-storage-relation-departed')