Repository: rucio/rucio

Issue:
stream=True should only be used for list_replicas POST calls
Motivation
----------
At the moment it is used for ALL POST calls, but it should only be done for the list_replica one where it is needed.


Discussion:
@mlassnig @nikmagini @TomasJavurek can one of you take over this ticket? It would actually be nice if we can get this into 1.17.0 (on Monday). If nobody has time I can take it as well.

Resolving patch:
diff --git a/lib/rucio/client/baseclient.py b/lib/rucio/client/baseclient.py
--- a/lib/rucio/client/baseclient.py
+++ b/lib/rucio/client/baseclient.py
@@ -274,7 +274,7 @@ def _load_json_data(self, response):
         else:  # Exception ?
             yield response.text
 
-    def _send_request(self, url, headers=None, type='GET', data=None, params=None):
+    def _send_request(self, url, headers=None, type='GET', data=None, params=None, stream=False):
         """
         Helper method to send requests to the rucio server. Gets a new token and retries if an unauthorized error is returned.
 
@@ -300,7 +300,7 @@ def _send_request(self, url, headers=None, type='GET', data=None, params=None):
                 elif type == 'PUT':
                     result = self.session.put(url, headers=hds, data=data, verify=self.ca_cert, timeout=self.timeout)
                 elif type == 'POST':
-                    result = self.session.post(url, headers=hds, data=data, verify=self.ca_cert, timeout=self.timeout, stream=True)
+                    result = self.session.post(url, headers=hds, data=data, verify=self.ca_cert, timeout=self.timeout, stream=stream)
                 elif type == 'DEL':
                     result = self.session.delete(url, headers=hds, data=data, verify=self.ca_cert, timeout=self.timeout)
                 else:
diff --git a/lib/rucio/client/replicaclient.py b/lib/rucio/client/replicaclient.py
--- a/lib/rucio/client/replicaclient.py
+++ b/lib/rucio/client/replicaclient.py
@@ -138,7 +138,7 @@ def list_replicas(self, dids, schemes=None, unavailable=False,
             headers['Accept'] = 'application/metalink4+xml'
 
         # pass json dict in querystring
-        r = self._send_request(url, headers=headers, type='POST', data=dumps(data))
+        r = self._send_request(url, headers=headers, type='POST', data=dumps(data), stream=True)
         if r.status_code == codes.ok:
             if not metalink:
                 return self._load_json_data(r)


Test patch:
diff --git a/lib/rucio/tests/test_root_proxy.py b/lib/rucio/tests/test_root_proxy.py
--- a/lib/rucio/tests/test_root_proxy.py
+++ b/lib/rucio/tests/test_root_proxy.py
@@ -36,16 +36,16 @@ def setup(self):
 
         self.client_location_without_proxy = {'ip': '192.168.0.1',
                                               'fqdn': 'anomalous-materials.blackmesa.com',
-                                              'site': 'BLACKMESA'}
+                                              'site': 'BLACKMESA1'}
         self.rse_without_proxy = rse_name_generator()
         add_rse(self.rse_without_proxy)
         add_rse_attribute(rse=self.rse_without_proxy,
                           key='site',
-                          value='BLACKMESA')
+                          value='BLACKMESA1')
 
         self.client_location_with_proxy = {'ip': '10.0.1.1',
                                            'fqdn': 'test-chamber.aperture.com',
-                                           'site': 'APERTURE'}
+                                           'site': 'APERTURE1'}
         self.rse_with_proxy = rse_name_generator()
         add_rse(self.rse_with_proxy)
         add_rse_attribute(rse=self.rse_with_proxy,
@@ -53,7 +53,7 @@ def setup(self):
                           value='root://proxy.aperture.com:1094')
         add_rse_attribute(rse=self.rse_with_proxy,
                           key='site',
-                          value='APERTURE')
+                          value='APERTURE1')
 
         self.files = [{'scope': 'mock',
                        'name': 'half-life_%s' % i,