Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yda 5892 delete revision creation avu for data objects found in trash #523

Merged
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ def rule_revision_batch(ctx, verbose, balance_id_min, balance_id_max, batch_size

minimum_timestamp = int(time.time() - config.async_revision_delay_time)

# Remove revision creation AVUs from deleted data objects.
# This makes it easier to monitor the number of data objects waiting for revision creation.
remove_revision_creation_avu_from_deleted_data_objects(ctx)

# Get list of up to batch size limit of data objects (in research space) scheduled for revision, taking into account
# modification time.
log.write(ctx, "verbose = {}".format(verbose))
Expand Down Expand Up @@ -1054,3 +1058,31 @@ def memory_limit_exceeded(rss_limit):
"""
rss_limit = int(rss_limit)
return rss_limit and memory_rss_usage() > rss_limit


def remove_revision_creation_avu_from_deleted_data_objects(ctx):
"""
Removes revision creation AVUs from deleted data objects [marked with 'org_revision_scheduled' metadata].

:param ctx: Combined type of a callback and rei struct

:raises Exception: If removal of revision creation AVUs fails
"""
if user.user_type(ctx) != 'rodsadmin':
raise Exception("This rule can only be executed by a rodsadmin user.")
leonidastri marked this conversation as resolved.
Show resolved Hide resolved

revision_avu_name = constants.UUORGMETADATAPREFIX + "revision_scheduled"

iter = genquery.row_iterator(
"COLL_NAME, DATA_NAME",
"COLL_NAME like '%{}/trash/home/%' AND META_DATA_ATTR_NAME = '{}'".format(user.zone(ctx), revision_avu_name),
genquery.AS_LIST, ctx
)

for coll_name, data_name in iter:
path = coll_name + '/' + data_name
try:
avu.rmw_from_data(ctx, path, revision_avu_name, "%") # use wildcard cause rm_from_data causes problems
log.write(ctx, 'Removed revision creation AVUs from data object: {}'.format(path))
leonidastri marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e:
log.write(ctx, "Error processing data object {}: {}".format(path, str(e)))
Loading