From 35d2fcfe440865762879f3a6c07da79b8ebcdf96 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Mon, 20 Feb 2023 14:31:13 +0000
Subject: [PATCH] Service component:

- Corrected inference of pathcomp algorithm and parameters
- Removed unneeded log messages/reduced log levels
---
 .../service/ServiceServiceServicerImpl.py     | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/service/service/ServiceServiceServicerImpl.py b/src/service/service/ServiceServiceServicerImpl.py
index 622abeee8..0b2e07601 100644
--- a/src/service/service/ServiceServiceServicerImpl.py
+++ b/src/service/service/ServiceServiceServicerImpl.py
@@ -38,8 +38,6 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
 
     @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
     def CreateService(self, request : Service, context : grpc.ServicerContext) -> ServiceId:
-        LOGGER.info('[CreateService] begin ; request = {:s}'.format(grpc_message_to_json_string(request)))
-
         if len(request.service_endpoint_ids) > 0:
             unexpected_endpoints = []
             for service_endpoint_id in request.service_endpoint_ids:
@@ -85,8 +83,6 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
 
     @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
     def UpdateService(self, request : Service, context : grpc.ServicerContext) -> ServiceId:
-        LOGGER.info('[UpdateService] begin ; request = {:s}'.format(grpc_message_to_json_string(request)))
-
         # Set service status to "SERVICESTATUS_PLANNED" to ensure rest of components are aware the service is
         # being modified.
         context_client = ContextClient()
@@ -112,27 +108,30 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
         service_id_with_uuids = context_client.SetService(service)
         service_with_uuids = context_client.GetService(service_id_with_uuids)
 
-        num_disjoint_paths = None
+        num_disjoint_paths = 0
         for constraint in request.service_constraints:
             if constraint.WhichOneof('constraint') == 'sla_availability':
                 num_disjoint_paths = constraint.sla_availability.num_disjoint_paths
                 break
 
+        num_disjoint_paths = 1 if num_disjoint_paths is None or num_disjoint_paths == 0 else num_disjoint_paths
+        num_expected_endpoints = num_disjoint_paths * 2
+
         tasks_scheduler = TasksScheduler(self.service_handler_factory)
-        if len(service_with_uuids.service_endpoint_ids) >= (2 if num_disjoint_paths is None else 4):
+        if len(service_with_uuids.service_endpoint_ids) >= num_expected_endpoints:
             pathcomp_request = PathCompRequest()
             pathcomp_request.services.append(service_with_uuids)    # pylint: disable=no-member
 
-            if num_disjoint_paths is None:
+            if num_disjoint_paths is None or num_disjoint_paths in {0, 1}:
                 pathcomp_request.shortest_path.Clear()              # pylint: disable=no-member
             else:
                 pathcomp_request.k_disjoint_path.num_disjoint = num_disjoint_paths  # pylint: disable=no-member
 
-            LOGGER.info('pathcomp_request={:s}'.format(grpc_message_to_json_string(pathcomp_request)))
+            LOGGER.debug('pathcomp_request={:s}'.format(grpc_message_to_json_string(pathcomp_request)))
             pathcomp = PathCompClient()
             pathcomp_reply = pathcomp.Compute(pathcomp_request)
             pathcomp.close()
-            LOGGER.info('pathcomp_reply={:s}'.format(grpc_message_to_json_string(pathcomp_reply)))
+            LOGGER.debug('pathcomp_reply={:s}'.format(grpc_message_to_json_string(pathcomp_reply)))
 
             # Feed TaskScheduler with this path computation reply. TaskScheduler identifies inter-dependencies among
             # the services and connections retrieved and produces a schedule of tasks (an ordered list of tasks to be
@@ -144,8 +143,6 @@ class ServiceServiceServicerImpl(ServiceServiceServicer):
 
     @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
     def DeleteService(self, request : ServiceId, context : grpc.ServicerContext) -> Empty:
-        LOGGER.info('[DeleteService] begin ; request = {:s}'.format(grpc_message_to_json_string(request)))
-
         context_client = ContextClient()
 
         # Set service status to "SERVICESTATUS_PENDING_REMOVAL" to ensure rest of components are aware the service is
-- 
GitLab