Bug #14957
closed
Image-based provisioning failing due to switching to 'sh' in 14131
Added by Greg Sutcliffe over 8 years ago.
Updated over 6 years ago.
Description
My image-based provisioning is currently failing. With a finish template of "true\n" I get
2016-05-08T20:58:49 [app] [W] Failed to launch script on oactest687.elysium.emeraldreverie.org: ERF42-0453 [Foreman::Exception]: Provision script had a non zero exit
| Foreman::Exception: ERF42-0453 [Foreman::Exception]: Provision script had a non zero exit
Switching to debug logs, these seems to be due to the change to 'sh' from 'bash' in 14131:
2016-05-08T20:58:49 [app] [D] about to execute sh -c '(chmod 0701 ./bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408 && ./bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408) 2>&1 | tee bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408.log; exit ${PIPESTATUS[0]}'
2016-05-08T20:58:49 [app] [D] sh: 1: Bad substitution
I guess I'm hitting this because Jessie links /bin/sh to Dash, not Bash, and PIPESTATUS is a Bash-specific thing. Changing this back to Bash clearly fixes the issue, but we should probably think about a sh-compatible way to do this.
- Related to Bug #14131: Libvirt image provision fails on FreeBSD without bash added
- Translation missing: en.field_release set to 155
Seeing how this is "my fault", I´m just spitbolling here and thinking why not just simplify it down to:
sh -c '(chmod 0701 ./bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408 && ./bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408) > bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408.log 2>&1'
?
/K
The tee is quite useful to get output from the script back to Foreman, which logs it.
Can we look at @results to calculate the exit status, rather than relying on PIPESTATUS?
- Status changed from New to Ready For Testing
- Assignee set to Greg Sutcliffe
- Pull request https://github.com/theforeman/foreman/pull/3504 added
- Assignee deleted (
Greg Sutcliffe)
@results won't work, so I've proposed a patch using a temporary file to store the exit status. I'll try to test later today.
OK, keep 'tee'. Found this:
[[http://stackoverflow.com/a/1221844]]
So the adaptation I propose looks like this:
sh -c 'TEMP_DIR=$(mktemp -d); mkfifo "${TEMP_DIR}/pipe"; tee /tmp/bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408.log < "${TEMP_DIR}/pipe" & (chmod 0701 /tmp/bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408 && /tmp/bootstrap-cf49f50f-7c60-46c4-ab0d-c833ec1d8408) > "${TEMP_DIR}/pipe"; EXIT_CODE=$?; rm -rf ${TEMP_DIR}; exit ${EXIT_CODE}'
Greg, is this similar to what you were thinking?
/K
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Also available in: Atom
PDF