Skip to content

Commit

Permalink
Support managing oci.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock committed Feb 15, 2024
1 parent b58615c commit 26f0597
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
11 changes: 11 additions & 0 deletions manifests/common/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@
source => $slurm::cgroup_conf_source,
notify => $slurm::service_notify,
}

file { 'slurm-oci.conf':
ensure => 'file',
path => $slurm::oci_conf_path,
owner => 'root',
group => 'root',
mode => '0644',
content => $slurm::oci_conf_content,
source => $slurm::oci_conf_source,
notify => $slurm::service_notify,
}
}

if ($slurm::client or $slurm::slurmctld) and ($slurm::cli_filter_lua_source or $slurm::cli_filter_lua_content) {
Expand Down
53 changes: 53 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,28 @@
# @param cgroup_max_swap_percent
# @param cgroup_memory_swappiness
# @param cgroup_min_ram_space
# @param oci_conf_template
# @param oci_conf_source
# @param oci_container_path
# @param oci_create_env_file
# @param oci_debug_flags
# @param oci_disable_cleanup
# @param oci_disable_hooks
# @param oci_env_exclude
# @param oci_mount_spool_dir
# @param oci_run_time_env_exclude
# @param oci_file_debug
# @param oci_ignore_file_config_json
# @param oci_run_time_create
# @param oci_run_time_delete
# @param oci_run_time_kill
# @param oci_run_time_query
# @param oci_run_time_run
# @param oci_run_time_start
# @param oci_srun_path
# @param oci_srun_args
# @param oci_std_io_debug
# @param oci_syslog_debug
# @param slurm_sh_template
# @param slurm_csh_template
# @param profile_d_env_vars
Expand Down Expand Up @@ -373,6 +395,30 @@
Optional[Integer[0,100]] $cgroup_memory_swappiness = undef,
Integer $cgroup_min_ram_space = 30,

# OCI
String $oci_conf_template = 'slurm/oci.conf.erb',
Optional[String] $oci_conf_source = undef,
Optional[String[1]] $oci_container_path = undef,
String[1] $oci_create_env_file = 'disabled',
Optional[String[1]] $oci_debug_flags = undef,
Boolean $oci_disable_cleanup = false,
Optional[String[1]] $oci_disable_hooks = undef,
Optional[String[1]] $oci_env_exclude = undef,
Stdlib::Absolutepath $oci_mount_spool_dir = '/var/run/slurm/',
Optional[String[1]] $oci_run_time_env_exclude = undef,
Optional[String[1]] $oci_file_debug = undef,
Boolean $oci_ignore_file_config_json = false,
Optional[String[1]] $oci_run_time_create = undef,
Optional[String[1]] $oci_run_time_delete = undef,
Optional[String[1]] $oci_run_time_kill = undef,
Optional[String[1]] $oci_run_time_query = undef,
Optional[String[1]] $oci_run_time_run = undef,
Optional[String[1]] $oci_run_time_start = undef,
Optional[Stdlib::Absolutepath] $oci_srun_path = undef,
Optional[String[1]] $oci_srun_args = undef,
Optional[String[1]] $oci_std_io_debug = undef,
Optional[String[1]] $oci_syslog_debug = undef,

# profile.d
String[1] $slurm_sh_template = 'slurm/profile.d/slurm.sh.erb',
String[1] $slurm_csh_template = 'slurm/profile.d/slurm.csh.erb',
Expand Down Expand Up @@ -419,6 +465,7 @@
$gres_conf_path = "${conf_dir}/gres.conf"
$slurmdbd_conf_path = "${conf_dir}/slurmdbd.conf"
$cgroup_conf_path = "${conf_dir}/cgroup.conf"
$oci_conf_path = "${conf_dir}/oci.conf"
$plugstack_conf_path = "${conf_dir}/plugstack.conf"
$job_container_conf_path = "${conf_dir}/job_container.conf"
$jwt_key_path = "${conf_dir}/jwt.key"
Expand Down Expand Up @@ -553,6 +600,12 @@
$cgroup_conf_content = template($cgroup_conf_template)
}

if $oci_conf_source {
$oci_conf_content = undef
} else {
$oci_conf_content = template($oci_conf_template)
}

if $slurmd and $slurmd_service_ensure == 'running' and $reload_services and $facts['slurmd_version'] {
$slurmd_notify = Exec['slurmd reload']
} elsif $slurmd and $slurmd_service_ensure == 'running' and $restart_services {
Expand Down
53 changes: 53 additions & 0 deletions spec/shared_examples/slurm_common_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@
])
end

it do
is_expected.to contain_file('slurm-oci.conf').with(ensure: 'file',
path: '/etc/slurm/oci.conf',
owner: 'root',
group: 'root',
mode: '0644')
end

it 'has oci.conf with valid contents' do
verify_exact_file_contents(catalogue, 'slurm-oci.conf', [
'CreateEnvFile=disabled',
'DisableCleanup=false',
'MountSpoolDir="/var/run/slurm/"',
'IgnoreFileConfigJson=false'
])
end

it { is_expected.not_to contain_file('/etc/slurm/jwt.key') }

it do
Expand Down Expand Up @@ -426,13 +443,42 @@
end
end

context 'when oci parameters defined' do
let(:param_override) do
{
oci_env_exclude: '^(SLURM_CONF|SLURM_CONF_SERVER)=',
oci_run_time_env_exclude: '^(SLURM_CONF|SLURM_CONF_SERVER)=',
oci_run_time_delete: 'runc delete',
oci_run_time_kill: 'runc kill',
oci_run_time_query: 'runc query',
oci_run_time_run: 'runc run'
}
end

it 'has oci.conf with valid contents' do
verify_exact_file_contents(catalogue, 'slurm-oci.conf', [
'CreateEnvFile=disabled',
'DisableCleanup=false',
'EnvExclude="^(SLURM_CONF|SLURM_CONF_SERVER)="',
'MountSpoolDir="/var/run/slurm/"',
'RunTimeEnvExclude="^(SLURM_CONF|SLURM_CONF_SERVER)="',
'IgnoreFileConfigJson=false',
'RunTimeDelete="runc delete',
'RunTimeKill="runc kill"',
'RunTimeQuery="runc query"',
'RunTimeRun="runc run'
])
end
end

context 'when manage_slurm_conf => false' do
let(:param_override) { { manage_slurm_conf: false } }

it { is_expected.not_to contain_file('slurm.conf') }
it { is_expected.not_to contain_concat('slurm-topology.conf') }
it { is_expected.not_to contain_concat('plugstack.conf') }
it { is_expected.not_to contain_file('slurm-cgroup.conf') }
it { is_expected.not_to contain_file('slurm-oci.conf') }
it { is_expected.not_to contain_file('cgroup_allowed_devices_file.conf') }
end

Expand Down Expand Up @@ -479,4 +525,11 @@
it { is_expected.to contain_file('slurm-cgroup.conf').without_content }
it { is_expected.to contain_file('slurm-cgroup.conf').with_source('file:///path/cgroup.conf') }
end

context 'when oci_conf_source => "file:///path/oci.conf"' do
let(:param_override) { { oci_conf_source: 'file:///path/oci.conf' } }

it { is_expected.to contain_file('slurm-oci.conf').without_content }
it { is_expected.to contain_file('slurm-oci.conf').with_source('file:///path/oci.conf') }
end
end

0 comments on commit 26f0597

Please sign in to comment.