Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snap build job doesn't properly fail on incorrect shas of downloaded snaps #517

Open
anonymouse64 opened this issue Nov 7, 2019 · 1 comment

Comments

@anonymouse64
Copy link
Contributor

See for example the log from this job:

22:26:13 �[91msha512sum: WARNING: 1 computed checksum did NOT match
22:26:13 �[0mcore.snap: FAILED
22:26:13 Parallel unsquashfs: Using 4 processors
22:26:13 �[91mRead on filesystem failed because EOF
22:26:13 read_uids_guids: failed to read id index table
22:26:13 FATAL ERROR:failed to uid/gid table
22:26:13 �[0mcore18.snap: OK

the job still goes on to try to run and fails for other unknown reasons.

@anonymouse64
Copy link
Contributor Author

Probably somewhere in this block of code we are not failing on non-0 exit codes:

RUN apt-get update && \
apt-get dist-upgrade --yes && \
apt-get install --yes \
curl sudo jq squashfs-tools && \
for thesnap in core core18 snapcraft; do \
dlUrl=$(curl -s -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $ARCH" "https://api.snapcraft.io/api/v1/snaps/details/$thesnap" | jq '.download_url' -r); \
dlSHA=$(curl -s -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $ARCH" "https://api.snapcraft.io/api/v1/snaps/details/$thesnap" | jq '.download_sha512' -r); \
curl -s -L $dlUrl --output $thesnap.snap; \
echo "$dlSHA $thesnap.snap" > $thesnap.snap.sha512; \
sha512sum -c $thesnap.snap.sha512; \
mkdir -p /snap/$thesnap && unsquashfs -n -d /snap/$thesnap/current $thesnap.snap && rm $thesnap.snap; \
done && \
apt remove --yes --purge curl jq squashfs-tools && \
apt-get autoclean --yes && \
apt-get clean --yes

probably just a set -e at the start would do the trick

anonymouse64 added a commit to anonymouse64/ci-management that referenced this issue Jul 13, 2020
The previous behavior would not actually fail the build setup if for example the
SHA's didn't match, but now if the SHA's don't match, sha512sum will exit
non-zero and using && results in the whole command failing.

We also should delete the sha512 file as well, it is not needed during the
build.

Fixes: edgexfoundry#517

Signed-off-by: Ian Johnson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant