fix LISA exception on None capability.

None capability happens on preparation failures. It should return False, instead of assertion failure.
This commit is contained in:
Chi Song (from Dev Box) 2024-10-03 16:25:11 -07:00 коммит произвёл LiliDeng
Родитель 125817aff0
Коммит e13b78fcef
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -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)}"