summaryrefslogtreecommitdiff
path: root/swift/obj/updater.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-01-26 00:43:36 +0000
committerGerrit Code Review <review@openstack.org>2022-01-26 00:43:36 +0000
commit793a57d7f96c56c9639a0f5df19ca9ce2fd8e555 (patch)
treee7e8e9b118692987e8073178550a7707b45d4842 /swift/obj/updater.py
parent8ef530d795df7f0300e761933c916546427a79fe (diff)
parent219a79a24d4d687b5a9b72b60d84665ebc2ec137 (diff)
downloadswift-793a57d7f96c56c9639a0f5df19ca9ce2fd8e555.tar.gz
Merge "updater: Add timing stats"
Diffstat (limited to 'swift/obj/updater.py')
-rw-r--r--swift/obj/updater.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/swift/obj/updater.py b/swift/obj/updater.py
index a0db3ffe7..b90b63f8a 100644
--- a/swift/obj/updater.py
+++ b/swift/obj/updater.py
@@ -562,6 +562,9 @@ class ObjectUpdater(Daemon):
tuple of (a path, a timestamp string).
"""
redirect = None
+ start = time.time()
+ # Assume an error until we hear otherwise
+ status = 500
try:
with ConnectionTimeout(self.conn_timeout):
conn = http_connect(
@@ -570,8 +573,9 @@ class ObjectUpdater(Daemon):
with Timeout(self.node_timeout):
resp = conn.getresponse()
resp.read()
+ status = resp.status
- if resp.status == HTTP_MOVED_PERMANENTLY:
+ if status == HTTP_MOVED_PERMANENTLY:
try:
redirect = get_redirect_data(resp)
except ValueError as err:
@@ -579,7 +583,7 @@ class ObjectUpdater(Daemon):
'Container update failed for %r; problem with '
'redirect location: %s' % (obj, err))
- success = is_success(resp.status)
+ success = is_success(status)
if not success:
self.logger.debug(
'Error code %(status)d is returned from remote '
@@ -588,8 +592,23 @@ class ObjectUpdater(Daemon):
'port': node['replication_port'],
'device': node['device']})
return success, node['id'], redirect
- except (Exception, Timeout):
+ except Exception:
self.logger.exception(
'ERROR with remote server '
'%(replication_ip)s:%(replication_port)s/%(device)s', node)
+ except Timeout as exc:
+ action = 'connecting to'
+ if not isinstance(exc, ConnectionTimeout):
+ # i.e., we definitely made the request but gave up
+ # waiting for the response
+ status = 499
+ action = 'waiting on'
+ self.logger.info(
+ 'Timeout %(action)s remote server '
+ '%(replication_ip)s:%(replication_port)s/%(device)s: %(exc)s',
+ dict(node, exc=exc, action=action))
+ finally:
+ elapsed = time.time() - start
+ self.logger.timing('updater.timing.status.%s' % status,
+ elapsed * 1000)
return HTTP_INTERNAL_SERVER_ERROR, node['id'], redirect