Skip to content

Commit 00187b8

Browse files
Append pcluster CloudWatch config when CW agent is running
Before this commit, pcluster CW config is not loaded when CW agent is running on the custom AMI, causing the lack of logs on CloudWatch. This commit appends pcluster CW config regardless of whether the CW agent is running. Therefore, CW config in the custom AMI will be preserved in addition to pcluster CW config. If there are conflicting parameters, the parameters in pcluster CW config overwrites the config from custom AMI. Signed-off-by: Hanwen <[email protected]>
1 parent 0aaa259 commit 00187b8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

cookbooks/aws-parallelcluster-environment/resources/cloudwatch/partial/_cloudwatch_common.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ def package_path
175175
execute "cloudwatch-agent-start" do
176176
user 'root'
177177
timeout 300
178-
command "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
179-
not_if "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status | grep status | grep running"
178+
command "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
180179
end unless node['cluster']['cw_logging_enabled'] != 'true' || on_docker?
181180
end

cookbooks/aws-parallelcluster-environment/spec/unit/resources/cloudwatch_spec.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def self.configure(chef_run)
255255
is_expected.to run_execute("cloudwatch-agent-start").with(
256256
user: 'root',
257257
timeout: 300,
258-
command: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
258+
command: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
259259
)
260260
end
261261
end
@@ -309,8 +309,12 @@ def self.configure(chef_run)
309309
ConvergeCloudWatch.configure(runner)
310310
end
311311

312-
it 'does not start cloudwatch' do
313-
is_expected.not_to run_execute("cloudwatch-agent-start")
312+
it 'starts cloudwatch agent' do
313+
is_expected.to run_execute("cloudwatch-agent-start").with(
314+
user: 'root',
315+
timeout: 300,
316+
command: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
317+
)
314318
end
315319
end
316320
end

0 commit comments

Comments
 (0)