Skip to content

Commit

Permalink
Subscription : Add the possibility to reevaluate subscription when a …
Browse files Browse the repository at this point in the history
…dataset is closed : Closes rucio#5926
  • Loading branch information
cserf committed Oct 19, 2022
1 parent 16ffde7 commit bb96ecb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/rucio/core/did.py
Expand Up @@ -2734,6 +2734,7 @@ def set_status(scope, name, session=None, **kwargs):
:param kwargs: Keyword arguments of the form status_name=value.
"""
statuses = ['open', ]
reevaluate_close_did = config_get_bool('core', 'reevaluate_close_did', raise_exception=False, default=False, session=session)

update_stmt = update(
models.DataIdentifier
Expand Down Expand Up @@ -2784,6 +2785,10 @@ def set_status(scope, name, session=None, **kwargs):
message['vo'] = scope.vo

add_message('CLOSE', message, session=session)
if reevaluate_close_did:
set_new_dids(dids=[{'scope': scope, 'name': name}],
new_flag=True,
session=session)

else:
# Set status to open only for privileged accounts
Expand Down
21 changes: 20 additions & 1 deletion lib/rucio/tests/test_did.py
Expand Up @@ -29,8 +29,9 @@
from rucio.common.utils import generate_uuid
from rucio.core.did import (list_dids, add_did, delete_dids, get_did_atime, touch_dids, attach_dids, detach_dids,
get_metadata, set_metadata, get_did, get_did_access_cnt, add_did_to_followed,
get_users_following_did, remove_did_from_followed, set_status)
get_users_following_did, remove_did_from_followed, set_status, list_new_dids)
from rucio.core.replica import add_replica, get_replica
from rucio.daemons.transmogrifier.transmogrifier import run
from rucio.db.sqla.constants import DIDType
from rucio.tests.common import rse_name_generator, scope_name_generator, did_name_generator

Expand Down Expand Up @@ -259,6 +260,24 @@ def test_circular_attach(self, root_account, rse_factory, did_factory, file_conf
with pytest.raises(UnsupportedOperation, match='Circular attachment detected'):
attach_dids(dids=[container1], account=root_account, **container3)

@pytest.mark.dirty
@pytest.mark.noparallel(reason='run transmogrifier')
@pytest.mark.parametrize("file_config_mock", [
{"overrides": [('core', 'reevaluate_close_did', 'True')]},
], indirect=True)
def test_reevaluate_after_close(self, mock_scope, root_account, file_config_mock):
""" DATA IDENTIFIERS (CORE): Test that the option reevaluate_close_did set is_new to True """
dsn = did_name_generator('dataset')

add_did(scope=mock_scope, name=dsn, did_type=DIDType.DATASET, account=root_account)
run(threads=1, bulk=1000000, once=True)
new_dids = [did for did in list_new_dids(did_type=None, thread=None, total_threads=None, chunk_size=100000, session=None)]
assert new_dids == []
set_status(mock_scope, dsn, open=False)
new_dids = [did for did in list_new_dids(did_type=None, thread=None, total_threads=None, chunk_size=100000, session=None)]
print(new_dids)
assert {'scope': mock_scope, 'name': dsn, 'did_type': DIDType.DATASET} in new_dids


class TestDIDApi:

Expand Down

0 comments on commit bb96ecb

Please sign in to comment.