Saggi Mizrahi has uploaded a new change for review.
Change subject: Nits on isLocalFsDomain()
......................................................................
Nits on isLocalFsDomain()
- Add followSymlinks parameter to findMountOfPath() for cases where the user
wants to avoid touching the file for the price of reduced accuracy.
- Uses the storage.mount module because there is no reason to reinvent
the wheel every time.
- Changes the logic to check that the domain mount is different from the
mount dir mount. This is a bit more robust and a lot more correct.
Change-Id: I415e3ed87d1c2f9e0f67d90c5bcd8734e70e53c3
Bug-url: https://bugzilla.redhat.com/show_bug.cgi?id=886533
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/storage/localFsSD.py
M vdsm/storage/mount.py
2 files changed, 32 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/10628/1
diff --git a/vdsm/storage/localFsSD.py b/vdsm/storage/localFsSD.py
index 74becea..dc9e727 100644
--- a/vdsm/storage/localFsSD.py
+++ b/vdsm/storage/localFsSD.py
@@ -26,6 +26,7 @@
import fileUtils
import storage_exception as se
import misc
+import mount
class LocalFsStorageDomain(fileSD.FileStorageDomain):
@@ -106,22 +107,23 @@
def isLocalFsDomain(domainPath):
"""This ancillary function differentiates local and mounted SD's.
- Assumed that a local SD can't be mounted.
- mounted: nfs, posixFS
- local: a link to a local dir in the /rhev/datacenter
+ It does this by checking if the mount path of "domainPath" is different
+ from the mount path of it's parent directory or the /ovirt/datacenter/mnt
+ directory. Because localFS domains a symlinks they will have the same mount
+ path.
+
+ This method has an inherent race that if the mounted domain has been
+ unmounted between getting the domainPath and actually checking for locality
+ it will be reported as local. Since the domain doesn't exist anyway I
+ choose to ignore this.
"""
- mtab = open("/etc/mtab", "r").readlines()
- for mEntry in mtab:
- mPoint = mEntry.split()[1]
- if mPoint == '/':
- continue
- elif mPoint in domainPath:
- # This is a mounted domain therefore not exists as a local SD.
- isLocal = False
- break
- else:
- isLocal = True
- return isLocal
+
+ mountDir = os.path.join(domainPath, "..")
+ mountDir = os.path.normpath(mountDir)
+
+ mountDirMnt = mount.findMountOfPath(mountDir, False)
+ domMnt = mount.findMountOfPath(domainPath, False)
+ return (domMnt.fs_file != mountDirMnt.fs_file)
def findDomain(sdUUID):
diff --git a/vdsm/storage/mount.py b/vdsm/storage/mount.py
index 81ca17f..d643528 100644
--- a/vdsm/storage/mount.py
+++ b/vdsm/storage/mount.py
@@ -154,10 +154,22 @@
raise OSError(errno.ENOENT, 'Mount target %s not found' % target)
-def findMountOfPath(path):
+def findMountOfPath(path, followSymlinks=True):
+ """ Finds the mount associated with a path.
+
+ :param path: path to a node on the filesystem
+ :param followSymlinks: The functions will not resolve symlinks. This means
+ that the function can be used in process without
+ fear of any IO getting stuck. Use this for cases
+ where you know that the target is not a symlink or
+ when it isn't important if it is.
+
+ :returns: A mount object representing the mount associated with the file.
+ """
# TBD: Bind mounts, should we ignore them?
- # Follow symlinks (if file exists)
- path = os.path.realpath(path)
+ if followSymlinks:
+ # Follow symlinks (if file exists)
+ path = os.path.realpath(path)
# Make sure using canonical representation
path = os.path.normpath(path)
--
To view, visit http://gerrit.ovirt.org/10628
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I415e3ed87d1c2f9e0f67d90c5bcd8734e70e53c3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
Juan Hernandez has uploaded a new change for review.
Change subject: Copy truncate vdsm-reg.log
......................................................................
Copy truncate vdsm-reg.log
When the vdsm-reg program doesn't stop (if it fails to contact the
engine, for example) it will continuously generate messages that can
flood the log. Moving the log file is not enough because the program
keeps it open, so the space is not freed. As the program opens the file
for appending it is safe to copy and truncate the file.
Change-Id: I92bea487a70fa2f39a88be417faa4efd7bb99f08
Signed-off-by: Juan Hernandez <juan.hernandez(a)redhat.com>
---
M vdsm_reg/vdsm-reg-logrotate.conf
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/11282/1
diff --git a/vdsm_reg/vdsm-reg-logrotate.conf b/vdsm_reg/vdsm-reg-logrotate.conf
index d84bf15..579096a 100644
--- a/vdsm_reg/vdsm-reg-logrotate.conf
+++ b/vdsm_reg/vdsm-reg-logrotate.conf
@@ -5,6 +5,7 @@
}
/var/log/vdsm-reg/vdsm-reg.log {
+ copytruncate
rotate 3
missingok
size 10M
--
To view, visit http://gerrit.ovirt.org/11282
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I92bea487a70fa2f39a88be417faa4efd7bb99f08
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernandez(a)redhat.com>
Dan Kenigsberg has uploaded a new change for review.
Change subject: test CommandPath
......................................................................
test CommandPath
Change-Id: I0b53d5ce56551fea8c6ecf7801ca2de86334cf49
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M tests/utilsTests.py
1 file changed, 18 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/11165/1
diff --git a/tests/utilsTests.py b/tests/utilsTests.py
index cb32c65..dcc78ed 100644
--- a/tests/utilsTests.py
+++ b/tests/utilsTests.py
@@ -1,5 +1,5 @@
#
-# Copyright 2012 Red Hat, Inc.
+# Copyright 2012-2013 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,6 +17,8 @@
#
# Refer to the README and COPYING files for full details of the license
#
+import errno
+
from testrunner import VdsmTestCase as TestCaseBase
from vdsm import utils
from storage import misc
@@ -58,3 +60,18 @@
self.assertEquals(name, args[0])
sproc.kill()
sproc.wait()
+
+
+class CommandPathTests(TestCaseBase):
+ def testExisting(self):
+ cp = utils.CommandPath('sh', 'utter nonsense', '/bin/sh')
+ self.assertEquals(cp.cmd, '/bin/sh')
+
+ def testMissing(self):
+ NAME = 'nonsense'
+ try:
+ utils.CommandPath(NAME, 'utter nonsense').cmd
+ except OSError as e:
+ self.assertEquals(e.errno, errno.ENOENT)
+ self.assertTrue(NAME in e.strerror,
+ msg='%s not in %s' % (NAME, e.strerror))
--
To view, visit http://gerrit.ovirt.org/11165
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b53d5ce56551fea8c6ecf7801ca2de86334cf49
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
Jarod.w has uploaded a new change for review.
Change subject: vdsm: free loop device when umounting floppy in mkimage.py
......................................................................
vdsm: free loop device when umounting floppy in mkimage.py
After umounting floppy successfully, it doesn't free automatically
the loop device. Here, we add the support to free the loop device
in the umount function of Mount class and free it to prevent it
using up all loop devices.
The issue only happened in the special case that node is built using
livecd-tools(version: 16.8-1) and rpms from centos63. Because:
1. Centos63 disables auto-destruction feature and still depends on
/etc/mtab to free the loop device.
2. Livecd-tools links /etc/mtab to /proc/self/mounts, so umount can't
get suggestion to free the loop device from /etc/mtab.
Change-Id: Ia02cfaf4d8ba46de6d42b12d15351d3ab1cb3d03
Signed-off-by: jarod.w <work.iec23801(a)gmail.com>
---
M vdsm/mkimage.py
M vdsm/storage/mount.py
2 files changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/11132/1
diff --git a/vdsm/mkimage.py b/vdsm/mkimage.py
index c3c66ab..0eabae2 100644
--- a/vdsm/mkimage.py
+++ b/vdsm/mkimage.py
@@ -90,7 +90,7 @@
try:
_decodeFilesIntoDir(files, dirname)
finally:
- m.umount(force=True)
+ m.umount(force=True, freeloop=True)
finally:
_commonCleanFs(dirname, floppy)
diff --git a/vdsm/storage/mount.py b/vdsm/storage/mount.py
index 81ca17f..90cacc7 100644
--- a/vdsm/storage/mount.py
+++ b/vdsm/storage/mount.py
@@ -237,7 +237,7 @@
raise MountError(rc, ";".join((out, err)))
- def umount(self, force=False, lazy=False, timeout=None):
+ def umount(self, force=False, lazy=False, freeloop=False, timeout=None):
cmd = [constants.EXT_UMOUNT]
if force:
cmd.append("-f")
@@ -245,6 +245,9 @@
if lazy:
cmd.append("-l")
+ if freeloop:
+ cmd.append("-d")
+
cmd.append(self.fs_file)
return self._runcmd(cmd, timeout)
--
To view, visit http://gerrit.ovirt.org/11132
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia02cfaf4d8ba46de6d42b12d15351d3ab1cb3d03
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Jarod.w <work.iec23801(a)gmail.com>