Project

General

Profile

Actions

Bug #14957

closed

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

Added by Greg Sutcliffe over 8 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Orchestration
Target version:
Difficulty:
Triaged:
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 1 (0 open1 closed)

Related to Foreman - Bug #14131: Libvirt image provision fails on FreeBSD without bashClosedKarli Sjöberg03/10/2016Actions
Actions #1

Updated by Greg Sutcliffe over 8 years ago

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

Updated by Dominic Cleal over 8 years ago

  • Translation missing: en.field_release set to 155
Actions #3

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

Actions #4

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.

Actions #5

Updated by Greg Sutcliffe over 8 years ago

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

Actions #6

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
Actions #7

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.

Actions #8

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

Actions #9

Updated by Greg Sutcliffe over 8 years ago

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

Also available in: Atom PDF