From 6f44d7163110c4910e112db576a7e49ca22a6018 Mon Sep 17 00:00:00 2001 From: Mark Vanderwiel Date: Tue, 28 Apr 2015 14:18:52 -0500 Subject: [PATCH] Fix lock_path to be based upon state path On some recent platforms, systemd based, the /var/lock/ path gets cleaned up at reboot and causes issues for projects like cinder. Nova and neutron changed long ago to base the lock path off the state path, this change does the same thing now for cinder. Change-Id: Ibe693c21cfc63dd5b6e1753c85081a952005b293 Closes-Bug: #1449711 --- attributes/default.rb | 9 +++++++-- recipes/cinder-common.rb | 2 +- spec/cinder_common_spec.rb | 10 +++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 7ed723e..348c265 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -40,8 +40,6 @@ default['openstack']['block-storage']['debug'] = 'False' # Specify policy.json remote file to import default['openstack']['block-storage']['policyfile_url'] = nil -# Default lock_path -default['openstack']['block-storage']['lock_path'] = '/var/lock/cinder' # Default notification_driver and control exchange default['openstack']['block-storage']['notification_driver'] = 'cinder.openstack.common.notifier.rpc_notifier' default['openstack']['block-storage']['control_exchange'] = 'cinder' @@ -314,6 +312,13 @@ default['openstack']['block-storage']['volume']['default_volume_type'] = nil # For example: ['# Comment', 'key=value'] default['openstack']['block-storage']['misc_cinder'] = [] +# Default lock_path +# The lock_path normally uses /var/lock/cinder, but it's does not work +# in cases like systemd, so setting lock_path to $state_path/lock like +# in nova and neutron. +default['openstack']['block-storage']['lock_path'] = + "#{node['openstack']['block-storage']['volume']['state_path']}/lock" + case platform_family when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this # operating system user and group names diff --git a/recipes/cinder-common.rb b/recipes/cinder-common.rb index 4234c27..dee23d4 100644 --- a/recipes/cinder-common.rb +++ b/recipes/cinder-common.rb @@ -124,7 +124,7 @@ end directory node['openstack']['block-storage']['lock_path'] do group node['openstack']['block-storage']['group'] owner node['openstack']['block-storage']['user'] - mode 00700 + mode 00755 end template '/etc/cinder/rootwrap.conf' do diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb index 9d0c96e..51e9d2a 100644 --- a/spec/cinder_common_spec.rb +++ b/spec/cinder_common_spec.rb @@ -193,7 +193,7 @@ describe 'openstack-block-storage::cinder-common' do end it 'has a lock_path attribute' do - expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r(^lock_path=/var/lock/cinder$)) + expect(chef_run).to render_config_file(file.name).with_section_content('oslo_concurrency', %r(^lock_path=/var/lib/cinder/lock$)) end context 'netapp driver' do @@ -971,10 +971,10 @@ describe 'openstack-block-storage::cinder-common' do end end - describe '/var/lock/cinder' do - let(:dir) { chef_run.directory('/var/lock/cinder') } + describe '/var/lib/cinder/lock' do + let(:dir) { chef_run.directory('/var/lib/cinder/lock') } - it 'should create the /var/lock/cinder directory' do + it 'should create the /var/lib/cinder/lock directory' do expect(chef_run).to create_directory(dir.name) end @@ -984,7 +984,7 @@ describe 'openstack-block-storage::cinder-common' do end it 'has proper modes' do - expect(sprintf('%o', dir.mode)).to eq '700' + expect(sprintf('%o', dir.mode)).to eq '755' end end