Skip to content

Fix incorrect reporting when fs_hash.sh fails#364

Merged
nishakm merged 1 commit intotern-tools:masterfrom
rnjudge:issue-263-fix-fs_hash-error-message
Aug 5, 2019
Merged

Fix incorrect reporting when fs_hash.sh fails#364
nishakm merged 1 commit intotern-tools:masterfrom
rnjudge:issue-263-fix-fs_hash-error-message

Conversation

@rnjudge
Copy link
Copy Markdown
Contributor

@rnjudge rnjudge commented Aug 2, 2019

Currently, if there is any failure in the fs_hash.sh script, the only
erro message that gets reported is:
WARNING - report - Cannot retrieve full image metadata.

It is common to see this warning message when attr is not installed in a
Linux environment or if you try to run the script natively on MacOS.
The current error message is not helpful for users trying to understand
the output file.

The following commit adapts the fs_hash.sh script to check for the
availability of the three central commands in the script: find,
sha256sum and getfattr before it runs. If any of these commands are
not available, the script will exit with a more helpful error message.

Finally, tern/utils/rootfs.py was modified to properly log the error
message from pipes.communicate().

Resolves #263

Signed-off-by: Rose Judge rjudge@vmware.com

@rnjudge
Copy link
Copy Markdown
Contributor Author

rnjudge commented Aug 2, 2019

Labeled this as WIP so @nishakm may review and provide feedback. Output of running Tern on a system without attr installed is:

2019-08-02 14:49:26,322 - DEBUG - rootfs - Running command: sudo /home/rjudge/ternenv/lib/python3.6/site-packages/tern/tools/fs_hash.sh /home/rjudge/ternenv/tern/temp/0477746f96c55ac74d949a55a3280d3af6b22d8a90e4a57f80abcaa133b2efce/contents
2019-08-02 14:49:26,418 - ERROR - rootfs - Command failed with:
'getfattr' command not hashed on system.
2019-08-02 14:49:26,433 - WARNING - report - Cannot retrieve full image metadata

@rnjudge rnjudge force-pushed the issue-263-fix-fs_hash-error-message branch 2 times, most recently from 87b1224 to 6aa3afe Compare August 5, 2019 16:47
@rnjudge rnjudge changed the title WIP: Fix incorrect reporting when fs_hash.sh fails Fix incorrect reporting when fs_hash.sh fails Aug 5, 2019
Currently, if there is any failure in the fs_hash.sh script, the only
erro message that gets reported is:
WARNING - report - Cannot retrieve full image metadata.

It is common to see this warning message when attr is not installed in a
Linux environment or if you try to run the script natively on MacOS.
The current error message is not helpful for users trying to understand
the output file.

The following commit adapts the fs_hash.sh script to check for the
availability of the three central commands in the script: find,
sha256sum and getfattr before it runs. If any of these commands are
not available, the script will exit with a more helpful error message.

Finally, tern/utils/rootfs.py was modified to properly log the error
message from pipes.communicate().

Resolves tern-tools#263

Signed-off-by: Rose Judge <rjudge@vmware.com>
@rnjudge rnjudge force-pushed the issue-263-fix-fs_hash-error-message branch from 6aa3afe to 6569358 Compare August 5, 2019 17:07
@rnjudge
Copy link
Copy Markdown
Contributor Author

rnjudge commented Aug 5, 2019

This PR is now ready for formal review.

@nishakm
Copy link
Copy Markdown
Contributor

nishakm commented Aug 5, 2019

Looks good to me. Reviewed test with @rnjudge on a call. Merging now.

@nishakm nishakm merged commit 0505b3d into tern-tools:master Aug 5, 2019
@rnjudge rnjudge deleted the issue-263-fix-fs_hash-error-message branch August 28, 2019 15:24
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 this pull request may close these issues.

Incorrect reporting with failure in running fs_hash.sh

2 participants