Ensure the owner/group for cache is correct

Create the cache dir or update the owner/group for cache dir,
in order to ensure that the image cache dir has the right
permission, avoid breaking the glance cache feature.

Change-Id: If7ba126af284c7fd53adbdb8270a7cf20a941ace
Related-Bug: 1416245
This commit is contained in:
Jun Hong Li
2015-02-02 14:30:36 +08:00
parent 26b05d678f
commit 191e0130b8
4 changed files with 29 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ This file is used to list changes made in each version of cookbook-openstack-ima
## 10.1.0
### Blue print
* Make container_formats and disk_formats configurable
* Set the owner/group of openstack image cache directory to glance/glance.
## 10.0.0
* Upgrading to Juno

View File

@@ -254,6 +254,14 @@ cron 'glance-cache-cleaner' do
command "/usr/bin/glance-cache-cleaner #{node['openstack']['image']['cron']['redirection']}"
end
# Ensure the owner/group of image cache directory is correct
directory node['openstack']['image']['cache']['dir'] do
owner node['openstack']['image']['user']
group node['openstack']['image']['group']
recursive true
mode 00755
end
template '/etc/glance/glance-scrubber-paste.ini' do
source 'glance-scrubber-paste.ini.erb'
owner node['openstack']['image']['user']

View File

@@ -31,6 +31,7 @@ describe 'openstack-image::api' do
include_examples 'common-logging-recipe'
include_examples 'common-packages'
include_examples 'cache-directory'
include_examples 'image-lib-cache-directory'
include_examples 'glance-directory'
it 'does not upgrade swift package by default' do

View File

@@ -111,6 +111,25 @@ shared_examples 'cache-directory' do
end
end
shared_examples 'image-lib-cache-directory' do
describe '/var/lib/glance/image-cache/' do
let(:dir) { chef_run.directory('/var/lib/glance/image-cache/') }
it 'has proper owner' do
expect(dir.owner).to eq('glance')
expect(dir.group).to eq('glance')
end
it 'has proper modes' do
expect(sprintf('%o', dir.mode)).to eq '755'
end
it 'creates directory recursively' do
expect(dir.recursive).to eq(true)
end
end
end
shared_examples 'glance-directory' do
describe '/etc/glance' do
let(:dir) { chef_run.directory('/etc/glance') }