Commit 88999dc4 authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

service: do not abandon an optical connection whose first handler is not its own

get_service_handlers() returns one entry per device type on the path, and
deconfiguring stops after the first so that a second pass does not try to
remove media channels that are already gone. Stopping unconditionally,
however, also stopped when the first handler did not own the connection's
media channel: DeleteEndpoint was skipped, delete_connection was never
reached, and the connection outlived its service. Deleting that service
then failed on the connection_service_uuid foreign key.

It now stops once a handler has actually deleted the connection and
otherwise moves on to the next one, which is how the loop behaved before
the early exit was introduced.
parent b2713818
Loading
Loading
Loading
Loading
+9 −4
Changes for src/service/service/task_scheduler/tasks/Task_OpticalConnectionDeconfigure.py: 9 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ class Task_OpticalConnectionDeconfigure(_Task):
                    raise OperationFailedException(MSG.format(str_connection, str_service), extra_details=errors)
                if is_media_channel:
                    self._task_executor.delete_connection(self._connection_id)
                    break
                # This handler does not own the media channel; try the next one.
                continue
            else:
                results_deleteendpoint = service_handler.DeleteEndpoint(endpointids_to_delete, connection_uuid=connection_uuid)
                errors = check_errors_deleteendpoint(endpointids_to_delete, results_deleteendpoint)
@@ -82,8 +85,10 @@ class Task_OpticalConnectionDeconfigure(_Task):
                    raise OperationFailedException(MSG.format(str_connection, str_service), extra_details=errors)
                self._task_executor.delete_connection(self._connection_id)

            # get_service_handlers() returns one entry per device type in the path (e.g. transponders
            # and ROADMs), but DeleteEndpoint already acts on every endpoint of the connection; as in
            # Task_OpticalConnectionConfigure, invoke it once, otherwise the second pass tries to
            # delete media channels that are already gone (NETCONF "data-missing").
            # get_service_handlers() returns one entry per device type in the path (e.g.
            # transponders and ROADMs), but DeleteEndpoint already acts on every endpoint of the
            # connection, so stop as soon as one handler has deleted it; a second pass would try
            # to remove media channels that are already gone (NETCONF "data-missing"). Stopping
            # unconditionally would instead leave the connection behind whenever the first
            # handler is not the one owning the media channel.
            break