From 855950712f894827186d53bf54a62f49fd2b1403 Mon Sep 17 00:00:00 2001 From: Jacob Lindgren Date: Mon, 16 Dec 2024 13:12:55 -0600 Subject: [PATCH] handle cloud-init recoverable failure exit status by swallowing specific exit code --- libmachine/provision/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libmachine/provision/utils.go b/libmachine/provision/utils.go index aabdc1ecf2..a2d6199c68 100644 --- a/libmachine/provision/utils.go +++ b/libmachine/provision/utils.go @@ -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) }