Skip to content

Commit

Permalink
cluster-launch-installer-e2e: Wait on the create process ID
Browse files Browse the repository at this point in the history
From the POSIX spec [1]:

  If the wait utility is invoked with no operands, it shall wait until
  all process IDs known to the invoking shell have terminated and exit
  with a zero exit status.

  If one or more pid operands are specified that represent known
  process IDs, the wait utility shall wait until all of them have
  terminated. If one or more pid operands are specified that represent
  unknown process IDs, wait shall treat them as if they were known
  process IDs that exited with exit status 127. The exit status
  returned by the wait utility shall be the exit status of the process
  requested by the last pid operand.

Because the bare 'wait' from d862f6f (cluster-launch-installer-e2e:
Restore EXIT and TERM signal handlers, 2018-10-17, openshift#1957) contained no
PID arguments, it was returning zero even when the install command
failed.  Here's a simple example demonstrating the effect:

  $ false &
  $ wait
  $ echo $?
  0

With this command, we use $! to get the installer's process PID [2],
and pass that to 'wait'.  Now the wait call will exit with the
installer exit status, and because it's the last command in the shell
script, the script will also exit with the installer exit status.
Here's a simple example demonstrating the new approach:

  $ false &
  $ wait "$!"
  $ echo $?
  1

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wait.html
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02
  • Loading branch information
wking committed Oct 26, 2018
1 parent 7495171 commit 713037a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ objects:
export _CI_ONLY_STAY_AWAY_OPENSHIFT_INSTALL_AWS_USER_TAGS="{\"expirationDate\": \"$(date -d '4 hours' --iso=minutes --utc)\"}"
/bin/openshift-install --dir=/tmp/artifacts/installer --log-level=debug cluster &
wait
wait "$!"
# Performs cleanup of all created resources
- name: teardown
Expand Down

0 comments on commit 713037a

Please sign in to comment.