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

fix: added packer plugin section & improved error handling logic #26

Merged
merged 5 commits into from
Nov 21, 2023

Conversation

lennessyy
Copy link
Contributor

Describe the Change

This PR added the packer plugin section to the address a build error arising from a packer feature deprecation. Also improves the bash script error handling logic so that the build process does not error out when it shouldn't.

Review Changes

🎫 Jira Ticket

@lennessyy lennessyy requested a review from a team as a code owner November 21, 2023 01:00
@lennessyy lennessyy requested review from karl-cardenas-coding, addetz and ritawatson and removed request for a team November 21, 2023 01:00
Copy link
Collaborator

@karl-cardenas-coding karl-cardenas-coding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor concern but not a show stopper.


if [ -z "$CACHE_EXISTS" ]; then
if [[ $CACHE_OUTPUT == *"/packer_cache was not found"* ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit too brittle. I thought we were using $? to check the command's exit code 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exit code approach unfortunately doesn't work as it would just generically return a 1 when it cannot find packer cache. Nor does the error itself have an error code :/ :

69879bff6947:/# govc datastore.ls -ds=$vcenter_datastore /packer_cache
govc: file [vsanDatastore2]/packer_cache was not found
69879bff6947:/# echo $?
1

I also tried listing the output of govc datastore.ls -ds=$vcenter_datastore and see if we can find packer pache in the output, but that doesn't work either because it does not return the actual directory names and only UIDs:

govc datastore.ls -ds=$vcenter_datastore
a34c2465-4c1b-0503-107a-0cc47a7e0192
16643364-3f04-2d05-33ba-0cc47a92e4f2
fd763664-3f6d-d105-bc5e-0cc47a92e4f2

I can't really think another way now to distinguish a not found error versus other errors besides using the error message now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to have the user access the datastore first and if they have problem listing directories then it must be other issues. and if they can list directories but just cannot find the packer cache directory, then it must be that the directory doesn't exist.

@lennessyy lennessyy merged commit d857c12 into main Nov 21, 2023
3 checks passed
@lennessyy lennessyy deleted the packer-plugin-fix branch November 21, 2023 21:46
Copy link

🎉 This PR is included in version 1.0.10 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants