21
21
event_log_err = node [ 'cluster' ] [ 'scheduler_plugin' ] [ 'handler_log_err' ]
22
22
event_cwd = node [ 'cluster' ] [ 'scheduler_plugin' ] [ 'home' ]
23
23
event_user = node [ 'cluster' ] [ 'scheduler_plugin' ] [ 'user' ]
24
+ event_user_group = node [ 'cluster' ] [ 'scheduler_plugin' ] [ 'group' ]
24
25
event_timeout = 3600
25
26
event_env = build_env
26
27
event_log_prefix_error = "%Y-%m-%d %H:%M:%S,000 - [#{ new_resource . event_name } ] - ERROR:"
30
31
# 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
31
32
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 } ; } " \
32
33
"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 )
34
35
cmd . run_command
35
36
36
37
if cmd . error?
@@ -85,7 +86,9 @@ def build_env
85
86
end
86
87
end
87
88
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
89
92
90
93
# Load static env from file or build it if file not found
91
94
source_handler_env = "#{ node [ 'cluster' ] [ 'shared_dir' ] } /handler-env.json"
@@ -109,7 +112,9 @@ def build_env
109
112
def copy_config ( config_type , source_config , target_config )
110
113
raise "Expected #{ config_type } file not found in (#{ source_config } )" unless ::File . exist? ( source_config )
111
114
115
+ Chef ::Log . info ( "Copying #{ config_type } file from (#{ source_config } ) to (#{ target_config } )" )
112
116
FileUtils . cp ( source_config , target_config )
117
+ FileUtils . chown ( node [ 'cluster' ] [ 'scheduler_plugin' ] [ 'user' ] , node [ 'cluster' ] [ 'scheduler_plugin' ] [ 'group' ] , target_config )
113
118
end
114
119
115
120
def build_dynamic_env
0 commit comments