IBM / ubiquity

Ubiquity
Apache License 2.0
90 stars 26 forks source link

Mount flow should fail to mount if the mountpoint is already in-use. #212

Closed shay-berman closed 6 years ago

shay-berman commented 6 years ago

This PR is for fixing a bug that @danare found in PR #196 (internal issue UB-1230).

Flex mount CLI must prevent mounting a device if the mountpoint is already in used by other device, in order to prevent double mounting on the same directory.

So this PR fix it and check during the mount flow if the given mountpoint is already in-used (already mounted by other device). If its already mounted to a different device, then error will be raised "[%s] directory is already a mountpoint but to unexpected devices=%#v (expected mountpoint only on device=[%s])"

How to test:

  1. Create 2 PVCs (PVC1 & PVC2) and check what is the PV1 WWN (will be used in step 3)
  2. Manually create and map PV2 on node1.
  3. Manually discover the PV2 the device on the node1 and mkfs and mount it to a directory /ubiquity/ (create the directory in advance)
  4. Create Pod on node1 that uses PVC1, the creation of the pod should fail(Container creating) due to the error mentioned above.
  5. Now manually unmount PVC2 from node1, unmap and clean its device from node1. Then after after few minutes (k8s flex scheduling) should start the POD successfully.

This change is Reviewable

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.6%) to 53.818% when pulling 170380da4c3d8d5e7d67ef2c99bfea771fcedfd7 on fix/UB_1230_prevent_doublemounting into e742debdcd60e2624b1bd24d42efab62562b585a on dev.

olgashtivelman commented 6 years ago
:lgtm:

Review status: 0 of 7 files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

olgashtivelman commented 6 years ago

Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable