Make mount_check option usable in containerized environments
The ismount_raw method does not work inside containers if disks are mounted on the hostsystem and only mountpoints are exposed inside the containers. In this case the inode and device checks fail, making this option unusable. Mounting devices into the containers would solve this. However, this would require that all processes that require access to a device are running inside the same container, which counteracts the container concept. This patch adds the possiblity to place stubfiles named ".ismount" into the root directory of any device, and Swift assumes a given device to be mounted if that file exists. This should be transparent to existing clusters. Change-Id: I9d9fc0a4447a8c5dd39ca60b274c119af6b4c28f
This commit is contained in:
parent
9089e44c0b
commit
5eeaa95440
@ -3583,6 +3583,12 @@ def ismount_raw(path):
|
||||
# path/.. is the same i-node as path
|
||||
return True
|
||||
|
||||
# Device and inode checks are not properly working inside containerized
|
||||
# environments, therefore using a workaround to check if there is a
|
||||
# stubfile placed by an operator
|
||||
if os.path.isfile(os.path.join(path, ".ismount")):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
@ -3300,6 +3300,16 @@ cluster_dfw1 = http://dfw1.host/v1/
|
||||
finally:
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
def test_ismount_successes_stubfile(self):
|
||||
tmpdir = mkdtemp()
|
||||
fname = os.path.join(tmpdir, ".ismount")
|
||||
try:
|
||||
with open(fname, "w") as stubfile:
|
||||
stubfile.write("")
|
||||
self.assertTrue(utils.ismount(tmpdir))
|
||||
finally:
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
def test_parse_content_type(self):
|
||||
self.assertEqual(utils.parse_content_type('text/plain'),
|
||||
('text/plain', []))
|
||||
|
Loading…
x
Reference in New Issue
Block a user