Skip to content

Commit

Permalink
Merge pull request #7613 from chaen/v8.0_feat_fts3SafeVersion
Browse files Browse the repository at this point in the history
[8.0] feat (FTS3): prepare for breaking API release
  • Loading branch information
fstagni authored May 16, 2024
2 parents 03d5fb2 + 7e94e45 commit c111713
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 0 additions & 1 deletion docs/diracdoctools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"_arc",
"arc",
"cmreslogging",
"fts3",
"gfal2",
"git",
"lcg_util",
Expand Down
19 changes: 17 additions & 2 deletions src/DIRAC/DataManagementSystem/Client/FTS3Job.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
""" FTS3Job module containing only the FTS3Job class """

import datetime
import errno
from packaging.version import Version


# Requires at least version 3.3.3
from fts3 import __version__ as fts3_version
import fts3.rest.client.easy as fts3
from fts3.rest.client.exceptions import FTS3ClientException, NotFound

# There is a breaking change in the API in 3.13
# https://gitlab.cern.ch/fts/fts-rest-flask/-/commit/5faa283e0cd4b80a0139a547c4a6356522c8449d
FTS3_SPACETOKEN_API_CHANGE = Version("3.13")
if Version(fts3_version) >= FTS3_SPACETOKEN_API_CHANGE:
DESTINATION_SPACETOKEN_ATTR = "destination_spacetoken"
else:
DESTINATION_SPACETOKEN_ATTR = "spacetoken"

# We specifically use Request in the FTS client because of a leak in the
# default pycurl. See https://its.cern.ch/jira/browse/FTS-261
from fts3.rest.client.request import Request as ftsSSLRequest
Expand Down Expand Up @@ -501,11 +513,11 @@ def _constructTransferJob(self, pinTime, allLFNs, target_spacetoken, protocols=N
if self.activity:
job_metadata["activity"] = self.activity

dest_spacetoken = {DESTINATION_SPACETOKEN_ATTR: target_spacetoken}
job = fts3.new_job(
transfers=transfers,
overwrite=True,
source_spacetoken=source_spacetoken,
spacetoken=target_spacetoken,
bring_online=bring_online,
copy_pin_lifetime=copy_pin_lifetime,
retry=3,
Expand All @@ -514,6 +526,7 @@ def _constructTransferJob(self, pinTime, allLFNs, target_spacetoken, protocols=N
metadata=job_metadata,
priority=self.priority,
archive_timeout=archive_timeout,
**dest_spacetoken,
)

return S_OK((job, fileIDsInTheJob))
Expand Down Expand Up @@ -641,16 +654,18 @@ def _constructStagingJob(self, pinTime, allLFNs, target_spacetoken):
if self.activity:
job_metadata["activity"] = self.activity

dest_spacetoken = {DESTINATION_SPACETOKEN_ATTR: target_spacetoken}

job = fts3.new_job(
transfers=transfers,
overwrite=True,
source_spacetoken=target_spacetoken,
spacetoken=target_spacetoken,
bring_online=bring_online,
copy_pin_lifetime=copy_pin_lifetime,
retry=3,
metadata=job_metadata,
priority=self.priority,
**dest_spacetoken,
)

return S_OK((job, fileIDsInTheJob))
Expand Down

0 comments on commit c111713

Please sign in to comment.