From 14ba1498bfded74b112904c9b5aecc1f36401f9e Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 29 Jun 2022 15:53:55 +0200 Subject: [PATCH] util: reduce systemd related errors while mounting There are regular reports that identify a non-error as the cause of failures. The Kubernetes mount-utils package has detection for systemd based environments, and if systemd is unavailable, the following error is logged: Cannot run systemd-run, assuming non-systemd OS systemd-run output: System has not been booted with systemd as init system (PID 1). Can't operate. Failed to create bus connection: Host is down, failed with: exit status 1 Because of the `failed` and `exit status 1` error message, users might assume that the mounting failed. This does not need to be the case. The container-images that the Ceph-CSI projects provides, do not use systemd, so the error will get logged with each mount attempt. By using the newer MountSensitiveWithoutSystemd() function from the mount-utils package where we can, the number of confusing logs get reduced. Signed-off-by: Niels de Vos --- internal/rbd/nodeserver.go | 2 +- internal/util/util.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/rbd/nodeserver.go b/internal/rbd/nodeserver.go index 057cf9e44..0e13cb787 100644 --- a/internal/rbd/nodeserver.go +++ b/internal/rbd/nodeserver.go @@ -773,7 +773,7 @@ func (ns *NodeServer) mountVolumeToStagePath( if isBlock { opt = append(opt, "bind") - err = diskMounter.Mount(devicePath, stagingPath, fsType, opt) + err = diskMounter.MountSensitiveWithoutSystemd(devicePath, stagingPath, fsType, opt, nil) } else { err = diskMounter.FormatAndMount(devicePath, stagingPath, fsType, opt) } diff --git a/internal/util/util.go b/internal/util/util.go index b9d7ea173..857b7b19d 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -330,7 +330,7 @@ func ReadMountInfoForProc(proc string) ([]mount.MountInfo, error) { func Mount(source, target, fstype string, options []string) error { dummyMount := mount.New("") - return dummyMount.Mount(source, target, fstype, options) + return dummyMount.MountSensitiveWithoutSystemd(source, target, fstype, options, nil) } // MountOptionsAdd adds the `add` mount options to the `options` and returns a