Project

General

Profile

Bug #14957

Image-based provisioning failing due to switching to 'sh' in 14131

Added by Greg Sutcliffe almost 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Orchestration
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

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 issues

Related to Foreman - Bug #14131: Libvirt image provision fails on FreeBSD without bashClosed2016-03-10

Associated revisions

Revision a6363a50 (diff)
Added by Greg Sutcliffe almost 4 years ago

Fixes #14957 - Use a temporary status file to store exit status

Revision 73bc84a6 (diff)
Added by Greg Sutcliffe almost 4 years ago

Fixes #14957 - Use a temporary status file to store exit status

(cherry picked from commit a6363a50932a0b9b91e6aad1cb22e0308ccc9c33)

History

#1 Updated by Greg Sutcliffe almost 4 years ago

  • Related to Bug #14131: Libvirt image provision fails on FreeBSD without bash added

#2 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) set to 155

#3 Updated by Karli Sjöberg almost 4 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

#4 Updated by Dominic Cleal almost 4 years ago

The tee is quite useful to get output from the script back to Foreman, which logs it.

#5 Updated by Greg Sutcliffe almost 4 years ago

Can we look at @results to calculate the exit status, rather than relying on PIPESTATUS?

#6 Updated by The Foreman Bot almost 4 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

#7 Updated by Greg Sutcliffe almost 4 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.

#8 Updated by Karli Sjöberg almost 4 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

#9 Updated by Greg Sutcliffe almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF