Skip to content

Commit

Permalink
Fix tests + formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-shelkovnikov committed Dec 20, 2023
1 parent 59cdc3a commit c93c01b
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 235 deletions.
6 changes: 5 additions & 1 deletion connectors/services/job_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
A task periodically clean up orphaned and idle jobs.
"""

from connectors.es.client import ESManagementClient
from connectors.es.index import DocumentNotFoundError
from connectors.logger import logger
from connectors.protocol import ConnectorIndex, SyncJobIndex
Expand All @@ -27,6 +28,7 @@ def __init__(self, config):
async def _run(self):
logger.debug("Successfully started Job cleanup task...")
self.connector_index = ConnectorIndex(self.es_config)
self.es_management_client = ESManagementClient(self.es_config)
self.sync_job_index = SyncJobIndex(self.es_config)

try:
Expand Down Expand Up @@ -71,7 +73,9 @@ async def _process_orphaned_jobs(self):

# delete content indices in case they are re-created by sync job
if len(content_indices) > 0:
await self.sync_job_index.delete_indices(indices=list(content_indices))
await self.es_management_client.delete_indices(
indices=list(content_indices)
)
result = await self.sync_job_index.delete_jobs(job_ids=job_ids)
if len(result["failures"]) > 0:
logger.error(f"Error found when deleting jobs: {result['failures']}")
Expand Down
Loading

0 comments on commit c93c01b

Please sign in to comment.