Skip to content

Commit

Permalink
util: reduce systemd related errors while mounting
Browse files Browse the repository at this point in the history
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 <ndevos@redhat.com>
  • Loading branch information
nixpanic authored and mergify[bot] committed Jul 4, 2022
1 parent a1ed620 commit 14ba149
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14ba149

Please sign in to comment.