Skip to content

Commit

Permalink
[#282] Add hard stop for DeleteMode usage with S3 buckets
Browse files Browse the repository at this point in the history
DeleteMode is not supported for S3 bucket syncs, so we need
to stop the sync job if something other than DO_NOT_DELETE
is provided in order to prevent a silent no-op.
  • Loading branch information
alanking committed Oct 8, 2024
1 parent fbd3e03 commit 972cdef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion irods_capability_automated_ingest/tasks/s3_bucket_tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .. import sync_logging
from .. import sync_logging, utils
from ..celery import app, RestartTask
from ..char_map_util import translate_path
from ..custom_event_handler import custom_event_handler
Expand Down Expand Up @@ -80,6 +80,8 @@ def s3_bucket_sync_path(self, meta):

logger = sync_logging.get_sync_logger(logging_config)

event_handler = custom_event_handler(meta)

proxy_url = meta.get("s3_proxy_url")
if proxy_url is None:
httpClient = None
Expand Down Expand Up @@ -113,6 +115,15 @@ def s3_bucket_sync_path(self, meta):
meta["task"] = "s3_bucket_sync_dir"
chunk = {}

# Check to see whether the provided operation and delete_mode are compatible.
delete_mode = event_handler.delete_mode()
logger.debug(f"delete_mode: {delete_mode}")
# TODO(#282): S3 bucket syncs do not support DeleteMode (yet)
if utils.DeleteMode.DO_NOT_DELETE != delete_mode:
raise RuntimeError(
f"S3 bucket syncs do not support DeleteMode [{delete_mode}]. Only DeleteMode.DO_NOT_DELETE is supported."
)

path_list = meta["path"].lstrip("/").split("/", 1)
bucket_name = path_list[0]
if len(path_list) == 1:
Expand Down

0 comments on commit 972cdef

Please sign in to comment.