Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 11c3a591 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Integritycheck after transfer

parent 492cc4b8
...@@ -49,6 +49,7 @@ format_report(){ ...@@ -49,6 +49,7 @@ format_report(){
# If everything goes fine, then validate staging data # If everything goes fine, then validate staging data
irods_push(){ irods_push(){
KEY=$1 KEY=$1
LOCAL_SHA=$2
SIZE=$(stat -c %s $RESIFDD_WORKDIR/$KEY.tar) SIZE=$(stat -c %s $RESIFDD_WORKDIR/$KEY.tar)
SIZEMB=$(($SIZE/1024/1024)) SIZEMB=$(($SIZE/1024/1024))
...@@ -63,7 +64,7 @@ irods_push(){ ...@@ -63,7 +64,7 @@ irods_push(){
irm -f $KEY/staging.tar > /dev/null 2>&1 irm -f $KEY/staging.tar > /dev/null 2>&1
echo "[$KEY] Sending data to iRODS ($SIZEMB MB)" echo "[$KEY] Sending data to iRODS ($SIZEMB MB)"
COMMAND="iput --retries 5 -T -K -f -X $RESIFDD_WORKDIR/${KEY}.restart $RESIFDD_WORKDIR/${KEY}.tar $KEY/staging.tar" COMMAND="iput --retries 5 -T -f -X $RESIFDD_WORKDIR/${KEY}.restart $RESIFDD_WORKDIR/${KEY}.tar $KEY/staging.tar"
start=$(date +%s) start=$(date +%s)
eval $COMMAND eval $COMMAND
IPUTRC=$? IPUTRC=$?
...@@ -77,6 +78,14 @@ irods_push(){ ...@@ -77,6 +78,14 @@ irods_push(){
else else
duration=$(($(date +%s)-$start)) duration=$(($(date +%s)-$start))
throughput=$(($SIZEMB / $duration )) throughput=$(($SIZEMB / $duration ))
# Check integrity.
# We do it separately from transfer because for big files it can be very long, and the network can cut
irods_sha=$(ichksum $KEY/staging.tar | awk -F':' '/sha2:/ {print $2; exit;}')
if [[ "$LOCAL_SHA" != "$irods_sha" ]]; then
echo "[$KEY] Error 012 distant file is corrupted (localsha $LOCAL_SHA irodssha $irods_sha). Rollback"
irods_rollback $KEY
zabbix_err "${KEY}:Error 012"
fi
echo "[$KEY] staging.tar data sent, let's commit everything on irods server" echo "[$KEY] staging.tar data sent, let's commit everything on irods server"
format_report $KEY $SIZEMB $(date +%Y-%m-%dT%H:%M:%S --date=@$start) $duration $throughput 'OK' >> $LOCAL_REPORT format_report $KEY $SIZEMB $(date +%Y-%m-%dT%H:%M:%S --date=@$start) $duration $throughput 'OK' >> $LOCAL_REPORT
irods_commit $KEY irods_commit $KEY
...@@ -95,6 +104,7 @@ irods_push(){ ...@@ -95,6 +104,7 @@ irods_push(){
# Argument is the distant directory to work with # Argument is the distant directory to work with
irods_rollback(){ irods_rollback(){
KEY=$1 KEY=$1
irm -f ${KEY}/staging.tar
echo "[$KEY] Rollback : try to recover latest.tar from previous" echo "[$KEY] Rollback : try to recover latest.tar from previous"
ils ${KEY}/previous.tar 2>/dev/null && ( ils ${KEY}/previous.tar 2>/dev/null && (
imv ${KEY}/previous.tar ${KEY}/latest.tar imv ${KEY}/previous.tar ${KEY}/latest.tar
...@@ -200,7 +210,7 @@ pack_and_send() { ...@@ -200,7 +210,7 @@ pack_and_send() {
fi fi
fi fi
# Send latest archive file to IRODS # Send latest archive file to IRODS
irods_push $KEY irods_push $KEY $local_sha
rm $RESIFDD_WORKDIR/$KEY* rm $RESIFDD_WORKDIR/$KEY*
} }
...@@ -280,7 +290,8 @@ else ...@@ -280,7 +290,8 @@ else
zabbix_err "${KEY}:Error 001" zabbix_err "${KEY}:Error 001"
exit 1 exit 1
fi fi
irods_push $KEY local_sha=$(sha256sum $RESIFDD_WORKDIR/$KEY.tar | awk '{print $1}' | xxd -r -p | base64)
irods_push $KEY $local_sha
echo "[$KEY] Dump terminated :" echo "[$KEY] Dump terminated :"
ils -l $KEY ils -l $KEY
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment