diff --git a/Berksfile.lock b/Berksfile.lock index f6b37ee..a77c01b 100644 --- a/Berksfile.lock +++ b/Berksfile.lock @@ -2,8 +2,8 @@ "sha": "ba71763fac936d414bd4a63f004357f86f6e1bfb", "sources": { "openstack-block-storage": { - "locked_version": "7.0.2", - "constraint": "= 7.0.2", + "locked_version": "7.0.3", + "constraint": "= 7.0.3", "path": "." }, "openstack-image": { diff --git a/CHANGELOG.md b/CHANGELOG.md index d135563..a587ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ openstack-block-storage Cookbook CHANGELOG ============================== This file is used to list changes made in each version of the openstack-block-storage cookbook. +v7.0.3 +------ +### Bug +- change audit cronjob binary path depending on platform, refactored some tests + v7.0.2 ------ ### Improvement diff --git a/attributes/default.rb b/attributes/default.rb index 540aafd..7f0d2f2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -108,6 +108,7 @@ default["openstack"]["block-storage"]["syslog"]["config_facility"] = "local2" default["openstack"]["block-storage"]["api"]["ratelimit"] = "True" default["openstack"]["block-storage"]["cron"]["minute"] = '00' +default["openstack"]["block-storage"]["cron"]["audit_logfile"] = "/var/log/cinder/audit.log" default["openstack"]["block-storage"]["volume"]["state_path"] = "/var/lib/cinder" default["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.driver.ISCSIDriver" diff --git a/metadata.rb b/metadata.rb index 8b37e15..ed54eb1 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer_email "cookbooks@lists.tfoundry.com" license "Apache 2.0" description "The OpenStack Advanced Volume Management service Cinder." long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "7.0.2" +version "7.0.3" recipe "openstack-block-storage::common", "Defines the common pieces of repeated code from the other recipes" recipe "openstack-block-storage::api", "Installs the cinder-api, sets up the cinder database, and cinder service/user/endpoints in keystone" diff --git a/recipes/scheduler.rb b/recipes/scheduler.rb index 1730674..8e5fcc9 100644 --- a/recipes/scheduler.rb +++ b/recipes/scheduler.rb @@ -55,6 +55,9 @@ service "cinder-scheduler" do subscribes :restart, "template[/etc/cinder/cinder.conf]" end +audit_bin_dir = platform?("ubuntu") ? "/usr/bin" : "/usr/local/bin" +audit_log = node["openstack"]["block-storage"]["cron"]["audit_logfile"] + if node["openstack"]["metering"] scheduler_role = node["openstack"]["block-storage"]["scheduler_role"] results = search(:node, "roles:#{scheduler_role}") @@ -67,7 +70,7 @@ if node["openstack"]["metering"] minute node["openstack"]["block-storage"]["cron"]["minute"] month node["openstack"]["block-storage"]["cron"]["month"] || '*' weekday node["openstack"]["block-storage"]["cron"]["weekday"] || '*' - command "/usr/local/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log 2>&1" + command "#{audit_bin_dir}/cinder-volume-usage-audit > #{audit_log} 2>&1" action cron_node == node.name ? :create : :delete user node["openstack"]["block-storage"]["user"] end diff --git a/spec/scheduler_spec.rb b/spec/scheduler_spec.rb index 54042e2..8c167c6 100644 --- a/spec/scheduler_spec.rb +++ b/spec/scheduler_spec.rb @@ -74,38 +74,34 @@ describe "openstack-block-storage::scheduler" do end chef_run.converge "openstack-block-storage::scheduler" cron = chef_run.cron "cinder-volume-usage-audit" - expect(cron.command).to match(/\/usr\/local\/bin\/cinder-volume-usage-audit/) - expect(cron.command).to match(/\/var\/log\/cinder\/audit.log/) - expect(cron.minute).to eq "00" - expect(cron.hour).to eq "*" - expect(cron.day).to eq "*" - expect(cron.weekday).to eq "*" - expect(cron.month).to eq "*" - expect(cron.user).to eq "cinder" + bin_str="/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log" + expect(cron.command).to match(/#{bin_str}/) + crontests = [ [:minute, '00'], [:hour, '*'], [:day, '*'], + [:weekday, '*'], [:month, '*'], [:user, 'cinder'] ] + crontests.each do |k,v| + expect(cron.send(k)).to eq v + end expect(cron.action).to include :create end it "creates cron metering custom" do + crontests = [ [:minute, '50'], [:hour, '23'], [:day, '6'], + [:weekday, '5'], [:month, '11'], [:user, 'foobar'] ] ::Chef::Recipe.any_instance.stub(:search). with(:node, "roles:os-block-storage-scheduler"). and_return([OpenStruct.new(:name => "foobar")]) chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS do |n| n.set["openstack"]["metering"] = true - n.set["openstack"]["block-storage"]["cron"]["minute"] = 50 - n.set["openstack"]["block-storage"]["cron"]["hour"] = 23 - n.set["openstack"]["block-storage"]["cron"]["day"] = 6 - n.set["openstack"]["block-storage"]["cron"]["weekday"] = 5 - n.set["openstack"]["block-storage"]["cron"]["month"] = 11 + crontests.each do |k,v| + n.set["openstack"]["block-storage"]["cron"][k.to_s] = v + end n.set["openstack"]["block-storage"]["user"] = "foobar" end chef_run.converge "openstack-block-storage::scheduler" cron = chef_run.cron "cinder-volume-usage-audit" - expect(cron.minute).to eq "50" - expect(cron.hour).to eq "23" - expect(cron.day).to eq "6" - expect(cron.weekday).to eq "5" - expect(cron.month).to eq "11" - expect(cron.user).to eq "foobar" + crontests.each do |k,v| + expect(cron.send(k)).to eq v + end expect(cron.action).to include :delete end