Skip to content

Delete cluster name state file whenever slurm accounting is configured or updated #2994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@
retry_delay 10
end unless kitchen_test? || (node['cluster']['node_type'] == "ExternalSlurmDbd")

bash "Remove existing cluster name state file" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please cover this new logic with a spec test?

user 'root'
group 'root'
code <<-CLUSTERSTATE
rm /var/spool/slurm.state/clustername
CLUSTERSTATE
only_if { ::File.exist?('/var/spool/slurm.state/clustername') }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using an only_if rather than having a rm-f?

end

bash "bootstrap slurm database" do
user 'root'
group 'root'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@
supports restart: false
action %i(disable stop)
end

bash "Remove existing cluster name state file" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please cover this new logic with a spec test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is duplicated. What about reducing code duplication by defining this logic into a function and call that function?

user 'root'
group 'root'
code <<-CLUSTERSTATE
rm /var/spool/slurm.state/clustername
CLUSTERSTATE
only_if { ::File.exist?('/var/spool/slurm.state/clustername') }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'spec_helper'

describe 'aws-parallelcluster-slurm::clear_slurm_accounting' do
for_all_oses do |platform, version|
context "on #{platform}#{version}" do
cached(:chef_run) do
runner = runner(platform: platform, version: version) do |node|
mock_file_exists("/var/spool/slurm.state/clustername", true)
node.override['cluster']['slurmdbd_service_enabled'] = true
end
runner.converge(described_recipe)
end
cached(:node) { chef_run.node }

it 'stops the slurm database daemon' do
is_expected.to disable_service("slurmdbd")
end

it 'deletes the Slurm database password update script' do
is_expected.to delete_file("#{node['cluster']['scripts_dir']}/slurm/update_slurm_database_password.sh")
end

it 'Removes existing cluster name state file' do
is_expected.to run_bash("Remove existing cluster name state file")
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
allow_any_instance_of(Object).to receive(:are_mount_or_unmount_required?).and_return(false)
allow_any_instance_of(Object).to receive(:dig).and_return(true)
RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
mock_file_exists("/var/spool/slurm.state/clustername", true)
node.override['cluster']['slurmdbd_service_enabled'] = enable_service
end
runner.converge(described_recipe)
Expand Down Expand Up @@ -70,6 +71,9 @@
)
end
if enable_service == "true"
it 'Removes existing cluster name state file' do
is_expected.to run_bash("Remove existing cluster name state file")
end
it 'starts the slurm database daemon' do
is_expected.to enable_service("slurmdbd")
is_expected.to start_service("slurmdbd")
Expand Down
Loading