Check oslo.concurrency supports prlimits

Bug #1449062 was fixed and backported to Liberty by adding qemu limits settings
to oslo putils execute call. The problem is that min requirement for Liberty is
oslo.concurrency 2.30 and this feature requires oslo.concurrency 2.6.1.

oslo.concurrency isn't pinned but this could cause some issues if folks are on
the older version. We should just add a simple try/except block around this so
it doesn't break people that are running older versions of oslo.concurrency.

Change-Id: I9e3965980f28fc0760b81a6e2d60db33a794cca3
Closes-Bug: #1641992
This commit is contained in:
John Griffith 2016-11-15 09:26:14 -07:00
parent 859ce1f218
commit 4295ff0a64
1 changed files with 19 additions and 6 deletions

View File

@ -38,7 +38,7 @@ from oslo_utils import timeutils
from oslo_utils import units
from cinder import exception
from cinder.i18n import _, _LI, _LW
from cinder.i18n import _, _LE, _LI, _LW
from cinder.openstack.common import imageutils
from cinder import utils
from cinder.volume import throttling
@ -54,9 +54,17 @@ image_helper_opts = [cfg.StrOpt('image_conversion_dir',
CONF = cfg.CONF
CONF.register_opts(image_helper_opts)
QEMU_IMG_LIMITS = processutils.ProcessLimits(
cpu_time=2,
address_space=1 * units.Gi)
QEMU_IMG_LIMITS = None
try:
QEMU_IMG_LIMITS = processutils.ProcessLimits(
cpu_time=2,
address_space=1 * units.Gi)
except Exception:
LOG.error(_LE('Use of process limits requires oslo.concurrency '
'version >=2.6.1 but the installed version is '
'older than that. Please upgrade oslo.concurrency '
'to address vulnerability CVE-2015-5162.'))
def qemu_img_info(path, run_as_root=True):
@ -64,8 +72,13 @@ def qemu_img_info(path, run_as_root=True):
cmd = ('env', 'LC_ALL=C', 'qemu-img', 'info', path)
if os.name == 'nt':
cmd = cmd[2:]
out, _err = utils.execute(*cmd, run_as_root=run_as_root,
prlimit=QEMU_IMG_LIMITS)
if QEMU_IMG_LIMITS:
out, _err = utils.execute(*cmd, run_as_root=run_as_root,
prlimit=QEMU_IMG_LIMITS)
else:
out, _err = utils.execute(*cmd, run_as_root=run_as_root)
return imageutils.QemuImgInfo(out)