Bug #14957
closedImage-based provisioning failing due to switching to 'sh' in 14131
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.
Updated by Greg Sutcliffe over 8 years ago
- Related to Bug #14131: Libvirt image provision fails on FreeBSD without bash added
Updated by Dominic Cleal over 8 years ago
- Translation missing: en.field_release set to 155
Updated by Karli Sjöberg over 8 years ago
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
Updated by Dominic Cleal over 8 years ago
The tee is quite useful to get output from the script back to Foreman, which logs it.
Updated by Greg Sutcliffe over 8 years ago
Can we look at @results to calculate the exit status, rather than relying on PIPESTATUS?
Updated by The Foreman Bot over 8 years ago
- Status changed from New to Ready For Testing
- Assignee set to Greg Sutcliffe
- Pull request https://github.com/theforeman/foreman/pull/3504 added
Updated by Greg Sutcliffe over 8 years ago
- 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.
Updated by Karli Sjöberg over 8 years ago
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
Updated by Greg Sutcliffe over 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset a6363a50932a0b9b91e6aad1cb22e0308ccc9c33.