-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delete docs not found when re indexing in catalog task (#1365)
### Feature or Bugfix <!-- please choose --> - Feature ### Detail - Add logic to Catalog Indexer Task to Delete Docs No Longer in RDS - TODO: Add Ability to Re-index Catalog Items via Dataall Admin UI ### Relates - #1078 ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? - Have you used the least-privilege principle? How? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
e2817a1
commit 3ccacfc
Showing
25 changed files
with
432 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from dataall.modules.catalog.handlers import ecs_catalog_handlers | ||
|
||
__all__ = ['ecs_catalog_handlers'] |
27 changes: 27 additions & 0 deletions
27
backend/dataall/modules/catalog/handlers/ecs_catalog_handlers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import logging | ||
import os | ||
|
||
from dataall.core.tasks.service_handlers import Worker | ||
from dataall.core.stacks.aws.ecs import Ecs | ||
from dataall.core.tasks.db.task_models import Task | ||
from dataall.modules.catalog.tasks.catalog_indexer_task import CatalogIndexerTask | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class EcsCatalogIndexHandler: | ||
@staticmethod | ||
@Worker.handler(path='ecs.reindex.catalog') | ||
def run_ecs_reindex_catalog_task(engine, task: Task): | ||
envname = os.environ.get('envname', 'local') | ||
if envname in ['local', 'dkrcompose']: | ||
CatalogIndexerTask.index_objects(engine, str(task.payload.get('with_deletes', False))) | ||
else: | ||
ecs_task_arn = Ecs.run_ecs_task( | ||
task_definition_param='ecs/task_def_arn/catalog_indexer', | ||
container_name_param='ecs/container/catalog_indexer', | ||
context=[ | ||
{'name': 'with_deletes', 'value': str(task.payload.get('with_deletes', False))}, | ||
], | ||
) | ||
return {'task_arn': ecs_task_arn} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
backend/dataall/modules/catalog/services/catalog_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import logging | ||
|
||
from dataall.base.context import get_context | ||
|
||
from dataall.core.permissions.services.tenant_policy_service import TenantPolicyValidationService | ||
from dataall.core.tasks.db.task_models import Task | ||
from dataall.core.tasks.service_handlers import Worker | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CatalogService: | ||
@staticmethod | ||
def start_reindex_catalog(with_deletes: bool) -> bool: | ||
context = get_context() | ||
groups = context.groups if context.groups is not None else [] | ||
if not TenantPolicyValidationService.is_tenant_admin(groups): | ||
raise Exception('Only data.all admin group members can start re-index catalog task') | ||
|
||
with context.db_engine.scoped_session() as session: | ||
reindex_catalog_task: Task = Task( | ||
action='ecs.reindex.catalog', targetUri='ALL', payload={'with_deletes': with_deletes} | ||
) | ||
session.add(reindex_catalog_task) | ||
|
||
Worker.queue(engine=context.db_engine, task_ids=[reindex_catalog_task.taskUri]) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.