From d7be5a021acbf1fb822a865ea720a92583c9a2e7 Mon Sep 17 00:00:00 2001 From: arlakshm <55814491+arlakshm@users.noreply.github.com> Date: Fri, 22 Jan 2021 09:42:19 -0800 Subject: [PATCH] [Multi Asic] support of swss.rec and sairedis.rec for multi asic (#6310) Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com - Why I did it This PR has the changes to support having different swss.rec and sairedis.rec for each asic. The logrotate script is updated as well - How I did it Update the orchagent.sh script to use the logfile name options in these PRs(Azure/sonic-swss#1546 and Azure/sonic-sairedis#747) In multi asic platforms the record files will be different for each asic, with the format swss.asic{x}.rec and sairedis.asic{x}.rec Update the logrotate script for multiasic platform . --- dockers/docker-orchagent/orchagent.sh | 5 +++++ .../logrotate/logrotate.d/rsyslog | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/dockers/docker-orchagent/orchagent.sh b/dockers/docker-orchagent/orchagent.sh index 45715dc61f9c..aaa047a42036 100755 --- a/dockers/docker-orchagent/orchagent.sh +++ b/dockers/docker-orchagent/orchagent.sh @@ -41,6 +41,11 @@ then ORCHAGENT_ARGS+="-i $asic_id " fi +# for multi asic platforms add the asic name to the record file names +if [[ "$NAMESPACE_ID" ]]; then + ORCHAGENT_ARGS+="-f swss.asic$NAMESPACE_ID.rec -j sairedis.asic$NAMESPACE_ID.rec " +fi + # Add platform specific arguments if necessary if [ "$platform" == "broadcom" ]; then ORCHAGENT_ARGS+="-m $MAC_ADDRESS" diff --git a/files/image_config/logrotate/logrotate.d/rsyslog b/files/image_config/logrotate/logrotate.d/rsyslog index 792e3e9a2d57..cbf6e722eb90 100644 --- a/files/image_config/logrotate/logrotate.d/rsyslog +++ b/files/image_config/logrotate/logrotate.d/rsyslog @@ -30,8 +30,8 @@ /var/log/telemetry.log /var/log/frr/bgpd.log /var/log/frr/zebra.log -/var/log/swss/sairedis.rec -/var/log/swss/swss.rec +/var/log/swss/sairedis*.rec +/var/log/swss/swss*.rec { size 1M rotate 5000 @@ -85,7 +85,22 @@ endscript postrotate if [ $(echo $1 | grep -c "/var/log/swss/") -gt 0 ]; then - pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true + # for multi asic platforms, there are multiple orchagents + # send the SIGHUP only to the orchagent the which needs log file rotation + PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform` + ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf + if [ -f "$ASIC_CONF" ]; then + . $ASIC_CONF + fi + if [ $NUM_ASIC -gt 1 ]; then + log_file=$1 + log_file_name=${log_file#/var/log/swss/} + logger -p syslog.info -t "logrotate" "Sending SIGHUP to OA log_file_name: $log_file_name" + pgrep -xa orchagent | grep $log_file_name | awk '{ print $1; }' | xargs /bin/kill -HUP 2>/dev/null || true + else + logger -p syslog.info -t "logrotate" "Sending SIGHUP to OA log_file_name: $1" + pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true + fi else /bin/kill -HUP $(cat /var/run/rsyslogd.pid) fi