mirror of
https://github.com/hashicorp/vault.git
synced 2026-06-08 16:24:51 -04:00
enos(cloud-init): fix synchronize-repos (#30013)
`$?` in bash is wonky. When you evaluate an expression in an `if` statement the `$?` variable is only set the actual value in blocks scoped in the statement. Therefore, since we rely on it in synchronize-repos we have to evaluate the rest of the function in a scope of that statement. Signed-off-by: Ryan Cragun <me@ryan.ec>
This commit is contained in:
parent
8d0743c16d
commit
77e48e837e
1 changed files with 24 additions and 23 deletions
|
|
@ -107,30 +107,31 @@ synchronize_repos() {
|
|||
wait_for_cloud_init() {
|
||||
if output=$(sudo cloud-init status --wait); then
|
||||
return 0
|
||||
else
|
||||
res=$?
|
||||
case $res in
|
||||
2)
|
||||
{
|
||||
echo "WARNING: cloud-init did not complete successfully but recovered."
|
||||
echo "Exit code: $res"
|
||||
echo "Output: $output"
|
||||
echo "Here are the logs for the failure:"
|
||||
cat /var/log/cloud-init-*
|
||||
} 1>&2
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
{
|
||||
echo "cloud-init did not complete successfully."
|
||||
echo "Exit code: $res"
|
||||
echo "Output: $output"
|
||||
echo "Here are the logs for the failure:"
|
||||
cat /var/log/cloud-init-*
|
||||
} 1>&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
res=$?
|
||||
case $res in
|
||||
2)
|
||||
{
|
||||
echo "WARNING: cloud-init did not complete successfully but recovered."
|
||||
echo "Exit code: $res"
|
||||
echo "Output: $output"
|
||||
echo "Here are the logs for the failure:"
|
||||
cat /var/log/cloud-init-*
|
||||
} 1>&2
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
{
|
||||
echo "cloud-init did not complete successfully."
|
||||
echo "Exit code: $res"
|
||||
echo "Output: $output"
|
||||
echo "Here are the logs for the failure:"
|
||||
cat /var/log/cloud-init-*
|
||||
} 1>&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Wait for cloud-init if it exists
|
||||
|
|
|
|||
Loading…
Reference in a new issue