Skip to content

Commit c3b3be6

Browse files
committed
Change ownership for byos config files
Signed-off-by: Luca Carrogu <[email protected]>
1 parent 9c82b29 commit c3b3be6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cookbooks/aws-parallelcluster-scheduler-plugin/resources/execute_event_handler.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
event_log_err = node['cluster']['scheduler_plugin']['handler_log_err']
2222
event_cwd = node['cluster']['scheduler_plugin']['home']
2323
event_user = node['cluster']['scheduler_plugin']['user']
24+
event_user_group = node['cluster']['scheduler_plugin']['group']
2425
event_timeout = 3600
2526
event_env = build_env
2627
event_log_prefix_error = "%Y-%m-%d %H:%M:%S,000 - [#{new_resource.event_name}] - ERROR:"
@@ -30,7 +31,7 @@
3031
# switch stderr/stdout with (2>&1 1>&3-), process error (now on stdout), switch back stdout/stderr with (3>&1 1>&2) and then process output
3132
event_command = Shellwords.escape("set -o pipefail; { (#{new_resource.event_command}) 2>&1 1>&3- | ts '#{event_log_prefix_error}' | tee -a #{event_log_err}; } " \
3233
"3>&1 1>&2 | ts '#{event_log_prefix_info}' | tee -a #{event_log_out}")
33-
cmd = Mixlib::ShellOut.new("/bin/bash -c #{event_command}", user: event_user, group: event_user, login: true, env: event_env, cwd: event_cwd, timeout: event_timeout)
34+
cmd = Mixlib::ShellOut.new("/bin/bash -c #{event_command}", user: event_user, group: event_user_group, login: true, env: event_env, cwd: event_cwd, timeout: event_timeout)
3435
cmd.run_command
3536

3637
if cmd.error?
@@ -85,7 +86,9 @@ def build_env
8586
end
8687
end
8788

88-
FileUtils.cp(source_scheduler_plugin_substack_outputs, target_scheduler_plugin_substack_outputs) if ::File.exist?(source_scheduler_plugin_substack_outputs)
89+
if ::File.exist?(source_scheduler_plugin_substack_outputs)
90+
copy_config("scheduler plugin substack outputs", source_scheduler_plugin_substack_outputs, target_scheduler_plugin_substack_outputs)
91+
end
8992

9093
# Load static env from file or build it if file not found
9194
source_handler_env = "#{node['cluster']['shared_dir']}/handler-env.json"
@@ -109,7 +112,9 @@ def build_env
109112
def copy_config(config_type, source_config, target_config)
110113
raise "Expected #{config_type} file not found in (#{source_config})" unless ::File.exist?(source_config)
111114

115+
Chef::Log.info("Copying #{config_type} file from (#{source_config}) to (#{target_config})")
112116
FileUtils.cp(source_config, target_config)
117+
FileUtils.chown(node['cluster']['scheduler_plugin']['user'], node['cluster']['scheduler_plugin']['group'], target_config)
113118
end
114119

115120
def build_dynamic_env

0 commit comments

Comments
 (0)