LVM.__init__() checks for VG existence before setting up LVM_SYSTEM_DIR

Bug #1498480 reported by Fergal Mc Carthy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Fergal Mc Carthy

Bug Description

Running Kilo Stable version of OpenStack

While testing on a small OpenStack configuration using LVM as a backend I have configured the /etc/lvm/lvm.conf on my hosts to reject all devices except those on which the operating system is installed.

On the host where cinder-volume & cinder-backup are running I created a /etc/cinder/lvm.conf which rejects all devices except those backing the cinder-volumes LVM VG. I.e. there is no overlap between the set of devices accepted by /etc/lvm/lvm.conf and /etc/cinder/lvm.conf.

When I try to start cinder-volume I get errors trying to initalise the LVM backend because the specified backing LVM VG is not found.

Looking in the logs I noticed that even though /etc/cinder/lvm.conf exists and was specified via the lvm_conf_file option, there is a 'vgs' command being run without LVM_SYSTEM_DIR specified in it's environment.

This lead me to the 'cinder/brick/local_dev/lvm.py' file where I noticed that, in the middle of the LVM.__init__(), there is a self._vg_exists() check, but the LVM.LVM_CMD_PREFIX isn't updated to include LVM_SYSTEM_DIR until the end of the LVM.__init__() routine, as follows:

        if lvm_conf and os.path.isfile(lvm_conf):
            LVM.LVM_CMD_PREFIX = ['env',
                                  'LC_ALL=C',
                                  'LVM_SYSTEM_DIR=/etc/cinder']

Moving these 4 lines of code to before the create_vg check near the beginning of LVM.__init__() resolved the problem and allows me to start cinder-volume.

I notice that this code appears the same on the cinder/master branch, so I will propose a review for this against that branch later today.

affects: nova → cinder
Changed in cinder:
assignee: nobody → Fergal Mc Carthy (fergal-mccarthy)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/226543

Changed in cinder:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/226543
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=adf2d4306a6886268ffb1a6e4c8fe7ef2fe683e3
Submitter: Jenkins
Branch: master

commit adf2d4306a6886268ffb1a6e4c8fe7ef2fe683e3
Author: Fergal Mc Carthy <email address hidden>
Date: Tue Sep 22 16:39:48 2015 -0400

    Setup LVM_SYSTEM_DIR earlier in LVM.__init()

    When using a Cinder specific lvm.conf file, we need to setup the
    LVM_SYSTEM_DIR setting in the LVM.LVM_CMD_PREFIX before issuing
    any LVM commands to ensure that the correct lvm.conf is used.

    The issue was uncovered when testing on a Cinder Volume host setup
    as follows:
      * Cinder is configured to use an LVM backend, backed by the
        cinder-volumes VG, which already exists.
      * /etc/lvm/lvm.conf rejects all devices other than those on which
        the operating system is installed.
      * /etc/cinder/lvm.conf accepts only the devices backing the
        cinder-volumes LVM VG

    The cinder-volume service would fail to initialise the specified LVM
    backend because the cinder.brick.local_dev.lvm.LVM.__init__() call
    checks for the existence of the specified VG before
        LVM_SYSTEM_DIR=/etc/cinder
    has been added to the LVM.LVM_CMD_PREFIX, and thus fails to find the
    VG, and raises an exception.

    By moving the setup of the LVM_SYSTEM_DIR environment variable in
    LVM.LVM_CMD_PREFIX to happen before any LVM commands are issued we
    ensure that all subsequent LVM commands are run against the correct
    lvm.conf file.

    Change-Id: I6551b045ab48ee60c3ee4cd15c13058635c144c2
    Closes-Bug: #1498480

Changed in cinder:
status: In Progress → Fix Committed
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/cinder 8.0.0.0b1

This issue was fixed in the openstack/cinder 8.0.0.0b1 development milestone.

Thierry Carrez (ttx)
Changed in cinder:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.