Skip to content

Commit

Permalink
Merge pull request #39 from cdwilhelm/curtd-dev
Browse files Browse the repository at this point in the history
remove rl6 command and use rl10
  • Loading branch information
rshade committed Feb 11, 2016
2 parents d2542dd + 2305503 commit 92b9a3c
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 87 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ script: bundle exec strainer test --except kitchen
notifications:
slack:
secure: TIZFCcm+FcFBB6IoEBv2174qwXe1SxVsGpkMe6eZjccVwmgRt2ik8To03Orpjy/2VOztuqJdDqmHOucbmoL/67W2rnAHjVk85dlGGv60Xqf4F+oSfmc0igESocfZLbv0yhD2SBDIt/RGRqQyGEW1YmNsk7QiFx0HqnXpn0aycaA=

10 changes: 8 additions & 2 deletions Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ metadata
cookbook 'collectd', github: 'rightscale-cookbooks-contrib/chef-collectd', branch: 'generalize_install_for_both_centos_and_ubuntu'
cookbook 'mysql', github: 'rightscale-cookbooks-contrib/mysql', branch: 'rs-fixes'
cookbook 'dns', github: 'rightscale-cookbooks-contrib/dns', branch: 'rightscale_development_v2'
cookbook 'build-essential', '~> 1.4.4'
#cookbook 'build-essential', '~> 2.2.4'
cookbook 'database', github: 'rightscale-cookbooks-contrib/database', branch: 'rs-fixes'

cookbook 'rightscale_backup',github: 'rightscale-cookbooks/rightscale_backup'
cookbook 'rightscale_volume',github: 'rightscale-cookbooks/rightscale_volume'
cookbook 'rightscale_tag',github: 'rightscale-cookbooks/rightscale_tag'
cookbook 'machine_tag',github: 'rightscale-cookbooks/machine_tag'
cookbook 'ephemeral_lvm',github:'rightscale-cookbooks/ephemeral_lvm'

group :integration do
cookbook 'apt', '~> 2.3.0'
cookbook 'runit', '1.6.0'
cookbook 'apt', '~> 2.9.2'
cookbook 'yum-epel', '~> 0.4.0'
cookbook 'curl', '~> 1.1.0'
cookbook 'fake', path: './test/cookbooks/fake'
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ records.
- `node['rs-mysql']['schedule']['enable']` - Enable/disable automated backups. Default is `false`.
- `node['rs-mysql']['schedule']['hour']` - The backup schedule hour. Default is `nil`.
- `node['rs-mysql']['schedule']['minute']` - The backup schedule minute. Default is `nil`.
- `node['rightscale']['decom_reason']` - Set from RL10 Shutdown Reason Rightscript to determine how to handle
rs-mysql::decommission behavior

# Recipes

Expand Down
35 changes: 0 additions & 35 deletions libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,41 +300,6 @@ def to_dm_name(name)
RsMysql::Helper.to_dm_name(name)
end

# Obtains the run state of the server. It uses the `rs_state` utility to get the current system run state.
# Possible values for this command:
# - booting
# - booting:reboot
# - operational
# - stranded
# - shutting-down:reboot
# - shutting-down:terminate
# - shutting-down:stop
#
# @return [String] the current system run state
#
def self.get_rs_run_state
state = shell_out!('rs_state --type=run').stdout.chomp
Chef::Log.info "The RightScale run state is: #{state.inspect}"
state
end

# Obtains the run state of the server. It uses the `rs_state` utility to get the current system run state.
# Possible values for this command:
# - booting
# - booting:reboot
# - operational
# - stranded
# - shutting-down:reboot
# - shutting-down:terminate
# - shutting-down:stop
#
# @return [String] the current system run state
#
# @see .get_rs_run_state
#
def get_rs_run_state
RsMysql::Helper.get_rs_run_state
end

private

Expand Down
10 changes: 5 additions & 5 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
license 'Apache 2.0'
description 'Installs and configures a MySQL server'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.1.9'
version '1.2.0'

