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

Replicas registration: removing adler32 requirement in add_replica methods #3494 #3538

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/rucio/client/replicaclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from rucio.client.baseclient import BaseClient
from rucio.client.baseclient import choice
from rucio.common.utils import build_url, render_json
from rucio.common.utils import set_replica_checksums


class ReplicaClient(BaseClient):
Expand Down Expand Up @@ -167,7 +168,7 @@ def list_replicas(self, dids, schemes=None, unavailable=False,
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
raise exc_cls(exc_msg)

def add_replica(self, rse, scope, name, bytes, adler32, pfn=None, md5=None, meta={}):
def add_replica(self, rse, scope, name, bytes, adler32=None, pfn=None, md5=None, meta={}):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in principle this is fine now, however, it would allow adding replicas without any checksum at all.
Currently the schema validation would allow that.

def add_replicas(rse, files, issuer, ignore_availability=False):

It does call the schema validation there, but since it compares with dids where adler32 is not mandatory (due to datasets/containers) we can end up also with files without checksums.
@davidgcameron @mlassnig @cserf @dchristidis would be good to check this too. I am not sure if we want to allow that, I think there needs to be at least an option to require one, or the other, checksum.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the requirement be specified via a community-specific policy or configuration? For ATLAS checksums should be enforced but I can imagine other cases where it should be optional, like registering files residing on a storage which doesn't support checksums, mutable files, or pseudo-files like say a dynamic web page. I think we should be flexible and not restrict the way rucio can be (ab)used by any community :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do that. There is a few possibilities, one of them would be to place it in the schema (Which can already be community specific). The difficulty with that is that we would have to change this quite a bit though, since for now you could not just make the adler32 field mandatory. (That part of the schema is validated for datasets/containers too, and would fail them, since they do not have checksums)
Another option is to put this into rucio.cfg or config table. Something like required_checksum.
I am a little bit more leaning to the schema direction, since this makes this work natively also for multi-vo mode, where different VOs might have different requirements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to add few cents.
I'm not sure, but can you confirm making one checksum mandatory might limit the functionalities of per-RSE checksum compatibility?
In that case enforcing adler32 will throw away compatibility with, e.g., legacy gridftp sites (the triggering reason for the per-RSE compatibility).
For this reason I'd tend to the solution which would check all the provided values and verify that there is at least one, more than having a given algorithm set up statically as VO o deployment setting.
If this is not the case, then the per VO setting seems to me the best one, while having to interact with the schema is in mi mind not (read never) ideal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not following this closely, but just to throw my few cents into the discussion.

There should be a way to express the following things:

  • "every file must have a checksum, doesn't matter which one"
  • "every file must have a checksum, and it must be expliclity this one"
  • "no checksums are needed"
  • "no checksums are allowed on special RSEs"
  • "no checksums are allowed on special files"

I guess a combination of both approaches makes sense here. A schema validation for the global "decision", and then more specific attributes to express the more fine-grained selections.

"""
Add file replicas to a RSE.

Expand All @@ -183,12 +184,11 @@ def add_replica(self, rse, scope, name, bytes, adler32, pfn=None, md5=None, meta
:return: True if files were created successfully.

"""
dict = {'scope': scope, 'name': name, 'bytes': bytes, 'meta': meta, 'adler32': adler32}
if md5:
dict['md5'] = md5
if pfn:
dict['pfn'] = pfn
return self.add_replicas(rse=rse, files=[dict])
dictio = {'scope': scope, 'name': name, 'bytes': bytes, 'meta': meta}

set_replica_checksums(dictio, md5=md5, adler32=adler32, pfn=pfn)

return self.add_replicas(rse=rse, files=[dictio])

def add_replicas(self, rse, files, ignore_availability=True):
"""
Expand Down
14 changes: 14 additions & 0 deletions lib/rucio/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,20 @@ def set_checksum_value(file, checksum_names_list):
break


def set_replica_checksums(dictio, **checksums):
"""
Utility to fill a replica dictionary with all the passed checksums, automatically excluding unsupported ones

:param dictio: replica description dictionary.
:param checksums: arbitrary number of checksum values. Passed variables must be named after the checksum algorithm name.
"""
for checksum_name in checksums:
if checksum_name in GLOBALLY_SUPPORTED_CHECKSUMS or checksum_name == 'pfn':
value = checksums[checksum_name]
if value:
dictio[checksum_name] = value


def adler32(file):
"""
An Adler-32 checksum is obtained by calculating two 16-bit checksums A and B and concatenating their bits into a 32-bit integer. A is the sum of all bytes in the stream plus one, and B is the sum of the individual values of A from each step.
Expand Down
8 changes: 5 additions & 3 deletions lib/rucio/core/replica.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from rucio.common import exception
from rucio.common.utils import chunks, clean_surls, str_to_date, add_url_query
from rucio.common.types import InternalScope
from rucio.common.utils import set_replica_checksums
from rucio.core.config import get as config_get
from rucio.core.credential import get_signed_url
from rucio.core.rse import get_rse, get_rse_name, get_rse_attribute
Expand Down Expand Up @@ -1362,9 +1363,10 @@ def add_replica(rse_id, scope, name, bytes, account, adler32=None, md5=None, dsn

:returns: True is successful.
"""
file = {'scope': scope, 'name': name, 'bytes': bytes, 'adler32': adler32, 'md5': md5, 'meta': meta, 'rules': rules, 'tombstone': tombstone}
if pfn:
file['pfn'] = pfn
file = {'scope': scope, 'name': name, 'bytes': bytes, 'meta': meta, 'rules': rules, 'tombstone': tombstone}

set_replica_checksums(file, md5=md5, adler32=adler32, pfn=pfn)

return add_replicas(rse_id=rse_id, files=[file, ], account=account, session=session)


Expand Down