diff --git a/craft_providers/lxd/lxd.py b/craft_providers/lxd/lxd.py index 696529bb..b96fad26 100644 --- a/craft_providers/lxd/lxd.py +++ b/craft_providers/lxd/lxd.py @@ -88,9 +88,10 @@ def version(self) -> str: """Query LXD version. The version is of the format: - .[.] + .[.] [LTS] Version examples: + - 5.21.0 LTS - 4.13 - 4.0.5 - 2.0.12 @@ -107,7 +108,14 @@ def version(self) -> str: details=details_from_called_process_error(error), ) from error - return proc.stdout.strip() + version_string = proc.stdout.strip() + if version_string: + return version_string.split()[0] + + raise LXDError( + "Failed to parse LXD version.", + details=f"Version data returned: {version_string!r}", + ) def wait_ready( self, diff --git a/tests/unit/lxd/test_lxd.py b/tests/unit/lxd/test_lxd.py index 69f6f0e0..ec6f2b56 100644 --- a/tests/unit/lxd/test_lxd.py +++ b/tests/unit/lxd/test_lxd.py @@ -80,6 +80,7 @@ def test_init_error(fake_process): ("4.0", True), ("4.1.4", True), ("4.10", True), + ("5.21.0 LTS", True), ], ) def test_is_supported_version(fake_process, version, compatible):