Skip to content

Commit

Permalink
fix: don't start the fetch-service in managed mode (#542)
Browse files Browse the repository at this point in the history
Fixes #537
  • Loading branch information
tigarmo authored Oct 23, 2024
1 parent f2a4bec commit 6efe544
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion craft_application/services/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def setup(self) -> None:
"and still in development."
)

self._fetch_process = fetch.start_service()
self._fetch_process = fetch.start_service()

def create_session(self, instance: craft_providers.Executor) -> dict[str, str]:
"""Create a new session.
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Application

- ``AppCommand`` subclasses now will always receive a valid ``app_config``
dict.
- Fixes a bug where the fetch-service integration would try to spawn the
fetch-service process when running in managed mode.

Commands
========
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/services/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,13 @@ def test_warning_experimental(mocker, fetch_service, run_on_host, emitter):
warning_emitted = call("message", warning) in emitter.interactions

assert warning_emitted == run_on_host


def test_setup_managed(mocker, fetch_service):
"""The fetch-service process should only be checked/started when running on the host."""
mock_start = mocker.patch.object(fetch, "start_service")
mocker.patch.object(ProviderService, "is_managed", return_value=True)

fetch_service.setup()

assert not mock_start.called

0 comments on commit 6efe544

Please sign in to comment.