Skip to content

Commit

Permalink
fix #5280 (#5284)
Browse files Browse the repository at this point in the history
  • Loading branch information
belforte authored Jan 10, 2024
1 parent 8a8cacf commit 6ab4d45
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/python/CRABClient/Commands/checkfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,25 @@ def __call__(self):
self.logger.info(msg)

self.logger.info("looking up LFN in DBS %s", self.dbsInstance)
found = self.checkFileInDBS()
found, validInDBS = self.checkFileInDBS()
if not found:
self.logger.error('LFN not found in DBS')
return {'commandStatus': 'FAILED'}
return {'commandStatus': 'SUCCESS'}

if not self.rucio:
self.logger.warning('Rucio client not available with CMSSW<10\n No more checks possible')
return {'commandStatus': 'SUCCESS'}
# following code is only executed in python3, can use f-string etc.

self.logger.info("Check information in Rucio")
status, msg = self.checkFileInRucio()
if not status:
self.logger.error('LFN not found in Rucio or otherwise not properly stored in Rucio')
self.logger.error('LFN not found or otherwise not properly stored in Rucio')
self.logger.error('Details: %s', msg)
return {'commandStatus': 'FAILED'}
if validInDBS:
self.logger.error("ERROR: most likely file was deleted but non invalidated in DBS")
else:
self.logger.info("This is consistente with INVALID in DBS")
return {'commandStatus': 'SUCCESS'}

# so far so good, find Replicas and check size of the disk ones

Expand Down Expand Up @@ -95,6 +99,7 @@ def __call__(self):
self.logger.info(msg)
return {'commandStatus': 'SUCCESS'}

# reach here if user asked to check replica's checksum
if rseWithSizeOK:
self.logger.info("\nCheck Adler32 checksum (%s) for each disk replica", self.fileToCheck['adler32'])
for rse in rseWithSizeOK:
Expand All @@ -120,10 +125,10 @@ def checkFileInDBS(self):
self.logger.debug('exitcode= %s', rc)
if rc != 200: # this is HTTP code. 200=OK
self.logger.error("Error trying to talk with DBS:\n%s", msg)
return False
return False, False
if not fs:
self.logger.error("ERROR: LFN %s not found in DBS", self.lfn)
return False
return False, False
fileStatus = 'VALID' if fs[0]['is_file_valid'] else 'INVALID'
self.logger.info(" file status in DBS is %s", fileStatus)
dbsDataset = fs[0]['dataset']
Expand All @@ -133,7 +138,7 @@ def checkFileInDBS(self):
self.fileToCheck['block'] = block
self.fileToCheck['dataset'] = dbsDataset

return True
return True, fileStatus == 'VALID'

def checkFileInRucio(self):
"""
Expand All @@ -158,7 +163,6 @@ def checkFileInRucio(self):
lfnAdler32 = did['adler32']
except DataIdentifierNotFound:
msg = "LFN not found in Rucio"
msg += "\nERROR: most likely file was deleted but non invalidated in DBS"
return False, msg

self.logger.debug('LFN found in Rucio')
Expand Down

0 comments on commit 6ab4d45

Please sign in to comment.