Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: Restore sai log levels from LOGLEVEL_DB after saiDiscover #491

Merged
merged 1 commit into from
Jul 26, 2019

Conversation

qiluo-msft
Copy link
Contributor

@qiluo-msft qiluo-msft commented Jul 25, 2019

This bug is introduced from #316 (comment)

The bug is exposed by below steps. The expected log level for SAI_API_SWITCH is SAI_LOG_LEVEL_DEBUG.

admin@sonic:~$ swssloglevel -l SAI_LOG_LEVEL_DEBUG -s -c SWITCH
admin@sonic:~$ redis-cli -n 3 hgetall "SAI_API_SWITCH:SAI_API_SWITCH"
1) "LOGLEVEL"
2) "SAI_LOG_LEVEL_DEBUG"
3) "LOGOUTPUT"
4) "SYSLOG"
admin@sonic:~$ sudo systemctl restart swss
admin@sonic:~$ redis-cli -n 3 hgetall "SAI_API_SWITCH:SAI_API_SWITCH"
1) "LOGLEVEL"
2) "SAI_LOG_LEVEL_DEBUG"
3) "LOGOUTPUT"
4) "SYSLOG"
admin@sonic:~$ sudo grep "loglevel SAI_API_SWITCH" /var/log/syslog
Jul 25 00:00:28.280667 sonic NOTICE syncd#syncd: :- saiLoglevelNotify: Setting SAI loglevel SAI_API_SWITCH to SAI_LOG_LEVEL_DEBUG
Jul 25 00:04:47.411408 sonic NOTICE syncd#syncd: :- saiLoglevelNotify: Setting SAI loglevel SAI_API_SWITCH to SAI_LOG_LEVEL_DEBUG
Jul 25 00:06:31.440304 sonic NOTICE syncd#syncd: :- saiLoglevelNotify: Setting SAI loglevel SAI_API_SWITCH to SAI_LOG_LEVEL_CRITICAL
Jul 25 00:06:31.663183 sonic NOTICE syncd#syncd: :- saiLoglevelNotify: Setting SAI loglevel SAI_API_SWITCH to SAI_LOG_LEVEL_NOTICE

The first syslog line is for swssloglevel
The 3 later syslog lines are for systemctl restart swss

After this fix:

admin@sonic:~$ sudo systemctl restart swss
admin@sonic:~$ sudo grep "loglevel SAI_API_SWITCH" /var/log/syslog
Jul 25 00:10:43.058437 sonic NOTICE syncd#syncd: :- saiLoglevelNotify: Setting SAI loglevel SAI_API_SWITCH to SAI_LOG_LEVEL_DEBUG
Jul 25 00:12:07.920069 sonic NOTICE syncd#syncd: :- saiLoglevelNotify: Setting SAI loglevel SAI_API_SWITCH to SAI_LOG_LEVEL_CRITICAL
Jul 25 00:12:08.133814 sonic NOTICE syncd#syncd: :- saiLoglevelNotify: Setting SAI loglevel SAI_API_SWITCH to SAI_LOG_LEVEL_DEBUG

The 3 syslog lines are for systemctl restart swss

@pavel-shirshov
Copy link
Contributor

@yxieca patch for 201811 should be

pavelsh@pavelsh-vm:~/disk2/public/sonic-buildimage/src/sonic-sairedis$ git diff
diff --git a/syncd/syncd.h b/syncd/syncd.h
index 9ce4dc4..207fa56 100644
--- a/syncd/syncd.h
+++ b/syncd/syncd.h
@@ -141,4 +141,6 @@ void set_sai_api_log_min_prio(
 
 bool enableUnittests();
 
+void set_sai_api_loglevel();
+
 #endif // __SYNCD_H__
diff --git a/syncd/syncd_saiswitch.cpp b/syncd/syncd_saiswitch.cpp
index e90369f..ab6a5d5 100644
--- a/syncd/syncd_saiswitch.cpp
+++ b/syncd/syncd_saiswitch.cpp
@@ -971,7 +971,7 @@ void SaiSwitch::helperDiscover()
 
         saiDiscover(m_switch_rid, m_discovered_rids);
 
-        set_sai_api_log_min_prio("SAI_LOG_LEVEL_NOTICE");
+        set_sai_api_loglevel();
     }
 
     SWSS_LOG_NOTICE("discovered objects count: %zu", m_discovered_rids.size());

@qiluo-msft qiluo-msft merged commit 6937051 into sonic-net:master Jul 26, 2019
@qiluo-msft qiluo-msft deleted the qiluo/restorelog branch July 26, 2019 22:12
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants