From dd5f136442d7b9bf9a829f72e5680aa67ab76f5a Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Tue, 18 Sep 2018 11:35:26 -0400 Subject: [PATCH] Remove udevadm from rootwrap Use oslo.privsep for udevadm Change-Id: Ib89354c9555c4b2c9f5a8331a788d7fe4ac46694 Signed-off-by: Chuck Short --- cinder/brick/local_dev/lvm.py | 5 ++--- cinder/privsep/lvm.py | 26 ++++++++++++++++++++++++++ etc/cinder/rootwrap.d/volume.filters | 2 -- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 cinder/privsep/lvm.py diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 342720863ed..69636bbf445 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -28,6 +28,7 @@ from oslo_utils import excutils from six import moves from cinder import exception +import cinder.privsep.lvm from cinder import utils @@ -705,9 +706,7 @@ class LVM(executor.Executor): """ def run_udevadm_settle(): - self._execute('udevadm', 'settle', - root_helper=self._root_helper, run_as_root=True, - check_exit_code=False) + cinder.privsep.lvm.udevadm_settle() # LV removal seems to be a race with other writers or udev in # some cases (see LP #1270192), so we enable retry deactivation diff --git a/cinder/privsep/lvm.py b/cinder/privsep/lvm.py new file mode 100644 index 00000000000..a460520dbe9 --- /dev/null +++ b/cinder/privsep/lvm.py @@ -0,0 +1,26 @@ +# Copyright 2018 Red Hat, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +Helpers for lvm related routines +""" + +from oslo_concurrency import processutils + +import cinder.privsep + + +@cinder.privsep.sys_admin_pctxt.entrypoint +def udevadm_settle(): + processutils.execute('udevadm', 'settle') diff --git a/etc/cinder/rootwrap.d/volume.filters b/etc/cinder/rootwrap.d/volume.filters index 9ad11694170..5e40a73be40 100644 --- a/etc/cinder/rootwrap.d/volume.filters +++ b/etc/cinder/rootwrap.d/volume.filters @@ -103,8 +103,6 @@ ln: CommandFilter, ln, root qemu-img: EnvFilter, env, root, LC_ALL=C, qemu-img qemu-img_convert: CommandFilter, qemu-img, root -udevadm: CommandFilter, udevadm, root - # cinder/volume/nfs.py stat: CommandFilter, stat, root mount: CommandFilter, mount, root