Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wait for cloud-init.service to fully activate #3020

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion lib/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ def _wait_for_cloud_config():
LOG.debug("waiting for cloud-config.service to finish")
for i in range(WAIT_FOR_CLOUD_CONFIG_POLL_TIMES + 1):
state = system.get_systemd_unit_active_state("cloud-config.service")
ci_state = system.get_systemd_unit_active_state("cloud-init.service")
LOG.debug("cloud-config.service state: %r", state)
if state is not None and state == "activating":
LOG.debug("cloud-init.service state: %r", ci_state)
# if cloud-config.service is not yet activating but cloud-init is
# running, wait for cloud-config to start
if state is not None and (
state == "activating"
or (
state == "inactive"
and ci_state is not None
and (ci_state == "activating" or ci_state == "active")
)
):
if i < WAIT_FOR_CLOUD_CONFIG_POLL_TIMES:
LOG.debug(
"cloud-config.service is activating. "
Expand Down
29 changes: 23 additions & 6 deletions uaclient/tests/test_lib_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,41 @@ class TestWaitForCloudConfig:
(
# not activating
(
["active"],
["active"] * 2,
[],
),
# inactive (all cloud-init)
(
["inactive"],
["inactive"] * 2,
[],
),
(
[None],
[None] * 2,
[],
),
# activating, then finishes
# cloud-config activating, then finishes
# cloud-init is active
(
(["activating"] * 11) + ["active"],
(["activating", "active"] * 11) + ["active"] * 2,
[mock.call(WAIT_FOR_CLOUD_CONFIG_SLEEP_TIME)] * 11,
),
(
(["activating"] * 11) + ["failed"],
(["activating", "active"] * 11) + ["failed"] + ["active"],
[mock.call(WAIT_FOR_CLOUD_CONFIG_SLEEP_TIME)] * 11,
),
# inactive cloud-config, active cloud-init
(
(["inactive", "active"] * 6)
+ (["activating", "active"] * 5)
+ ["active"] * 2,
[mock.call(WAIT_FOR_CLOUD_CONFIG_SLEEP_TIME)] * 11,
),
# inactive cloud-config, activating cloud-init
(
(["inactive", "activating"] * 2)
+ (["inactive", "active"] * 4)
+ (["activating", "active"] * 5)
+ ["active"] * 2,
[mock.call(WAIT_FOR_CLOUD_CONFIG_SLEEP_TIME)] * 11,
),
# still activating after polling maximum times
Expand Down
Loading