Skip to content

cluster-launch-installer-e2e: Wait on the create process ID #2031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2018

Conversation

wking
Copy link
Member

@wking wking commented Oct 26, 2018

Builds on #2030; review that first.

From the POSIX spec:

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 (#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, 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

/assign @abhinavdahiya

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
@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 26, 2018
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 26, 2018
@wking wking force-pushed the wait-with-an-operand branch from 0c4de85 to 713037a Compare October 26, 2018 18:04
@abhinavdahiya
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 26, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 8ffbe63 into openshift:master Oct 26, 2018
@openshift-ci-robot
Copy link
Contributor

@wking: Updated the prow-job-cluster-launch-installer-e2e configmap using the following files:

  • key cluster-launch-installer-e2e.yaml using file ci-operator/templates/openshift/installer/cluster-launch-installer-e2e.yaml

In response to this:

Builds on #2030; review that first.

From the POSIX spec:

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 (#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, 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

/assign @abhinavdahiya

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants