Skip to content

Commit

Permalink
fix: ensure the launcher always mounts cache dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau committed Dec 1, 2023
1 parent 52c8f75 commit 7074e73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion craft_providers/lxd/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ def _create_instance(
instance.restart()
else:
instance.start()
base_configuration.wait_until_ready(executor=instance)
# Warmup the instance to ensure we have everything set up.
# There are cases where setup won't do everything to the base instance that
# warmup does to the final instance (such as mounting cache directories).
base_configuration.warmup(executor=instance)


def _ensure_project_exists(
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/lxd/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_launch_no_base_instance(
assert mock_base_configuration.mock_calls == [
call.get_command_environment(),
call.setup(executor=fake_instance),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down Expand Up @@ -248,7 +248,7 @@ def test_launch_use_base_instance(
call.get_command_environment(),
call.get_command_environment(),
call.setup(executor=fake_base_instance, mount_cache=False),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down Expand Up @@ -528,7 +528,7 @@ def test_launch_existing_base_instance_invalid(
call.get_command_environment(),
call.get_command_environment(),
call.setup(executor=fake_base_instance, mount_cache=False),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down Expand Up @@ -609,7 +609,7 @@ def test_launch_all_opts(
assert mock_base_configuration.mock_calls == [
call.get_command_environment(),
call.setup(executor=fake_instance),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down Expand Up @@ -703,7 +703,7 @@ def test_launch_create_project(
assert mock_base_configuration.mock_calls == [
call.get_command_environment(),
call.setup(executor=fake_instance),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down Expand Up @@ -846,7 +846,7 @@ def test_launch_with_existing_instance_incompatible_with_auto_clean(
call.get_command_environment(),
call.warmup(executor=fake_instance),
call.setup(executor=fake_instance),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down Expand Up @@ -940,7 +940,7 @@ def test_launch_with_existing_ephemeral_instance(
assert mock_base_configuration.mock_calls == [
call.get_command_environment(),
call.setup(executor=fake_instance),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down Expand Up @@ -1134,7 +1134,7 @@ def test_use_snapshots_deprecated(
call.get_command_environment(),
call.get_command_environment(),
call.setup(executor=fake_base_instance, mount_cache=False),
call.wait_until_ready(executor=fake_instance),
call.warmup(executor=fake_instance),
]


Expand Down

0 comments on commit 7074e73

Please sign in to comment.