1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Description: Reduce the timeout to zero seconds when running in a container (LP: #1760173)
When inside a lxd container with zfs storage, zfs list or zpool status
appears to hang, no output for 10 seconds. Check if we are inside a
container and set the timeout to zero in this specific case.
Origin: ubuntu
Forwarded: not-needed
Bug: https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1760173
--- a/lib/libzfs/os/linux/libzfs_util_os.c
+++ b/lib/libzfs/os/linux/libzfs_util_os.c
@@ -110,6 +110,16 @@
const char *timeout_str = getenv("ZFS_MODULE_TIMEOUT");
int seconds = 10;
+
+ /*
+ * If inside a container, set the timeout to zero (LP: #1760173),
+ * however, this can be over-ridden by ZFS_MODULE_TIMEOUT just
+ * in case the user explicitly wants to set the timeout for some
+ * reason just for backward compatibilty
+ */
+ if (access("/run/systemd/container", R_OK) == 0)
+ seconds = 0;
+
if (timeout_str)
seconds = MIN(strtol(timeout_str, NULL, 0), 600);
struct itimerspec timeout = {.it_value.tv_sec = MAX(seconds, 0)};
|