From 59440f28a3db5edaa123ae9ed34ad29f20d678f3 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 29 Oct 2019 11:20:41 -0700 Subject: [PATCH] Allow buffer profile apply after init (#1099) * Allow buffer profile application after init (i.e., at run time) Signed-off-by: Wenda Ni * Address comment: Alert when a buffer profile is applied after the physical port is brought up Signed-off-by: Wenda Ni * Remove unnecessary space Signed-off-by: Wenda Ni * Correct logic Signed-off-by: Wenda Ni * Correct compile error Signed-off-by: Wenda Ni --- orchagent/bufferorch.cpp | 28 ++++++++++++++++++++++++++-- orchagent/portsorch.cpp | 11 +++++++++++ orchagent/portsorch.h | 1 + portsyncd/portsyncd.cpp | 1 - 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index c560551bca53..2257e927bd4c 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -579,7 +579,19 @@ task_process_status BufferOrch::processQueue(Consumer &consumer) } else { - SWSS_LOG_ERROR("Queue profile '%s' was inserted after BufferOrch init", key.c_str()); + // If a buffer queue profile is not in the initial CONFIG_DB BUFFER_QUEUE table + // at BufferOrch object instantiation, it is considered being applied + // at run time, and, in this case, is not tracked in the m_ready_list. It is up to + // the application to guarantee the set order that the buffer queue profile + // should be applied to a physical port before the physical port is brought up to + // carry traffic. Here, we alert to application through syslog when such a wrong + // set order is detected. + for (const auto &port_name : port_names) + { + if (gPortsOrch->isPortAdminUp(port_name)) { + SWSS_LOG_ERROR("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str()); + } + } } return task_process_status::task_success; @@ -666,7 +678,19 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer) } else { - SWSS_LOG_ERROR("PG profile '%s' was inserted after BufferOrch init", key.c_str()); + // If a buffer pg profile is not in the initial CONFIG_DB BUFFER_PG table + // at BufferOrch object instantiation, it is considered being applied + // at run time, and, in this case, is not tracked in the m_ready_list. It is up to + // the application to guarantee the set order that the buffer pg profile + // should be applied to a physical port before the physical port is brought up to + // carry traffic. Here, we alert to application through syslog when such a wrong + // set order is detected. + for (const auto &port_name : port_names) + { + if (gPortsOrch->isPortAdminUp(port_name)) { + SWSS_LOG_ERROR("PG profile '%s' applied after port %s is up", key.c_str(), port_name.c_str()); + } + } } return task_process_status::task_success; diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 690159375489..ae876467fb23 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -400,6 +400,17 @@ bool PortsOrch::isInitDone() return m_initDone; } +bool PortsOrch::isPortAdminUp(const string &alias) +{ + auto it = m_portList.find(alias); + if (it == m_portList.end()) + { + SWSS_LOG_ERROR("Failed to get Port object by port alias: %s", alias.c_str()); + return false; + } + + return it->second.m_admin_state_up; +} map& PortsOrch::getAllPorts() { diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index d2819e62eafe..6b12dd24fb06 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -57,6 +57,7 @@ class PortsOrch : public Orch, public Subject bool allPortsReady(); bool isInitDone(); + bool isPortAdminUp(const string &alias); map& getAllPorts(); bool bake() override; diff --git a/portsyncd/portsyncd.cpp b/portsyncd/portsyncd.cpp index 132e1cbf839f..7efec9d58a8e 100644 --- a/portsyncd/portsyncd.cpp +++ b/portsyncd/portsyncd.cpp @@ -166,7 +166,6 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - return 1; }