in tools/fixity/lambda/driver/app.py [0:0]
def _submit_job(sourceBucket, sourceKey):
logger.debug("preflight check start")
#preflight checks _read_
pre_flight_response = s3client.head_object(
Bucket=sourceBucket,
Key=sourceKey
)
logger.debug('## PREFLIGHT_RESPONSE\r' + jsonpickle.encode(dict(**pre_flight_response)))
if 'DeleteMarker' in pre_flight_response:
if pre_flight_response['pre_flight_response'] == True:
raise Exception('Object ' + sourceKey + ' is deleted')
size = pre_flight_response['ContentLength']
logger.debug("preflight check end")
unsupportedStorageClass = False
#Storage class check
if 'StorageClass' in pre_flight_response:
if pre_flight_response['StorageClass'] in ['GLACIER', 'DEEP_ARCHIVE']:
#check restore status:
if 'Restore' in pre_flight_response:
restore = pre_flight_response['Restore']
logger.debug(restore)
if 'ongoing-request="false"' not in restore:
logger.info('restore is in progress')
raise Exception('Object ' + sourceKey + ' is restoring from ' + pre_flight_response['StorageClass'])
else:
unsupportedStorageClass = True
if (unsupportedStorageClass):
raise Exception('Object ' + sourceKey + ' is in unsupported StorageClass ' + pre_flight_response['StorageClass'])
#NFC for unicodedata
if unicodedata.is_normalized('NFC', sourceKey) == False:
raise Exception('Object ' + sourceKey + ' is not in Normalized Form C' )
# use bigger containers for 10GB+
logger.debug("job submission start")
jobDefinition = os.environ['JOB_SIZE_SMALL'] if pre_flight_response['ContentLength'] < int(os.environ['JOB_SIZE_THRESHOLD']) else os.environ['JOB_SIZE_LARGE']
logger.debug("job definition is " + jobDefinition)
logger.debug("job submission start")
#submit job
response = batchclient.submit_job(
jobName="Fixity",
jobQueue=os.environ['JOB_QUEUE'],
jobDefinition=jobDefinition,
parameters={
'Bucket': sourceBucket,
'Key': sourceKey
},
propagateTags=True,
tags={
'Bucket': sourceBucket,
'Key': sourceKey,
'Size': str(pre_flight_response['ContentLength'])
}
)
logger.debug('## BATCH_RESPONSE\r' + jsonpickle.encode(dict(**response)))
logger.debug("job submission complete")
return response['jobId']