Skip to content

Commit

Permalink
Merge pull request #319 from thatmidwesterncoder/handle_cloudinit_rec…
Browse files Browse the repository at this point in the history
…overable_failure

handle cloud-init recoverable failure exit status by swallowing specific exit code
  • Loading branch information
thatmidwesterncoder authored Jan 8, 2025
2 parents aa18ee8 + 8559507 commit 50f36fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libmachine/provision/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ func checkDaemonUp(p Provisioner, dockerPort int) func() bool {

// waitForCloudInit runs `cloud-init status --wait` on the node in order to wait for the node to be ready before
// continuing execution.
// it also swallows the "bad" exit code that can be returned but is in reality just alerting us that there were benign
// errors during cloud-init: https://docs.cloud-init.io/en/24.1/explanation/failure_states.html#recoverable-failure
func waitForCloudInit(p Provisioner) error {
_, err := p.SSHCommand("sudo cloud-init status --wait")
_, err := p.SSHCommand(`sudo bash -c 'cloud-init status --wait >/dev/null || if [ $? == 2 ]; then true ; fi'`)
if err != nil {
return fmt.Errorf("failed to wait for cloud-init: %w", err)
}
Expand Down

0 comments on commit 50f36fa

Please sign in to comment.