From eee603294f120cf98696351433e7e6dbc9a3dbc2 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Wed, 23 Mar 2022 18:03:00 -0500 Subject: Fix cloud-init status --wait when no datasource found (#1349) * Fix cloud-init status --wait when no datasource found In 0de7acb1, we modified status checks to wait until we get an "enabled" or "disabled" file from ds-identiy. ds-identify never outputs a "disabled" file, so "status --wait" will wait indefinitely if no datasource is found. LP: #1966085 --- systemd/cloud-init-generator.tmpl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'systemd') diff --git a/systemd/cloud-init-generator.tmpl b/systemd/cloud-init-generator.tmpl index db964825..6c4a66d1 100644 --- a/systemd/cloud-init-generator.tmpl +++ b/systemd/cloud-init-generator.tmpl @@ -9,6 +9,7 @@ LOG_F="/run/cloud-init/cloud-init-generator.log" ENABLE="enabled" DISABLE="disabled" RUN_ENABLED_FILE="$LOG_D/$ENABLE" +RUN_DISABLED_FILE="$LOG_D/$DISABLE" CLOUD_TARGET_NAME="cloud-init.target" # lxc sets 'container', but lets make that explicitly a global CONTAINER="${container}" @@ -151,6 +152,10 @@ main() { "ln $CLOUD_SYSTEM_TARGET $link_path" fi fi + if [ -e $RUN_DISABLED_FILE ]; then + debug 1 "removing $RUN_DISABLED_FILE and creating $RUN_ENABLED_FILE" + rm -f $RUN_DISABLED_FILE + fi : > "$RUN_ENABLED_FILE" elif [ "$result" = "$DISABLE" ]; then if [ -f "$link_path" ]; then @@ -164,8 +169,10 @@ main() { debug 1 "already disabled: no change needed [no $link_path]" fi if [ -e "$RUN_ENABLED_FILE" ]; then + debug 1 "removing $RUN_ENABLED_FILE and creating $RUN_DISABLED_FILE" rm -f "$RUN_ENABLED_FILE" fi + : > "$RUN_DISABLED_FILE" else debug 0 "unexpected result '$result' 'ds=$ds'" ret=3 -- cgit v1.2.1