From daf5ec993fa5c47b40a9c4218ef62b9799b2d956 Mon Sep 17 00:00:00 2001 From: Jacopo De Amicis Date: Wed, 31 Jan 2024 15:45:27 +0100 Subject: [PATCH] Configure S3 mountpoint for external slurmdbd Install mountpoint-s3 and mount the S3 bucket of the external slurmdbd stack on `/opt/slurm/etc`. The slurmdbd configuration files are already generated from a template with a `:create_if_missing` action, meaning that if the files are already present in the bucket they will not be overwritten. Signed-off-by: Jacopo De Amicis --- .../recipes/external_slurmdbd_config.rb | 2 + .../config_external_slurmdbd_s3_mountpoint.rb | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 cookbooks/aws-parallelcluster-slurm/recipes/config/config_external_slurmdbd_s3_mountpoint.rb diff --git a/cookbooks/aws-parallelcluster-entrypoints/recipes/external_slurmdbd_config.rb b/cookbooks/aws-parallelcluster-entrypoints/recipes/external_slurmdbd_config.rb index 2d6d67dd79..358294a206 100644 --- a/cookbooks/aws-parallelcluster-entrypoints/recipes/external_slurmdbd_config.rb +++ b/cookbooks/aws-parallelcluster-entrypoints/recipes/external_slurmdbd_config.rb @@ -49,6 +49,8 @@ include_recipe 'aws-parallelcluster-slurm::config_head_node_directories' +include_recipe 'aws-parallelcluster-slurm::config_external_slurmdbd_s3_mountpoint' + # TODO: move this template to a separate recipe # TODO: add a logic in update_munge_key.sh.erb to skip sharing munge key to shared dir template "#{node['cluster']['scripts_dir']}/slurm/update_munge_key.sh" do diff --git a/cookbooks/aws-parallelcluster-slurm/recipes/config/config_external_slurmdbd_s3_mountpoint.rb b/cookbooks/aws-parallelcluster-slurm/recipes/config/config_external_slurmdbd_s3_mountpoint.rb new file mode 100644 index 0000000000..4218ef3d08 --- /dev/null +++ b/cookbooks/aws-parallelcluster-slurm/recipes/config/config_external_slurmdbd_s3_mountpoint.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# +# Cookbook:: aws-parallelcluster-slurm +# Recipe:: config_head_node +# +# Copyright:: 2013-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the +# License. A copy of the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES +# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and +# limitations under the License. + +ext = platform?('ubuntu') ? "deb" : "rpm" +subtree = arm? ? "arm64" : "x86_64" +mount_s3_url = "https://s3.amazonaws.com/mountpoint-s3-release/latest/#{subtree}/mount-s3.#{ext}" +download_path = "/tmp/mount-s3.#{ext}" + +remote_file 'download mountpoint-s3' do + source mount_s3_url + path download_path + retries 3 + retry_delay 5 + action :create_if_missing +end + +package "Install mountpoint-s3" do + source download_path +end + +execute 'mount slurmdbd configuration via S3' do + command "mount-s3 --allow-delete --uid $(id -u slurm) --gid $(id -g slurm) --dir-mode 0755 --file-mode 0600 #{node["slurmdbd_s3_bucket_name"]} /opt/slurm/etc/" + user 'root' +end