Skip to content

Commit

Permalink
Enhance the error message output mechanism (#14384)
Browse files Browse the repository at this point in the history
#### Why I did it

Enhance the error message output mechanism during swss docker creating

#### How I did it

Capture the output to stderr of `sonic-cfggen` and output it using `echo` to make sure the error message will be logged in syslog.

#### How to verify it

Manually test
  • Loading branch information
stephenxs authored and mssonicbld committed Apr 23, 2023
1 parent d859a4e commit 1d3fa0b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,25 @@ start() {
{%- if docker_container_name == "swss" %}
# Generate the asic_table.json and peripheral_table.json
if [ ! -f /etc/sonic/asic_table.json ] && [ -f /usr/share/sonic/templates/asic_table.j2 ]; then
sonic-cfggen -d -t /usr/share/sonic/templates/asic_table.j2 > /etc/sonic/asic_table.json
sonic-cfggen -d -t /usr/share/sonic/templates/asic_table.j2 > /etc/sonic/asic_table.json 2> errorlog.txt
if [[ $? -ne 0 ]] ; then
echo "sonic-cfggen failed to render asic_table.json"
echo "$(cat errorlog.txt)"
fi
fi
if [ ! -f /etc/sonic/peripheral_table.json ] && [ -f /usr/share/sonic/device/$PLATFORM/port_peripheral_config.j2 ]; then
sonic-cfggen -d -t /usr/share/sonic/device/$PLATFORM/port_peripheral_config.j2 > /etc/sonic/peripheral_table.json
sonic-cfggen -d -t /usr/share/sonic/device/$PLATFORM/port_peripheral_config.j2 > /etc/sonic/peripheral_table.json 2> errorlog.txt
if [[ $? -ne 0 ]] ; then
echo "sonic-cfggen failed to render peripheral_table.json"
echo "$(cat errorlog.txt)"
fi
fi
if [ ! -f /etc/sonic/zero_profiles.json ] && [ -f /usr/share/sonic/templates/zero_profiles.j2 ]; then
sonic-cfggen -d -t /usr/share/sonic/device/$PLATFORM/zero_profiles.j2 > /etc/sonic/zero_profiles.json
sonic-cfggen -d -t /usr/share/sonic/device/$PLATFORM/zero_profiles.j2 > /etc/sonic/zero_profiles.json 2> errorlog.txt
if [[ $? -ne 0 ]] ; then
echo "sonic-cfggen failed to render zero_profiles.json"
echo "$(cat errorlog.txt)"
fi
fi

{%- if enable_asan == "y" %}
Expand Down

0 comments on commit 1d3fa0b

Please sign in to comment.