Skip to content
Snippets Groups Projects

Исправлена работа с операциями в классе ExtensionService

Merged Podosochnyy Maxim requested to merge feature/AUTO-3851 into master
Files
2
@@ -94,7 +94,7 @@ class ExtensionService(
clients: list[clients_pb2.Client] = []
actions: list[dict] = []
__operations: dict[str, OperationMeta] = {}
__operations: dict[str, OperationMeta]
def __init__(self,
collections_service: collections_pb2_grpc.CollectionsStub,
@@ -137,6 +137,8 @@ class ExtensionService(
self.roles_service, self.clients_service, self.items_service,
)
self.__operations = {}
for collection in self.collections or []:
self.extension_setup.add_collection(collection)
@@ -153,6 +155,10 @@ class ExtensionService(
async def remove_old_operations():
self.remove_old_operations()
@property
def operations(self):
return self.__operations
def remove_old_operations(self):
self.logger.info("Удаление старых операций")
@@ -234,6 +240,12 @@ class ExtensionService(
description=description
)
def mark_operation_as_finished(self, operation_id: str, errors: list[str] | None = None):
if operation_id in self.operations:
self.operations[operation_id].mark_finished(errors)
else:
self.logger.error(f"Операция {operation_id} не найдена!")
async def _Install(self, operation_id: str, request: extension_service_pb2.InstallRequest, context):
errors_list = await self.extension_setup.install(
request.space_id, request.env_id, request.force
@@ -241,7 +253,7 @@ class ExtensionService(
self.result_log("установки", operation_id, request, errors_list)
self.__operations[operation_id].mark_finished(errors_list)
self.mark_operation_as_finished(operation_id, errors_list)
async def Install(self, request: extension_service_pb2.InstallRequest, context):
operation_id = generate_operation_id()
@@ -265,7 +277,7 @@ class ExtensionService(
self.result_log("удаления", operation_id, request, errors_list)
self.__operations[operation_id].mark_finished(errors_list)
self.mark_operation_as_finished(operation_id, errors_list)
async def Uninstall(self, request: extension_service_pb2.UninstallRequest, context):
operation_id = generate_operation_id()
Loading