Problems with get_hops
Motivation
----------
Debugging with Katy her attempt to multi hop, we noticed that while there is a check in non-multihopping code which ignores distances set to None, there is no check in the multi hop link finder. We're now running a version which ignores such links in its test.

I also noticed the function is using [] as a default argument, which is a python no-no.

I can make a PR that fixes both issues. Hopefully after we get MH working.


Modification
------------



diff --git a/lib/rucio/core/transfer.py b/lib/rucio/core/transfer.py
index 1c604bf1b..2cf0c22c8 100644
--- a/lib/rucio/core/transfer.py
+++ b/lib/rucio/core/transfer.py
@@ -455,7 +455,7 @@ def update_transfer_state(external_host, transfer_id, state, logging_prepend_str
 
 
 @transactional_session
-def get_hops(source_rse_id, dest_rse_id, include_multihop=False, multihop_rses=[], session=None):
+def get_hops(source_rse_id, dest_rse_id, include_multihop=False, multihop_rses=None, session=None):
     """
     Get a list of hops needed to transfer date from source_rse_id to dest_rse_id.
     Ideally, the list will only include one item (dest_rse_id) since no hops are needed.
@@ -468,6 +468,9 @@ def get_hops(source_rse_id, dest_rse_id, include_multihop=False, multihop_rses=[
     :raises:                   NoDistance
     """
 
+    if multihop_rses is None:
+        multihop_rses = []
+
     # TODO: Might be problematic to always load the distance_graph, since it might be expensive
     # TODO: Have an rse_expression to specify the eligible hops
 
@@ -522,6 +525,8 @@ def get_hops(source_rse_id, dest_rse_id, include_multihop=False, multihop_rses=[
 
             for out_v in distance_graph[current_node]:
                 # Check if the distance would be smaller
+                if distance_graph[current_node][out_v] is None:
+                    continue
                 if visited_nodes.get(out_v, {'distance': 9999})['distance'] > current_distance + distance_graph[current_node][out_v] + HOP_PENALTY\\
                    and local_optimum > current_distance + distance_graph[current_node][out_v] + HOP_PENALTY:
                     # Check if the intermediate RSE is enabled for multihop
@@ -655,6 +660,7 @@ def get_transfer_requests_and_source_replicas(total_workers=0, worker_number=0,
         try:
             list_hops = get_hops(source_rse_id, dest_rse_id, include_multihop=core_config_get('transfers', 'use_multihop', default=False, expiration_time=600, session=session), multihop_rses=multihop_rses, session=session)
             if len(list_hops) > 1:
+                logging.debug('From %s to %s requires multihop: %s', source_rse_id, dest_rse_id, list_hops)
                 multihop = True
                 multi_hop_dict[req_id] = (list_hops, dict_attributes, retry_count)
         except NoDistance:
['lib/rucio/core/transfer.py']