summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Albertson <lance@osuosl.org>2021-02-12 11:06:56 -0800
committerLance Albertson <lance@osuosl.org>2021-02-12 11:10:14 -0800
commit3ca53d4c6d412a6cc11892357867889e0f5ac89b (patch)
tree2c77d8e36a8872364284726de3d58034b5791638
parent4cfb8455fcc4ffcb452c43666b0f02c140d94d82 (diff)
downloadchef-3ca53d4c6d412a6cc11892357867889e0f5ac89b.tar.gz
Fix network mounts which use the root level as the device
PR #10614 introduce a bug which can impact network mounts which try to mount from the root level (i.e. server:/). Specifically, we run into this on cephfs where this is pretty common. This adds some logic to detect if this is a network mount at the root level and doesn't strip the '/'. This resolves #10764. Signed-off-by: Lance Albertson <lance@osuosl.org>
-rw-r--r--lib/chef/provider/mount/mount.rb2
-rw-r--r--spec/unit/provider/mount/mount_spec.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 0bd81d5453..12406b7f47 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -203,7 +203,7 @@ class Chef
end
end
# Removed "/" from the end of str, because it was causing idempotency issue.
- @real_device == "/" ? @real_device : @real_device.chomp("/")
+ (@real_device == "/" || @real_device.match?(":/$")) ? @real_device : @real_device.chomp("/")
end
def device_logstring
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 9a7d9198b5..015e0038c8 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -66,6 +66,7 @@ describe Chef::Provider::Mount::Mount do
describe "when dealing with network mounts" do
{ "nfs" => "nfsserver:/vol/path",
+ "cephfs" => "cephserver:6789:/",
"cifs" => "//cifsserver/share" }.each do |type, fs_spec|
it "should detect network fs_spec (#{type})" do
@new_resource.device fs_spec