diff --git a/doc/source/logs.rst b/doc/source/logs.rst index 79b8a3efb0..39258b1c72 100644 --- a/doc/source/logs.rst +++ b/doc/source/logs.rst @@ -126,9 +126,11 @@ status_int The response code for the request. content_length The value of the Content-Length header in the response. referer The value of the HTTP Referer header. transaction_id The transaction id of the request. -user_agent The value of the HTTP User-Agent header. Swift's proxy - server sets its user-agent to - ``"proxy-server ".`` +user_agent The value of the HTTP User-Agent header. Swift services + report a user-agent string of the service name followed by + the process ID, such as ``"proxy-server "`` or ``"object-updater "``. request_time The duration of the request. additional_info Additional useful information. server_pid The process id of the server diff --git a/swift/obj/mem_server.py b/swift/obj/mem_server.py index 7b3baf1b59..83647661aa 100644 --- a/swift/obj/mem_server.py +++ b/swift/obj/mem_server.py @@ -70,7 +70,7 @@ class ObjectController(server.ObjectController): :param objdevice: device name that the object is in :param policy_idx: the associated storage policy index """ - headers_out['user-agent'] = 'obj-server %s' % os.getpid() + headers_out['user-agent'] = 'object-server %s' % os.getpid() full_path = '/%s/%s/%s' % (account, container, obj) if all([host, partition, contdevice]): try: diff --git a/swift/obj/replicator.py b/swift/obj/replicator.py index fdc5378252..6994ca39cb 100644 --- a/swift/obj/replicator.py +++ b/swift/obj/replicator.py @@ -86,7 +86,7 @@ class ObjectReplicator(Daemon): self.disk_chunk_size = int(conf.get('disk_chunk_size', 65536)) self.headers = { 'Content-Length': '0', - 'user-agent': 'obj-replicator %s' % os.getpid()} + 'user-agent': 'object-replicator %s' % os.getpid()} self.rsync_error_log_line_length = \ int(conf.get('rsync_error_log_line_length', 0)) self.handoffs_first = config_true_value(conf.get('handoffs_first', diff --git a/swift/obj/server.py b/swift/obj/server.py index 4a3b9926ff..8fe1e7c8fe 100644 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -169,7 +169,7 @@ class ObjectController(object): :param objdevice: device name that the object is in :param policy_index: the associated storage policy index """ - headers_out['user-agent'] = 'obj-server %s' % os.getpid() + headers_out['user-agent'] = 'object-server %s' % os.getpid() full_path = '/%s/%s/%s' % (account, container, obj) if all([host, partition, contdevice]): try: diff --git a/swift/obj/updater.py b/swift/obj/updater.py index 6a9e7a1a4c..62ab9a39b9 100644 --- a/swift/obj/updater.py +++ b/swift/obj/updater.py @@ -258,7 +258,7 @@ class ObjectUpdater(Daemon): :param headers: headers to send with the update """ headers_out = headers.copy() - headers_out['user-agent'] = 'obj-updater %s' % os.getpid() + headers_out['user-agent'] = 'object-updater %s' % os.getpid() try: with ConnectionTimeout(self.conn_timeout): conn = http_connect(node['ip'], node['port'], node['device'], diff --git a/test/unit/obj/test_replicator.py b/test/unit/obj/test_replicator.py index 2b49f20167..cda8e9a2f0 100644 --- a/test/unit/obj/test_replicator.py +++ b/test/unit/obj/test_replicator.py @@ -689,7 +689,7 @@ class TestObjectReplicator(unittest.TestCase): self.replicator.partition_times = [] self.headers = {'Content-Length': '0', - 'user-agent': 'obj-replicator %s' % os.getpid()} + 'user-agent': 'object-replicator %s' % os.getpid()} self.replicator.logger = mock_logger = mock.MagicMock() mock_tpool_reraise.return_value = (0, {}) diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py index 0916e0513d..d521ff0a92 100755 --- a/test/unit/obj/test_server.py +++ b/test/unit/obj/test_server.py @@ -2319,7 +2319,7 @@ class TestObjectController(unittest.TestCase): given_args, ['127.0.0.1', '1234', 'sdc1', 1, 'PUT', '/a/c/o', { 'x-timestamp': '1', 'x-out': 'set', - 'user-agent': 'obj-server %s' % os.getpid(), + 'user-agent': 'object-server %s' % os.getpid(), 'X-Backend-Storage-Policy-Index': policy.idx}]) @patch_policies([storage_policy.StoragePolicy(0, 'zero', True), @@ -2399,7 +2399,7 @@ class TestObjectController(unittest.TestCase): 'x-timestamp': utils.Timestamp('12345').internal, 'X-Backend-Storage-Policy-Index': '37', 'referer': 'PUT http://localhost/sda1/p/a/c/o', - 'user-agent': 'obj-server %d' % os.getpid(), + 'user-agent': 'object-server %d' % os.getpid(), 'X-Backend-Storage-Policy-Index': policy.idx, 'x-trans-id': '-'})}) self.assertEquals( @@ -2417,7 +2417,7 @@ class TestObjectController(unittest.TestCase): 'x-size': '0', 'x-timestamp': utils.Timestamp('12345').internal, 'referer': 'PUT http://localhost/sda1/p/a/c/o', - 'user-agent': 'obj-server %d' % os.getpid(), + 'user-agent': 'object-server %d' % os.getpid(), # system account storage policy is 0 'X-Backend-Storage-Policy-Index': 0, 'x-trans-id': '-'})}) @@ -2436,7 +2436,7 @@ class TestObjectController(unittest.TestCase): 'x-size': '0', 'x-timestamp': utils.Timestamp('12345').internal, 'referer': 'PUT http://localhost/sda1/p/a/c/o', - 'user-agent': 'obj-server %d' % os.getpid(), + 'user-agent': 'object-server %d' % os.getpid(), # system account storage policy is 0 'X-Backend-Storage-Policy-Index': 0, 'x-trans-id': '-'})}) @@ -2507,7 +2507,7 @@ class TestObjectController(unittest.TestCase): 'x-timestamp': utils.Timestamp('12345').internal, 'X-Backend-Storage-Policy-Index': '26', 'referer': 'PUT http://localhost/sda1/p/a/c/o', - 'user-agent': 'obj-server %d' % os.getpid(), + 'user-agent': 'object-server %d' % os.getpid(), 'x-trans-id': '-'})}) self.assertEquals( http_connect_args[1], @@ -2525,7 +2525,7 @@ class TestObjectController(unittest.TestCase): 'x-timestamp': utils.Timestamp('12345').internal, 'X-Backend-Storage-Policy-Index': '26', 'referer': 'PUT http://localhost/sda1/p/a/c/o', - 'user-agent': 'obj-server %d' % os.getpid(), + 'user-agent': 'object-server %d' % os.getpid(), 'x-trans-id': '-'})}) def test_object_delete_at_aysnc_update(self): @@ -2639,7 +2639,7 @@ class TestObjectController(unittest.TestCase): '06fbf0b514e5199dfc4e00f42eb5ea83-%s' % utils.Timestamp(1).internal))), {'headers': {'x-timestamp': '1', 'x-out': 'set', - 'user-agent': 'obj-server %s' % os.getpid(), + 'user-agent': 'object-server %s' % os.getpid(), 'X-Backend-Storage-Policy-Index': policy.idx}, 'account': 'a', 'container': 'c', 'obj': 'o', 'op': 'PUT'}) @@ -2680,7 +2680,8 @@ class TestObjectController(unittest.TestCase): '06fbf0b514e5199dfc4e00f42eb5ea83-%s' % utils.Timestamp(1).internal))), {'headers': {'x-timestamp': '1', 'x-out': str(status), - 'user-agent': 'obj-server %s' % os.getpid(), + 'user-agent': + 'object-server %s' % os.getpid(), 'X-Backend-Storage-Policy-Index': policy.idx}, 'account': 'a', 'container': 'c', 'obj': 'o', @@ -2803,7 +2804,7 @@ class TestObjectController(unittest.TestCase): self.assertEqual(method, 'PUT') self.assertEqual(path, '/cdevice/cpartition/a/c/o') self.assertEqual(headers, HeaderKeyDict({ - 'user-agent': 'obj-server %s' % os.getpid(), + 'user-agent': 'object-server %s' % os.getpid(), 'x-size': '0', 'x-etag': 'd41d8cd98f00b204e9800998ecf8427e', 'x-content-type': 'text/plain', @@ -2844,7 +2845,7 @@ class TestObjectController(unittest.TestCase): self.assertEqual(data, { 'headers': HeaderKeyDict({ 'X-Size': '0', - 'User-Agent': 'obj-server %s' % os.getpid(), + 'User-Agent': 'object-server %s' % os.getpid(), 'X-Content-Type': 'text/plain', 'X-Timestamp': utils.Timestamp(1).internal, 'X-Trans-Id': '123',