Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packaging/greenboot/microshift-running-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ PODS_CT_LIST=(2 1 1 2
# shellcheck source=packaging/greenboot/functions.sh
source /usr/share/microshift/functions/greenboot.sh

# Set the term handler to convert exit code to 1
trap 'return_failure' TERM

# Set the exit handler to log the exit status
trap 'script_exit' EXIT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is script_exit called when TERM arrives?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, here's an example:

[root@microshift-dev microshift]# /etc/greenboot/check/required.d/40_microshift_running_check.sh
STARTED
GRUB boot variables:
boot_success=1
boot_indeterminate=0
Greenboot variables:
None
error: loading sysroot: opendir(ostree/repo): No such file or directory
The ostree status:

Waiting 300s for MicroShift service to be active and not failed
The microshift.service systemd unit is failed. Terminating...
FAILURE
[root@microshift-dev microshift]# echo $?
1


# The term handler to override the default behavior and have a uniform and
# homogeneous exit code in all controlled situations.
function return_failure() {
exit 1
}

# The script exit handler logging the FAILURE or FINISHED message depending
# on the exit status of the last command
#
Expand Down