Skip to content

Commit e609b9c

Browse files
committed
improve error when a root is not defined in non-hostonly mode
because autodetection is diabled, it must be manually defined. add a better error message for this case Signed-off-by: Zen <[email protected]>
1 parent 9b814da commit e609b9c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ugrd/fs/mounts.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,14 @@ def mount_root(self) -> str:
997997

998998
def export_mount_info(self) -> None:
999999
"""Exports mount info based on the config to /run/MOUNTS_ROOT_{option}"""
1000-
self["exports"]["MOUNTS_ROOT_SOURCE"] = _get_mount_str(self, self["mounts"]["root"])
1000+
try:
1001+
self["exports"]["MOUNTS_ROOT_SOURCE"] = _get_mount_str(self, self["mounts"]["root"])
1002+
except ValueError as e:
1003+
self.logger.critical(f"Failed to get source info for the root mount: {e}")
1004+
if not self["hostonly"]:
1005+
self.logger.info("Root mount infomrmation can be defined under the '[mounts.root]' section.")
1006+
raise ValidationError("Root mount source information is not set, when hostonly mode is disabled, it must be manually defined.")
1007+
raise ValidationError("Root mount source information is not set even though hostonly mode is enabled. Please report a bug.")
10011008
self["exports"]["MOUNTS_ROOT_TYPE"] = self["mounts"]["root"].get("type", "auto")
10021009
self["exports"]["MOUNTS_ROOT_OPTIONS"] = ",".join(self["mounts"]["root"]["options"])
10031010
self["exports"]["MOUNTS_ROOT_TARGET"] = self["mounts"]["root"]["destination"]

0 commit comments

Comments
 (0)