depends 'chef_handler', '~> 1.1.6'
depends 'marker', '~> 1.0.1'
depends 'database', '~> 1.5.2'
depends 'mysql', '~> 4.0.18'
depends 'collectd', '~> 1.1.0'
depends 'rightscale_tag', '~> 1.0.2'
depends 'filesystem', '~> 0.10.0'
depends 'rightscale_tag', '~> 1.1.0'
depends 'filesystem', '0.10.2'
depends 'lvm', '~> 1.3.6'
depends 'rightscale_volume', '~> 1.2.7'
depends 'rightscale_backup', '~> 1.1.8'
depends 'rightscale_volume', '~> 1.3.0'
depends 'rightscale_backup', '~> 1.2.0'
depends 'dns', '~> 0.1.3'
depends 'git', '~> 4.0.2'

Expand Down
5 changes: 5 additions & 0 deletions recipes/collectd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@

include_recipe 'collectd::default'

rewind "package[collectd]" do
action :nothing
only_if {::File.exists?("/usr/sbin/collectd")}
end

# collectd::default recipe attempts to delete collectd plugins that were not
# created during the same runlist as this recipe. Some common plugins are installed
# as a part of base install which runs in a different runlist. This resource
Expand Down
11 changes: 6 additions & 5 deletions recipes/decommission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@

# Check for the safety attribute first
if node['rs-mysql']['device']['destroy_on_decommission'] != true &&
node['rs-mysql']['device']['destroy_on_decommission'] != 'true'
node['rs-mysql']['device']['destroy_on_decommission'] != 'true'
log "rs-mysql/device/destroy_on_decommission is set to '#{node['rs-mysql']['device']['destroy_on_decommission']}'" +
" skipping..."
# Check 'rs_run_state' and skip if the instance is rebooting or entering the stop state
elsif ['shutting-down:reboot', 'shutting-down:stop', 'shutting-down:unknown'].include?(get_rs_run_state)
# Check 'DECOM_REASON' from Shutdown Reason script and skip if the instance
# is rebooting or entering the stop state
elsif ['reboot', 'stop',].include?(node['rightscale']['decom_reason'])
log 'Skipping deletion of volumes as the instance is either rebooting or entering the stop state...'
# Detach and delete the volumes if the above safety conditions are satisfied
# Detach and delete the volumes if the above safety conditions are satisfied
else
# Delete the link created as /var/lib/mysql
link '/var/lib/mysql' do
Expand Down Expand Up @@ -89,7 +90,7 @@
action [:detach, :delete]
end
end
# If LVM is not used, we only have a single device. In this case, unmount, detach and delete the volume.
# If LVM is not used, we only have a single device. In this case, unmount, detach and delete the volume.
else
# Unmount the volume
log "Unmounting #{node['rs-mysql']['device']['mount_point']}"
Expand Down
2 changes: 1 addition & 1 deletion recipes/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
cron "backup_schedule_#{lineage}" do
minute schedule_minute
hour schedule_hour
command "rs_run_recipe --policy 'rs-mysql::backup' --name 'rs-mysql::backup'"
command "sudo rsc rl10 run_right_script /rll/run/right_script 'right_script=Mysql Server Backup - chef'"
action schedule_enable ? :create : :delete
end
4 changes: 0 additions & 4 deletions recipes/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@

detach_timeout = node['rs-mysql']['device']['detach_timeout'].to_i * device_count

execute "set decommission timeout to #{detach_timeout}" do
command "rs_config --set decommission_timeout #{detach_timeout}"
not_if "[ `rs_config --get decommission_timeout` -eq #{detach_timeout} ]"
end

each_device_size = (size.to_f / device_count.to_f).ceil

Expand Down
8 changes: 4 additions & 4 deletions recipes/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
device_nickname = node['rs-mysql']['device']['nickname']
size = node['rs-mysql']['device']['volume_size'].to_i

execute "set decommission timeout to #{detach_timeout}" do
command "rs_config --set decommission_timeout #{detach_timeout}"
not_if "[ `rs_config --get decommission_timeout` -eq #{detach_timeout} ]"
end
#execute "set decommission timeout to #{detach_timeout}" do
# command "rs_config --set decommission_timeout #{detach_timeout}"
# not_if "[ `rs_config --get decommission_timeout` -eq #{detach_timeout} ]"
#end


# Cloud-specific volume options
Expand Down
22 changes: 5 additions & 17 deletions spec/decommission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
node.set['rs-mysql']['backup']['lineage'] = 'testing'
node.set['rs-mysql']['server_repl_password'] = 'replpass'
node.set['rs-mysql']['server_root_password'] = 'rootpass'

end
end

