fix: guard inotify sysctl limit updates against fact retrieval errors

This commit is contained in:
Omid Zamani
2026-01-01 22:57:52 +01:00
parent 740574fa1f
commit 58d82f04b5

View File

@@ -118,18 +118,24 @@ def _configure_dovecot(config: Config, debug: bool = False) -> (bool, bool):
# as per https://doc.dovecot.org/configuration_manual/os/
# it is recommended to set the following inotify limits
for name in ("max_user_instances", "max_user_watches"):
key = f"fs.inotify.{name}"
if host.get_fact(Sysctl)[key] > 65535:
# Skip updating limits if already sufficient
# (enables running in incus containers where sysctl readonly)
continue
server.sysctl(
name=f"Change {key}",
key=key,
value=65535,
persist=True,
)
try:
sysctls = host.get_fact(Sysctl)
except Exception:
sysctls = None
if sysctls:
for name in ("max_user_instances", "max_user_watches"):
key = f"fs.inotify.{name}"
if sysctls.get(key, 0) > 65535:
# Skip updating limits if already sufficient
# (enables running in incus containers where sysctl readonly)
continue
server.sysctl(
name=f"Change {key}",
key=key,
value=65535,
persist=True,
)
timezone_env = files.line(
name="Set TZ environment variable",