-
Notifications
You must be signed in to change notification settings - Fork 535
Description
Currently there is a not correct "if-then" statement in the script to update the metadata schema in solr, see https://github.com/IQSS/dataverse/blob/develop/conf/solr/8.8.1/updateSchemaMDB.sh
### Fail gracefull if Dataverse is not ready yet.
if [[ "`wc -l ${TMPFILE}`" < "3" ]]; then
echo "Dataverse responded with empty file. When running on K8s: did you bootstrap yet?"
exit 123
fi
The output of wc -l ${TMPFILE} will be generated as a string with 2 values - LINE_COUNT and ${TMPFILE}, what will be wrong interpreted in the comparison with "3" - as a comparison of strings and not as a comparison of digits. This bug was found during the testing of large amount of metadata in the dataverse instance. E.g. if ${TMPFILE} has more than 1000 lines, the output of wc -l ${TMPFILE} will be 1000 ${TMPFILE}, where only the first digit "1" (not the complete "1000") will be compared with "3", what as a result activates wrongly the echo message and exit command.
As a solution could be the code:
### Fail gracefull if Dataverse is not ready yet.
if [[ "`cat ${TMPFILE} | wc -l`" -lt "3" ]]; then
echo "Dataverse responded with empty file. When running on K8s: did you bootstrap yet?"
exit 123
fi
or
### Fail gracefull if Dataverse is not ready yet.
if [[ "`<${TMPFILE} wc -l`" -lt "3" ]]; then
echo "Dataverse responded with empty file. When running on K8s: did you bootstrap yet?"
exit 123
fi
based on these posts about "wc -l" and comparison operators.