Expand All @@ -25,22 +26,17 @@
context 'rs-mysql/device/destroy_on_decommission is set to true' do
let(:chef_runner_decommission) do
chef_runner.node.set['rs-mysql']['device']['destroy_on_decommission'] = true
chef_runner.node.set["rightscale"]["decom_reason"] = 'terminate'
chef_runner
end
let(:nickname) { chef_runner.converge(described_recipe).node['rs-mysql']['device']['nickname'] }

context 'RightScale run state is shutting-down:terminate' do
context 'RightScale run state is terminate' do
before do
stub_command('test -L /var/lib/mysql').and_return(true)
stub_command('[ `stat -c %h /var/lib/mysql/` -eq 2 ]').and_return(true)
stub_command('test -d /mnt/storage/mysql').and_return(true)
stub_command('test -f /var/lib/mysql/ib_logfile0').and_return(true)
rs_state = double
Mixlib::ShellOut.stub(:new).with('rs_state --type=run').and_return(rs_state)
allow(rs_state).to receive(:run_command)
allow(rs_state).to receive(:error!)
allow(rs_state).to receive(:live_stream=)
allow(rs_state).to receive(:stdout).and_return('shutting-down:terminate')
end

context 'LVM is not used' do
Expand Down Expand Up @@ -161,18 +157,10 @@
end
end

['shutting-down:reboot', 'shutting-down:stop'].each do |state|
['reboot', 'stop'].each do |state|
context "RightScale run state is #{state}" do
before do
rs_state = double
Mixlib::ShellOut.stub(:new).with('rs_state --type=run').and_return(rs_state)
allow(rs_state).to receive(:run_command)
allow(rs_state).to receive(:error!)
allow(rs_state).to receive(:live_stream=)
allow(rs_state).to receive(:stdout).and_return(state)
end

let(:chef_run) do
chef_runner_decommission.node.set["rightscale"]["decom_reason"] = state
chef_runner_decommission.converge(described_recipe)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/schedule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
expect(chef_run).to create_cron("backup_schedule_#{lineage}").with(
minute: chef_run.node['rs-mysql']['schedule']['minute'],
hour: chef_run.node['rs-mysql']['schedule']['hour'],
command: "rs_run_recipe --policy 'rs-mysql::backup' --name 'rs-mysql::backup'"
command: "sudo rsc rl10 run_right_script /rll/run/right_script 'right_script=Mysql Server Backup - chef'"
)
end
end
Expand All @@ -32,7 +32,7 @@

it 'deletes a crontab entry' do
expect(chef_run).to delete_cron("backup_schedule_#{lineage}").with(
command: "rs_run_recipe --policy 'rs-mysql::backup' --name 'rs-mysql::backup'"
command: "sudo rsc rl10 run_right_script /rll/run/right_script 'right_script=Mysql Server Backup - chef'"
)
end
end
Expand Down
6 changes: 0 additions & 6 deletions spec/stripe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@
end

before do
stub_command('[ `rs_config --get decommission_timeout` -eq 600 ]').and_return(false)
stub_command("/usr/bin/mysql -u root -e 'show databases;'").and_return(true)
end

context 'rs-mysql/restore/lineage is not set' do
let(:chef_run) { chef_runner.converge(described_recipe) }

it 'sets the decommission timeout' do
expect(chef_run).to run_execute("set decommission timeout to #{detach_timeout * 2}").with(
command: "rs_config --set decommission_timeout #{detach_timeout * 2}",
)
end

it 'creates two new volumes and attaches them' do
expect(chef_run).to create_rightscale_volume(nickname_1).with(
Expand Down
6 changes: 0 additions & 6 deletions spec/volume_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@
end

before do
stub_command('[ `rs_config --get decommission_timeout` -eq 300 ]').and_return(false)
stub_command("/usr/bin/mysql -u root -e 'show databases;'").and_return(true)
end

context 'rs-mysql/restore/lineage is not set' do
let(:chef_run) { chef_runner.converge(described_recipe) }

it 'sets the decommission timeout' do
expect(chef_run).to run_execute("set decommission timeout to #{detach_timeout}").with(
command: "rs_config --set decommission_timeout #{detach_timeout}",
)
end

it 'creates a new volume and attaches it' do
expect(chef_run).to create_rightscale_volume(nickname).with(
Expand Down

0 comments on commit 92b9a3c

Please sign in to comment.