From e13b78fcefa07a8e2d2cf21c424e3bed11e18255 Mon Sep 17 00:00:00 2001 From: "Chi Song (from Dev Box)" Date: Thu, 3 Oct 2024 16:25:11 -0700 Subject: [PATCH] fix LISA exception on None capability. None capability happens on preparation failures. It should return False, instead of assertion failure. --- lisa/schema.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lisa/schema.py b/lisa/schema.py index 43ca077b5..986fbfe71 100644 --- a/lisa/schema.py +++ b/lisa/schema.py @@ -367,6 +367,12 @@ class FeatureSettings( return feature def check(self, capability: Any) -> search_space.ResultReason: + if not capability: + return search_space.ResultReason( + result=False, + reasons=["capability is None, it may be caused by preparation failed."], + ) + assert isinstance(capability, FeatureSettings), f"actual: {type(capability)}" # default FeatureSetting is a place holder, nothing to do. result = search_space.ResultReason() @@ -584,6 +590,12 @@ class DiskOptionSettings(FeatureSettings): return super().__hash__() def check(self, capability: Any) -> search_space.ResultReason: + if not capability: + return search_space.ResultReason( + result=False, + reasons=["capability is None, it may be caused by preparation failed."], + ) + result = super().check(capability) result.merge( @@ -763,6 +775,12 @@ class NetworkInterfaceOptionSettings(FeatureSettings): ) def check(self, capability: Any) -> search_space.ResultReason: + if not capability: + return search_space.ResultReason( + result=False, + reasons=["capability is None, it may be caused by preparation failed."], + ) + assert isinstance( capability, NetworkInterfaceOptionSettings ), f"actual: {type(capability)}"