Skip to content

Commit e3caf6e

Browse files
Echo chef-client.log when a node fails to bootstrap
This helps with investigating bootstrap failures in cases CloudWatch logs are not available. Older CINC was outputting logs to STDOUT even when --logfile is specified. i.e. CINC was outputting logs to both STDOUT and the log file. Sometime in CINC 16, it stopped outputting logs to STDOUT when --logfile is specified. There are no clear changelog items. But there are some discussions around it: https://discourse.chef.io/t/chef-log-not-printing-for-console-in-chef-client-16-6-14/17983
1 parent d2ea61e commit e3caf6e

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ CHANGELOG
44
3.14.0
55
------
66

7+
**ENHANCEMENTS**
8+
- Echo chef-client log when a node fails to bootstrap. This helps with investigating bootstrap failures in cases CloudWatch logs are not available.
9+
710
**CHANGES**
811
- Ubuntu 20.04 is no longer supported.
912
- Support prioritized and capacity-optimized-prioritized Allocation Strategy

cli/src/pcluster/resources/compute_node/user_data.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ write_files:
7070
function error_exit
7171
{
7272
echo "Bootstrap failed with error: $1"
73+
# Echo chef-client.log to console logs for debugging
74+
echo "========== BEGIN CHEF-CLIENT.LOG =========="
75+
cat /var/log/chef-client.log || echo "chef-client.log not found"
76+
echo "========== END CHEF-CLIENT.LOG ==========="
7377
# wait logs flush before signaling the failure
7478
sleep 10
7579
# TODO: add possibility to override this behavior and keep the instance for debugging
@@ -173,6 +177,10 @@ MIME-Version: 1.0
173177
function error_exit
174178
{
175179
echo "Timed-out when bootstrapping instance"
180+
# Echo chef-client.log to console logs for debugging
181+
echo "========== BEGIN CHEF-CLIENT.LOG =========="
182+
cat /var/log/chef-client.log || echo "chef-client.log not found"
183+
echo "========== END CHEF-CLIENT.LOG ==========="
176184
sleep 10 # Allow logs to propagate
177185
shutdown -h now
178186
exit 1

cli/src/pcluster/resources/head_node/user_data.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ MIME-Version: 1.0
6464

6565
function error_exit
6666
{
67+
# Echo chef-client.log to console logs for debugging
68+
echo "========== BEGIN CHEF-CLIENT.LOG =========="
69+
cat /var/log/chef-client.log || echo "chef-client.log not found"
70+
echo "========== END CHEF-CLIENT.LOG ==========="
6771
# wait logs flush before signaling the failure
6872
sleep 10
6973
# trim the error message because there is a size limit of 4096 bytes for cfn-signal

cli/src/pcluster/resources/login_node/user_data.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ write_files:
5757
function error_exit
5858
{
5959
echo "Bootstrap failed with error: $1"
60+
# Echo chef-client.log to console logs for debugging
61+
echo "========== BEGIN CHEF-CLIENT.LOG =========="
62+
cat /var/log/chef-client.log || echo "chef-client.log not found"
63+
echo "========== END CHEF-CLIENT.LOG ==========="
6064
# wait logs flush before signaling the failure
6165
sleep 10
6266
# TODO: add possibility to override this behavior and keep the instance for debugging
@@ -145,6 +149,10 @@ MIME-Version: 1.0
145149
function error_exit
146150
{
147151
echo "Timed-out when bootstrapping instance"
152+
# Echo chef-client.log to console logs for debugging
153+
echo "========== BEGIN CHEF-CLIENT.LOG =========="
154+
cat /var/log/chef-client.log || echo "chef-client.log not found"
155+
echo "========== END CHEF-CLIENT.LOG ==========="
148156
sleep 10 # Allow logs to propagate
149157
shutdown -h now
150158
exit 1

0 commit comments

Comments
 (0)