Change in vdsm[master]: [WIP] rest-api: Model Networks
by lilei@linux.vnet.ibm.com
Lei Li has uploaded a new change for review.
Change subject: [WIP] rest-api: Model Networks
......................................................................
[WIP] rest-api: Model Networks
API Implemented:
----------------
/api/networks
* list, create, confirm and edit configuration for network
Actions:
/api/networks/add
- Add a new network
/api/networks/confirm
- Mark the current network configurations as safe
/api/networks/<id>/delete
- DELETE a network
/api/networks/<id>/edit
- Add a new network and replace the old one
API as TODO:
---------------
/api/networks/<id...>/setup
- Add/Edit/Remove configuration for networks
Change-Id: Ic7eca74c16699a5cc35c4077192fb6ecfe706470
Signed-off-by: Lei Li <lilei(a)linux.vnet.ibm.com>
---
M vdsm/rest/Controller.py
M vdsm/rest/templates/Makefile.am
M vdsm/rest/templates/api.xsd
A vdsm/rest/templates/network.json.x
A vdsm/rest/templates/network.xml.x
A vdsm/rest/templates/networks.json.x
A vdsm/rest/templates/networks.xml.x
M vdsm/rest/templates/root.json.x
M vdsm/rest/templates/root.xml.x
M vdsm/rest/templates/rsdl.xml
10 files changed, 377 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/5881/1
--
To view, visit http://gerrit.ovirt.org/5881
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7eca74c16699a5cc35c4077192fb6ecfe706470
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lei Li <lilei(a)linux.vnet.ibm.com>
10 years, 6 months
Change in vdsm[master]: Include vds_name parameter for node registration
by fgranha@linux.vnet.ibm.com
Fernando Granha Jeronimo has uploaded a new change for review.
Change subject: Include vds_name parameter for node registration
......................................................................
Include vds_name parameter for node registration
Motivation: in ovirt, the vds_name does not need to be resolvable.
In order to allow an arbitrary name, a new kernel parameter was created
(node_name). If this paramter is not passed, vdsm-reg will stick to
the hostname of the node (the previous behavior).
Change-Id: Ic1b0bcc473ef1a034736f80e1424e211ddf02946
Signed-off-by: Fernando Granha Jeronimo <fgranha(a)linux.vnet.ibm.com>
---
M vdsm_reg/config.py.in
M vdsm_reg/vdsm-config
M vdsm_reg/vdsm-reg-cmdline
M vdsm_reg/vdsm-reg-setup.in
M vdsm_reg/vdsm-reg.conf.in
5 files changed, 19 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/8036/1
diff --git a/vdsm_reg/config.py.in b/vdsm_reg/config.py.in
index 6519ec2..d00b427 100644
--- a/vdsm_reg/config.py.in
+++ b/vdsm_reg/config.py.in
@@ -35,5 +35,6 @@
config.set('vars', 'vdc_host_port', '80')
config.set('vars', 'vdc_reg_port', '54321')
config.set('vars', 'vdc_reg_uri', '/SolidICE/VdsAutoRegistration.aspx')
+config.set('vars', 'vds_name', 'None')
config.set('vars', 'vdsm_conf_file', '/etc/vdsm/vdsm.conf')
config.set('vars', 'vdsm_dir', '@VDSMDIR@')
diff --git a/vdsm_reg/vdsm-config b/vdsm_reg/vdsm-config
index 1cb4c2c..6e0f7f3 100755
--- a/vdsm_reg/vdsm-config
+++ b/vdsm_reg/vdsm-config
@@ -65,6 +65,9 @@
rhevm_admin_password=*)
rhevm_admin_password=${i#rhevm_admin_password=}
;;
+ node_name=*)
+ node_name=${i#node_name=}
+ ;;
*)
;;
esac
@@ -75,6 +78,7 @@
vdc_managment_server=${managment_server%:*}
vdc_managment_port=${managment_server#*:}
strRHEVMAddress=$vdc_managment_server
+ vds_name=${node_name}
tmp_vdsm_reg_conf=`mktemp`
cat /etc/vdsm-reg/vdsm-reg.conf > "$tmp_vdsm_reg_conf"
echo "checkpoint 3::management_server: $vdc_managment_server, management_port: $vdc_managment_port" >> $LOG 2>&1
@@ -108,6 +112,11 @@
echo "No management_server_fingerprint found." | tee -a $LOG
fi
+ if [ ! -z "$vds_name" ]; then
+ sed --copy -i "s/\(^vds_name=\)\(..*$\)/\1${vds_name}/" \
+ /etc/vdsm-reg/vdsm-reg.conf
+ fi
+
## Set new configuration
fWriteConfig=1
else
diff --git a/vdsm_reg/vdsm-reg-cmdline b/vdsm_reg/vdsm-reg-cmdline
index 92ed468..e7f0047 100644
--- a/vdsm_reg/vdsm-reg-cmdline
+++ b/vdsm_reg/vdsm-reg-cmdline
@@ -3,4 +3,5 @@
management_server
management_server_fingerprint
rhevm_admin_password
+node_name
ovirt_vdsm_disable
diff --git a/vdsm_reg/vdsm-reg-setup.in b/vdsm_reg/vdsm-reg-setup.in
index 492e38d..8652293 100644
--- a/vdsm_reg/vdsm-reg-setup.in
+++ b/vdsm_reg/vdsm-reg-setup.in
@@ -48,7 +48,12 @@
self.vdsmDir = config.get('vars', 'vdsm_dir')
if self.vdcURL != "None":
self.ovirtURL = deployUtil.getMGTIP(self.vdsmDir, self.vdcName)
- self.ovirtName = socket.gethostname()
+
+ # use the name from config file, otherwise get the fqdn
+ self.ovirtName = config.get('vars', 'vds_name')
+ if self.ovirtName is None or self.ovirtName == "None":
+ self.ovirtName = socket.gethostname()
+
self.ovirtUID = deployUtil.getHostID()
else:
self.ovirtURL = "None"
diff --git a/vdsm_reg/vdsm-reg.conf.in b/vdsm_reg/vdsm-reg.conf.in
index 2e9df0d..c38401c 100644
--- a/vdsm_reg/vdsm-reg.conf.in
+++ b/vdsm_reg/vdsm-reg.conf.in
@@ -13,6 +13,8 @@
vdc_host_port=443
#The registrtion uri
vdc_reg_uri=/OvirtEngineWeb/register
+# The name of this node (it does not need to be resolvable)
+vds_name=None
#Upgrade settings
upgrade_iso_file=@VDSMUPGRADEDIR(a)/ovirt-node-image.iso
upgrade_mount_point=/live
--
To view, visit http://gerrit.ovirt.org/8036
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1b0bcc473ef1a034736f80e1424e211ddf02946
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Fernando Granha Jeronimo <fgranha(a)linux.vnet.ibm.com>
10 years, 6 months
Change in vdsm[master]: Added utility to ensure that files written to the file syste...
by asegurap@redhat.com
Antoni Segura Puimedon has uploaded a new change for review.
Change subject: Added utility to ensure that files written to the file system happen atomically.
......................................................................
Added utility to ensure that files written to the file system happen atomically.
The only way in python to make a file be written in an atomic way is to take
advantage of the fact that in POSIX filesystems the rename operation is atomic.
Thus, we write the context to a temporary file on the same filesystem, sync on
the file descriptor and finally do the atomic file rename to the original file
we wanted to write.
For more info:
http://stackoverflow.com/questions/2333872/atomic-writing-to-file-with-py...
http://stackoverflow.com/questions/7433057/is-rename-without-fsync-safe
Change-Id: Ibecd61d6746231a5a8cb17bad9a3302b01454f27
Signed-off-by: Antoni S. Puimedon <asegurap(a)redhat.com>
---
M vdsm/configNetwork.py
M vdsm/utils.py
2 files changed, 17 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/7656/1
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 58117f8..b943574 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -369,7 +369,8 @@
'''Backs up the previous contents of the file referenced by fileName
writes the new configuration and sets the specified access mode.'''
self._backup(fileName)
- open(fileName, 'w').write(configuration)
+ with utils.atomicWrite(fileName) as f:
+ f.write(configuration)
os.chmod(fileName, 0664)
try:
selinux.restorecon(fileName)
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 5e2d4e5..bb8a842 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -36,6 +36,7 @@
import fcntl
import functools
import stat
+from contextlib import contextmanager
import ethtool
@@ -829,3 +830,17 @@
def __unicode__(self):
return unicode(self.cmd)
+
+@contextmanager
+def atomicWrite(file):
+ '''Context manager that makes the write happen to a temporary file and if
+ and only it is successful, overwrites the original file. It creates the
+ temporary file in the same directory of the destination file, as rename is
+ only atomic within the same filesystem.'''
+ tempFile = file+'vdsm_temp'
+ f = open(tempFile, 'w')
+ yield f
+ f.flush()
+ os.fsync(f.fileno())
+ f.close()
+ os.rename(tempFile, file)
--
To view, visit http://gerrit.ovirt.org/7656
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibecd61d6746231a5a8cb17bad9a3302b01454f27
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap(a)redhat.com>
10 years, 6 months
Change in vdsm[master]: Add deathSignal options to better peopen
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: Add deathSignal options to better peopen
......................................................................
Add deathSignal options to better peopen
This allows VDSM to specify as signal that will be sent by the kernel to
the child when VDSM dies.
- Also fixes problem in the makefile that would cause make not to
recompile the SO when the C file was changed
Change-Id: I9f987129cea112e2a75d6f02477369417cc50dc7
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/betterPopen/Makefile.am
M vdsm/betterPopen/__init__.py
M vdsm/betterPopen/createprocess.c
3 files changed, 35 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/41/6241/1
--
To view, visit http://gerrit.ovirt.org/6241
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f987129cea112e2a75d6f02477369417cc50dc7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
10 years, 6 months
Change in vdsm[master]: Add build-dep packages so yum-builddep is effective
by Ryan Harper
Ryan Harper has uploaded a new change for review.
Change subject: Add build-dep packages so yum-builddep is effective
......................................................................
Add build-dep packages so yum-builddep is effective
yum-builddep doesn't get all of the required packages
needed to build vdsm and vdsm rpms. Update the specfile
Build-Requires to include the needed packages.
Change-Id: Ia5b96b5b30a9efea06261f40d1f6df61754b8253
Signed-off-by: Ryan Harper <ryanh(a)us.ibm.com>
---
M vdsm.spec.in
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/7955/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 56a42b4..300dbe5 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -29,6 +29,9 @@
BuildRequires: pyflakes
BuildRequires: python-nose
BuildRequires: python-pep8
+BuildRequires: gcc
+BuildRequires: automake
+BuildRequires: rpm-build
# BuildRequires needed by the tests during the build
BuildRequires: python-ethtool
--
To view, visit http://gerrit.ovirt.org/7955
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5b96b5b30a9efea06261f40d1f6df61754b8253
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ryan Harper <ryanh(a)us.ibm.com>
10 years, 6 months
Change in vdsm[master]: [WIP]wait vdsm instead of poking it
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: [WIP]wait vdsm instead of poking it
......................................................................
[WIP]wait vdsm instead of poking it
wait vdsm the subprocess, handling signal and error flow
as to terminate the subprocess.
Change-Id: Id2067cbd317cebfb7e0ad5aee64788adef591cf6
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M Makefile.am
M vdsm/supervdsmServer.py
2 files changed, 28 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/11192/1
diff --git a/Makefile.am b/Makefile.am
index 48bdc5e..f0876a8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,7 +54,7 @@
vdsm/*.py.in \
vdsm/sos/vdsm.py.in \
vdsm/storage \
- vdsm/vdsm \
+ vdsm/vdsmServer.py \
vdsm_api \
vdsm_cli \
vdsm_hooks \
diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py
index d64076b..77d2798 100755
--- a/vdsm/supervdsmServer.py
+++ b/vdsm/supervdsmServer.py
@@ -32,6 +32,7 @@
from gluster import cli as gcli
import storage.misc as misc
from vdsm import utils
+from vdsmServer import startVdsm
from parted_utils import getDevicePartedInfo as _getDevicePartedInfo
from md_utils import getMdDeviceUuidMap as _getMdDeviceUuidMap
@@ -44,7 +45,7 @@
from storage.fileUtils import chown, resolveGid, resolveUid
from storage.fileUtils import validateAccess as _validateAccess
from vdsm.constants import METADATA_GROUP, EXT_UDEVADM, \
- DISKIMAGE_USER, DISKIMAGE_GROUP, P_LIBVIRT_VMCHANNELS
+ DISKIMAGE_USER, DISKIMAGE_GROUP, P_LIBVIRT_VMCHANNELS, P_VDSM_RUN
from storage.devicemapper import _removeMapping, _getPathsStatus
import configNetwork
from vdsm.config import config
@@ -61,6 +62,7 @@
"%s-%s" + _UDEV_RULE_FILE_EXT
RUN_AS_TIMEOUT = config.getint("irs", "process_pool_timeout")
+ADDRESS = os.path.join(P_VDSM_RUN, "svdsm.sock")
class Timeout(RuntimeError):
@@ -332,18 +334,25 @@
return self.__udevVersion() > self.UDEV_WITH_RELOAD_VERSION
-def __pokeParent(parentPid, address, log):
+def initLogger():
try:
- while True:
- os.kill(parentPid, 0)
- sleep(2)
- except Exception:
- utils.rmFile(address)
- log.debug("Killing SuperVdsm Process")
- os.kill(os.getpid(), signal.SIGTERM)
+ logging.config.fileConfig(LOG_CONF_PATH)
+ except:
+ logging.basicConfig(filename='/dev/stdout', filemode='w+',
+ level=logging.DEBUG)
+ log = logging.getLogger("SuperVdsm.Server")
+ log.warn("Could not init proper logging", exc_info=True)
+
+ log = logging.getLogger("SuperVdsm.Server")
+ return log
-def main():
+def startSvdsm(address, childProc):
+ def sigtermHandler(signum, frame):
+ if childProc.is_alive():
+ childProc.terminate()
+ childProc.join()
+
def bind(func):
def wrapper(_SuperVdsm, *args, **kwargs):
return func(*args, **kwargs)
@@ -365,6 +374,7 @@
log.warn("Could not init proper logging", exc_info=True)
log = logging.getLogger("SuperVdsm.Server")
+ signal.signal(signal.SIGTERM, sigtermHandler)
try:
log.debug("Making sure I'm root")
@@ -388,13 +398,6 @@
zombieReaper.registerSignalHandler()
- log.debug("Setting up keep alive thread")
-
- monThread = threading.Thread(target=__pokeParent,
- args=[int(parentPid), address, log])
- monThread.setDaemon(True)
- monThread.start()
-
try:
log.debug("Creating remote object manager")
manager = _SuperVdsmManager(address=address, authkey=authkey)
@@ -414,11 +417,17 @@
# http://bugs.python.org/issue1167930
while servThread.isAlive():
servThread.join(5)
+ if not childProc.is_alive():
+ childProc.join()
+ raise Exception('Supervdsm died unexpectedly!')
finally:
if os.path.exists(address):
utils.rmFile(address)
except Exception:
+ if childProc.is_alive():
+ childProc.terminate()
+ childProc.join()
log.error("Could not start Super Vdsm", exc_info=True)
sys.exit(1)
@@ -426,4 +435,4 @@
vdsmProc = Process(target=startVdsm)
vdsmProc.start()
sleep(2)
- main()
+ startSvdsm(ADDRESS, vdsmProc)
--
To view, visit http://gerrit.ovirt.org/11192
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2067cbd317cebfb7e0ad5aee64788adef591cf6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 6 months
Change in vdsm[master]: [WIP]clean authKey for managers
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: [WIP]clean authKey for managers
......................................................................
[WIP]clean authKey for managers
when authKey is omitted, it will use current_process().authKey,
and this key will be herited when using Process() to start child.
So no authKey manager is used for child/parent communication.
Change-Id: Iff8a8169d30fc12b212d550474ef18189b5acc8d
Signed-off-by:Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/supervdsm.py
M vdsm/supervdsmServer.py
2 files changed, 2 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/11193/1
diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py
index 10abae0..0512e30 100644
--- a/vdsm/supervdsm.py
+++ b/vdsm/supervdsm.py
@@ -117,21 +117,6 @@
for f in (self.pidfile, self.timestamp, self.address):
utils.rmFile(f)
- def _start(self):
- self._authkey = str(uuid.uuid4())
- self._log.debug("Launching Super Vdsm")
-
- # we pass to svdsm filenames and uid. Svdsm will use those filenames
- # to create its internal files and give to the passed uid the
- # permissions to read those files.
- superVdsmCmd = [constants.EXT_PYTHON, SUPERVDSM,
- self._authkey, str(os.getpid()),
- self.pidfile, self.timestamp, self.address,
- str(os.getuid())]
-
- misc.execCmd(superVdsmCmd, sync=False, sudo=True)
- sleep(2)
-
def kill(self):
try:
with open(self.pidfile, "r") as f:
@@ -142,7 +127,6 @@
exc_info=True)
self._cleanOldFiles()
- self._authkey = None
self._manager = None
self._svdsm = None
self._firstLaunch = True
@@ -179,8 +163,7 @@
return False
def _connect(self):
- self._manager = _SuperVdsmManager(address=self.address,
- authkey=self._authkey)
+ self._manager = _SuperVdsmManager(address=self.address)
self._manager.register('instance')
self._manager.register('open')
self._log.debug("Trying to connect to Super Vdsm")
diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py
index 77d2798..d789b4c 100755
--- a/vdsm/supervdsmServer.py
+++ b/vdsm/supervdsmServer.py
@@ -400,7 +400,7 @@
try:
log.debug("Creating remote object manager")
- manager = _SuperVdsmManager(address=address, authkey=authkey)
+ manager = _SuperVdsmManager(address=address)
manager.register('instance', callable=_SuperVdsm)
server = manager.get_server()
--
To view, visit http://gerrit.ovirt.org/11193
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff8a8169d30fc12b212d550474ef18189b5acc8d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 6 months
Change in vdsm[master]: [WIP]remove launch and kill svdsm function from supervdsm.py
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: [WIP]remove launch and kill svdsm function from supervdsm.py
......................................................................
[WIP]remove launch and kill svdsm function from supervdsm.py
when vdsm lost priviledge, it should not launch and kill priviledged process
Change-Id: Iba310fcd0e82b86b41729dfe7aeeb8fbd56bfaf5
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M Makefile.am
M vdsm/supervdsm.py
2 files changed, 3 insertions(+), 28 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/11194/1
diff --git a/Makefile.am b/Makefile.am
index f0876a8..a0c8667 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,7 +65,8 @@
check-local:
find . -path './.git' -prune -type f -o \
- -name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES)
+ -name '*.py' ! 'vdsmServer.py' -o \
+ -name '*.py.in' | xargs $(PYFLAKES)
$(PEP8) --exclude="$(PEP8_BLACKLIST)" --filename '*.py,*.py.in' \
$(PEP8_WHITELIST)
@if test -f .gitignore; then \
diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py
index 0512e30..df0c8a3 100644
--- a/vdsm/supervdsm.py
+++ b/vdsm/supervdsm.py
@@ -51,7 +51,6 @@
PIDFILE = os.path.join(constants.P_VDSM_RUN, "svdsm.pid")
TIMESTAMP = os.path.join(constants.P_VDSM_RUN, "svdsm.time")
ADDRESS = os.path.join(constants.P_VDSM_RUN, "svdsm.sock")
-SUPERVDSM = __supervdsmServerPath()
extraPythonPathList = []
@@ -75,7 +74,7 @@
# don't care that isRunning will run twice
with self._supervdsmProxy.proxyLock:
if not self._supervdsmProxy.isRunning():
- self._supervdsmProxy.launch()
+ self._supervdsmProxy.connect()
try:
return callMethod()
@@ -110,26 +109,6 @@
def open(self, *args, **kwargs):
return self._manager.open(*args, **kwargs)
-
- def _cleanOldFiles(self):
- self._log.debug("Cleanning svdsm old files: %s, %s, %s",
- self.pidfile, self.timestamp, self.address)
- for f in (self.pidfile, self.timestamp, self.address):
- utils.rmFile(f)
-
- def kill(self):
- try:
- with open(self.pidfile, "r") as f:
- pid = int(f.read().strip())
- misc.execCmd([constants.EXT_KILL, "-9", str(pid)], sudo=True)
- except Exception:
- self._log.error("Could not kill old Super Vdsm %s",
- exc_info=True)
-
- self._cleanOldFiles()
- self._manager = None
- self._svdsm = None
- self._firstLaunch = True
def isRunning(self):
if self._firstLaunch or self._svdsm is None:
@@ -173,11 +152,6 @@
self._log.warn("Connect to svdsm failed %s", ex)
raise
self._svdsm = self._manager.instance()
-
- def launch(self):
- self._firstLaunch = False
- self._start()
- utils.retry(self._connect, Exception, timeout=60)
def __getattr__(self, name):
return ProxyCaller(self, name)
--
To view, visit http://gerrit.ovirt.org/11194
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba310fcd0e82b86b41729dfe7aeeb8fbd56bfaf5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 6 months
Change in vdsm[master]: change of the isRunning function
by lvroyce@linux.vnet.ibm.com
Hello Zhou Zheng Sheng,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/10236
to review the following change.
Change subject: change of the isRunning function
......................................................................
change of the isRunning function
isRunning() now checks supervdsm pid this not guarantee
supervdsmServer really listened and manager framework works right.
since ping is call to local manager so it won't take much time.
Only ping() can identify whether supervdsm works fine.
Change isRunning() to use ping() also eliminate Authentication error
usecases:
1.first launch: ping fails because of _svdsm=None, launch supervdsm
2.previous _svdsm: ping fails with Autherror,kill and launch
3.previous svdsm exit:ping fails with socket error,launch
4.call error: raise to caller
5.ping succeed,svdsm killed when callmethod: raise error to caller
Change-Id: Ib25809d4416f26bc95dc72e7b32b8b2a17a71879
Signed-off-by:Royce Lv<lvroyce(a)linux.vnet.ibm.com>
Signed-off-by:Zhou Zheng Sheng<zhshzhou(a)linux.vnet.ibm.com>
---
M tests/superVdsmTests.py
M vdsm/supervdsm.py
M vdsm/supervdsmServer.py
3 files changed, 24 insertions(+), 79 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/10236/1
diff --git a/tests/superVdsmTests.py b/tests/superVdsmTests.py
index 87de66d..57f4de8 100644
--- a/tests/superVdsmTests.py
+++ b/tests/superVdsmTests.py
@@ -28,7 +28,7 @@
superVdsmCmd = [getNeededPythonPath(), constants.EXT_PYTHON,
supervdsm.SUPERVDSM,
self._authkey, str(os.getpid()),
- self.pidfile, self.timestamp, self.address,
+ self.pidfile, self.address,
str(os.getuid())]
misc.execCmd(superVdsmCmd, sync=False, sudo=True)
sleep(2)
@@ -41,33 +41,24 @@
# temporary values to run temporary svdsm
self.pidfd, pidfile = tempfile.mkstemp()
- self.timefd, timestamp = tempfile.mkstemp()
self.addfd, address = tempfile.mkstemp()
- self._proxy.setIPCPaths(pidfile, timestamp, address)
+ self._proxy.setIPCPaths(pidfile, address)
def tearDown(self):
supervdsm.extraPythonPathList = []
- for fd in (self.pidfd, self.timefd, self.addfd):
- os.close(fd)
+ os.close(self.pidfd)
self._proxy.kill() # cleanning old temp files
@MonkeyPatch(supervdsm.SuperVdsmProxy, '_start', monkeyStart)
def testIsSuperUp(self):
- self._proxy.ping() # this call initiate svdsm
- self.assertTrue(self._proxy.isRunning())
+ self._proxy.ping()
+ self.assertTrue(self._proxy.isRunning()) # this call initiate svdsm
@MonkeyPatch(supervdsm.SuperVdsmProxy, '_start', monkeyStart)
def testKillSuper(self):
self._proxy.ping()
self._proxy.kill()
- self.assertFalse(self._proxy.isRunning())
+ self.assertRaises(AttributeError, self._proxy.isRunning)
self._proxy.ping() # Launching vdsm after kill
self.assertTrue(self._proxy.isRunning())
-
- @MonkeyPatch(supervdsm.SuperVdsmProxy, '_start', monkeyStart)
- def testNoPidFile(self):
- self._proxy.ping() # svdsm is up
- self.assertTrue(self._proxy.isRunning())
- utils.rmFile(self._proxy.timestamp)
- self.assertRaises(IOError, self._proxy.isRunning)
diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py
index 532d5ac..a9bbdf6 100644
--- a/vdsm/supervdsm.py
+++ b/vdsm/supervdsm.py
@@ -20,13 +20,11 @@
#
import os
-from multiprocessing import AuthenticationError
from multiprocessing.managers import BaseManager
import logging
import threading
import uuid
from time import sleep
-from errno import ENOENT, ESRCH
import storage.misc as misc
from vdsm import constants, utils
@@ -45,7 +43,6 @@
raise RuntimeError("SuperVDSM Server not found")
PIDFILE = os.path.join(constants.P_VDSM_RUN, "svdsm.pid")
-TIMESTAMP = os.path.join(constants.P_VDSM_RUN, "svdsm.time")
ADDRESS = os.path.join(constants.P_VDSM_RUN, "svdsm.sock")
SUPERVDSM = __supervdsmServerPath("supervdsmServer.py")
@@ -66,22 +63,16 @@
callMethod = lambda: \
getattr(self._supervdsmProxy._svdsm, self._funcName)(*args,
**kwargs)
- if not self._supervdsmProxy.isRunning():
- # getting inside only when svdsm is down. its rare case so we
- # don't care that isRunning will run twice
- with self._supervdsmProxy.proxyLock:
- if not self._supervdsmProxy.isRunning():
- self._supervdsmProxy.launch()
- try:
- return callMethod()
- # handling internal exception that we raise to identify supervdsm
- # validation. only this exception can cause kill!
- except AuthenticationError:
- with self._supervdsmProxy.proxyLock:
+ with self._supervdsmProxy.proxyLock:
+ try:
+ # make sure supervdsmServer works right
+ self._supervdsmProxy.isRunning()
+ except:
self._supervdsmProxy.kill()
self._supervdsmProxy.launch()
- return callMethod()
+
+ return callMethod()
class SuperVdsmProxy(object):
@@ -92,25 +83,19 @@
def __init__(self):
self.proxyLock = threading.Lock()
- self._firstLaunch = True
+ self.setIPCPaths(PIDFILE, ADDRESS)
- # Declaration of public variables that keep files' names that svdsm
- # uses. We need to be able to change these variables so that running
- # tests doesn't disturb and already running VDSM on the host.
- self.setIPCPaths(PIDFILE, TIMESTAMP, ADDRESS)
-
- def setIPCPaths(self, pidfile, timestamp, address):
+ def setIPCPaths(self, pidfile, address):
self.pidfile = pidfile
- self.timestamp = timestamp
self.address = address
def open(self, *args, **kwargs):
return self._manager.open(*args, **kwargs)
def _cleanOldFiles(self):
- self._log.debug("Cleanning svdsm old files: %s, %s, %s",
- self.pidfile, self.timestamp, self.address)
- for f in (self.pidfile, self.timestamp, self.address):
+ self._log.debug("Cleanning svdsm old files: %s, %s",
+ self.pidfile, self.address)
+ for f in (self.pidfile, self.address):
utils.rmFile(f)
def _start(self):
@@ -122,7 +107,7 @@
# permissions to read those files.
superVdsmCmd = [constants.EXT_PYTHON, SUPERVDSM,
self._authkey, str(os.getpid()),
- self.pidfile, self.timestamp, self.address,
+ self.pidfile, self.address,
str(os.getuid())]
misc.execCmd(superVdsmCmd, sync=False, sudo=True)
@@ -134,42 +119,15 @@
pid = int(f.read().strip())
misc.execCmd([constants.EXT_KILL, "-9", str(pid)], sudo=True)
except Exception:
- self._log.error("Could not kill old Super Vdsm %s",
- exc_info=True)
+ self._log.warn("Could not kill old Super Vdsm")
self._cleanOldFiles()
self._authkey = None
self._manager = None
self._svdsm = None
- self._firstLaunch = True
def isRunning(self):
- try:
- with open(self.pidfile, "r") as f:
- spid = f.read().strip()
- with open(self.timestamp, "r") as f:
- createdTime = f.read().strip()
- except IOError as e:
- # pid file and timestamp file must be exist after first launch,
- # otherwise excpetion will be raised to svdsm caller
- if e.errno == ENOENT and self._firstLaunch:
- return False
- else:
- raise
-
- try:
- pTime = str(misc.getProcCtime(spid))
- except OSError as e:
- if e.errno == ESRCH:
- # Means pid is not exist, svdsm was killed
- return False
- else:
- raise
-
- if pTime == createdTime:
- return True
- else:
- return False
+ return self._svdsm.ping()
def _connect(self):
self._manager = _SuperVdsmManager(address=self.address,
@@ -185,7 +143,6 @@
self._svdsm = self._manager.instance()
def launch(self):
- self._firstLaunch = False
self._start()
utils.retry(self._connect, Exception, timeout=60)
diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py
index 5effd41..8968a82 100755
--- a/vdsm/supervdsmServer.py
+++ b/vdsm/supervdsmServer.py
@@ -336,15 +336,12 @@
sys.exit(errno.EPERM)
log.debug("Parsing cmd args")
- authkey, parentPid, pidfile, timestamp, address, uid = sys.argv[1:]
+ authkey, parentPid, pidfile, address, uid = sys.argv[1:]
- log.debug("Creating PID and TIMESTAMP files: %s, %s",
- pidfile, timestamp)
+ log.debug("Creating PID:%s", pidfile)
spid = os.getpid()
with open(pidfile, "w") as f:
f.write(str(spid) + "\n")
- with open(timestamp, "w") as f:
- f.write(str(misc.getProcCtime(spid) + "\n"))
log.debug("Cleaning old socket %s", address)
if os.path.exists(address):
@@ -369,7 +366,7 @@
servThread.setDaemon(True)
servThread.start()
- for f in (address, timestamp, pidfile):
+ for f in (address, pidfile):
chown(f, int(uid), METADATA_GROUP)
log.debug("Started serving super vdsm object")
--
To view, visit http://gerrit.ovirt.org/10236
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib25809d4416f26bc95dc72e7b32b8b2a17a71879
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
10 years, 6 months
Change in vdsm[master]: [WIP]start vdsm as subprocess in supervdsm server
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: [WIP]start vdsm as subprocess in supervdsm server
......................................................................
[WIP]start vdsm as subprocess in supervdsm server
supervdsm will run as root, vdsm start needs to drop priviledge.
export start vdsm function,
run it as subprocess when start supervdsm server.
sleep to make vdsm starts first and log ownership right.
Change-Id: I540b1d3f3c823433f100f4803f31322fc7ee2153
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/supervdsmServer.py
R vdsm/vdsmServer.py
2 files changed, 12 insertions(+), 31 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/11191/1
diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py
index 83a5803..d64076b 100755
--- a/vdsm/supervdsmServer.py
+++ b/vdsm/supervdsmServer.py
@@ -423,4 +423,7 @@
sys.exit(1)
if __name__ == '__main__':
+ vdsmProc = Process(target=startVdsm)
+ vdsmProc.start()
+ sleep(2)
main()
diff --git a/vdsm/vdsm b/vdsm/vdsmServer.py
similarity index 77%
rename from vdsm/vdsm
rename to vdsm/vdsmServer.py
old mode 100755
new mode 100644
index 4746a0f..337a4ca
--- a/vdsm/vdsm
+++ b/vdsm/vdsmServer.py
@@ -10,11 +10,8 @@
import os
import sys
-import getopt
import signal
-import getpass
import pwd
-import grp
import threading
import logging
import syslog
@@ -99,19 +96,6 @@
log.info(str(t))
-def parse_args():
- opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
- for o, v in opts:
- o = o.lower()
- if o == "-h" or o == "--help":
- usage()
- sys.exit(0)
-
- if len(args) >= 1:
- usage()
- sys.exit(1)
-
-
def __assertLogPermission():
if not os.access(constants.P_VDSM_LOG, os.W_OK):
syslog.syslog("vdsm log directory is not accessible")
@@ -127,21 +111,15 @@
sys.exit(1)
-def __assertVdsmUser():
- username = getpass.getuser()
- if username != constants.VDSM_USER:
- syslog.syslog("VDSM failed to start: running user is not %s, trying "
- "to run from user %s" % (constants.VDSM_USER, username))
- sys.exit(1)
- group = grp.getgrnam(constants.VDSM_GROUP)
- if (constants.VDSM_USER not in group.gr_mem) and \
- (pwd.getpwnam(constants.VDSM_USER).pw_gid != group.gr_gid):
- syslog.syslog("VDSM failed to start: vdsm user is not in KVM group")
- sys.exit(1)
+def startVdsm():
+ def dropPrivileges():
+ if os.getuid() != 0:
+ sys.exit(1)
+ vdsm_uid, vdsm_gid = pwd.getpwnam(constants.VDSM_USER)[2:4:]
-if __name__ == '__main__':
- __assertVdsmUser()
+ os.setgroups([])
+ os.setgid(vdsm_gid)
+ os.setuid(vdsm_uid)
+ dropPrivileges()
__assertLogPermission()
- os.setpgrp()
- parse_args()
run()
--
To view, visit http://gerrit.ovirt.org/11191
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I540b1d3f3c823433f100f4803f31322fc7ee2153
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 6 months