configDB enforcer for interface#357
Conversation
Support VLAN interface only for now Signed-off-by: Jipan Yang <[email protected]>
|
Has dependency on: |
intfconfd/Makefile.am
Outdated
| DBGFLAGS = -g | ||
| endif | ||
|
|
||
| intfconfd_SOURCES = intfconfd.cpp intfconf.cpp $(top_srcdir)/cfgorch/cfgorch.cpp |
There was a problem hiding this comment.
cfgorch [](start = 61, length = 7)
suggest merge "cfgorch", "intfconfd" into one directory #Closed
There was a problem hiding this comment.
Yes, cfgagent might be a good name for the directory. Will move intfconfd, vlanconfd and debug cli implmentation cfgmgrtest there. Actually that was the initial arrangement.
intfconfd/intfconf.cpp
Outdated
| #define VLAN_PREFIX "Vlan" | ||
| #define LAG_PREFIX "PortChannel" | ||
|
|
||
| IntfConf::IntfConf(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, vector<string> tableNames) : |
There was a problem hiding this comment.
vector [](start = 81, length = 6)
Do you want to copy a vector? #Closed
There was a problem hiding this comment.
The table names for different DB are different. a vector might not be a good fit here.
There was a problem hiding this comment.
I am not sure you are talking about the same thing. I mean that use a copied instance may cost much than a reference. #Closed
intfconfd/intfconf.cpp
Outdated
|
|
||
| cmd = "ip address " + opCmd + " "; | ||
| cmd += ipPrefixStr + " dev " + alias; | ||
| swss::exec(cmd, res); |
There was a problem hiding this comment.
exec [](start = 10, length = 4)
check the return value? #Closed
There was a problem hiding this comment.
Error has been logged in exec if there is any. In this case, error is not really expected.
That is common question for many functions in sonic, end 2 end feedback loop is missing.
There was a problem hiding this comment.
I don't agree. Locally if there is any error happens, you should check the return code all the levels up the stack, and quit as soon as possible, or recover depending on the situation. #Closed
There was a problem hiding this comment.
fine. But I don't see the same criteria applied in orchagent, syncd, those python code and etc.
We could start the endeavor from this.
intfconfd/intfconf.cpp
Outdated
| CfgOrch::syncCfgDB(CFG_VLAN_INTF_TABLE_NAME, m_cfgVlanIntfTable); | ||
| } | ||
|
|
||
| bool IntfConf::setIntfIp(string &alias, string &opCmd, string &ipPrefixStr) |
There was a problem hiding this comment.
string & [](start = 25, length = 8)
If using a reference, consider using a const reference if possible. #Closed
intfconfd/intfconf.cpp
Outdated
| return true; | ||
| } | ||
|
|
||
| bool IntfConf::isIntfStateOk(string &alias) |
There was a problem hiding this comment.
isIntfStateOk [](start = 15, length = 13)
suggest name: readyIntf
There was a problem hiding this comment.
Honestly I don't see readyIntf a better name than isIntfStateOk, we do put state ok in stateDB though it is not checked for now. If you insist on changing the name, I could do it.
There was a problem hiding this comment.
Just checking the code, there is nothing about "Ok" state. So I guess the original name is not perfect.
There was a problem hiding this comment.
Ok, will add code to check the state:
127.0.0.1:6379[6]> hgetall "PORT_TABLE|Ethernet47"
- "state"
- "ok"
There was a problem hiding this comment.
I don't see that you check "ok"
intfconfd/intfconf.cpp
Outdated
| continue; | ||
| } | ||
|
|
||
| IpPrefix ip_prefix(kfvKey(t).substr(kfvKey(t).find(CONFIGDB_KEY_SEPARATOR)+1)); |
There was a problem hiding this comment.
IpPrefix ip_prefix(kfvKey(t).substr(kfvKey(t).find(CONFIGDB_KEY_SEPARATOR)+1)); [](start = 8, length = 79)
Split into multiple statement. It is too complex to read. #Closed
| } | ||
| catch(const std::exception &e) | ||
| { | ||
| SWSS_LOG_ERROR("Runtime error: %s", e.what()); |
There was a problem hiding this comment.
return a non zero error code? #Closed
Signed-off-by: Jipan Yang <[email protected]>
.gitignore
Outdated
| teamsyncd/teamsyncd | ||
| fpmsyncd/fpmsyncd | ||
| intfsyncd/intfsyncd | ||
| cfgagent/intfconfd |
There was a problem hiding this comment.
can you rename to intfmgr?
The role of confd, orchagent, syncd are blurred, it is hard to have a clear cuts of different roles they are playing, so mgr can include all functions, which manages both asic and linux setup. therefore I prefer mgr name
There was a problem hiding this comment.
Ok, will rename them to intfmgr and vlanmgr. For switch table level configuration, besides switchmgr process itself, the configuration may be used by multiple function modules like VLAN.
I plan to keep the class name of VlanConf, IntfConf and SwitchConf, let me know if you have other suggestions.
cfgagent/intfconf.cpp
Outdated
| #define VLAN_PREFIX "Vlan" | ||
| #define LAG_PREFIX "PortChannel" | ||
|
|
||
| IntfConf::IntfConf(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, vector<string> tableNames) : |
There was a problem hiding this comment.
as requested above, can you rename to IntfMgr
There was a problem hiding this comment.
So process and binary name will be changed to VlanMgr/IntfMgr/SwitchMgr, you want to change the internal class name to xxxMgr too? IntfConfd/VlanConfd were chosen per the offline meeting discussion. Yes, class name may be changed.
|
can you add swssloglevel support for this agent so that we can control the log level of this agent on the fly. |
cfgagent/Makefile.am
Outdated
| endif | ||
|
|
||
|
|
||
| intfconfd_SOURCES = intfconfd.cpp intfconf.cpp $(top_srcdir)/orchagent/orchbase.cpp |
There was a problem hiding this comment.
orchbase [](start = 71, length = 8)
Is this file missing in the PR? Why not added it in the same directory?
|
retest this please |
cfgagent/intfconf.cpp
Outdated
| { | ||
| if (m_stateVlanTable.get(alias, temp)) | ||
| { | ||
| SWSS_LOG_DEBUG("Port %s is ready\n", alias.c_str()); |
cfgagent/intfconf.cpp
Outdated
| string op = kfvOp(t); | ||
| if (op == SET_COMMAND) | ||
| { | ||
| /* Don't proceed if port/lag/VLAN is not ready yet */ |
There was a problem hiding this comment.
add more comments here, retry. Later, we need to add subscriber for the state db to get notification when the port/lag/vlan is created.
|
@lguohan lguohan swssloglevel has been supported with "Logger::linkToDbNative("intfconfd");" root@sonic:/etc/sonic# swssloglevel -p |
Signed-off-by: Jipan Yang <[email protected]>
Signed-off-by: Jipan Yang <[email protected]>
Signed-off-by: Jipan Yang <[email protected]>
cfgagent/intfmgr.cpp
Outdated
| { | ||
| } | ||
|
|
||
| void IntfMgr::syncCfgDB() |
There was a problem hiding this comment.
where does this function get called?
configure.ac
Outdated
| teamsyncd/Makefile | ||
| swssconfig/Makefile | ||
| tests/Makefile | ||
| cfgagent/Makefile |
There was a problem hiding this comment.
cfgagent [](start = 4, length = 8)
cfgmgr
lguohan
left a comment
There was a problem hiding this comment.
per our discussion, can you change to use orch class for this PR?
Signed-off-by: Jipan Yang <[email protected]>
|
Switched to orch class. |
cfgmgr/intfmgr.cpp
Outdated
| { | ||
| return true; | ||
| } | ||
| return false; |
|
@JipanYanga , can you resolve the conflict? |
Signed-off-by: Jipan Yang <[email protected]>
|
Conflicts resolved. |
* Fix optimized remove in comparison logic * Add missing brackets * Address comments
* configDB enforcer for interface Support VLAN interface only for now Signed-off-by: Jipan Yang <[email protected]> * Use OrchBase for configDB intf configuration enforcer Signed-off-by: Jipan Yang <[email protected]> * Rename intfconf to intfmgr Signed-off-by: Jipan Yang <[email protected]> * Use shell full path command macros Signed-off-by: Jipan Yang <[email protected]> * Optimize shell command execution error handling Signed-off-by: Jipan Yang <[email protected]> * Use Orch class for intfmgrd orchestration Signed-off-by: Jipan Yang <[email protected]>
Support VLAN interface only for now
Signed-off-by: Jipan Yang [email protected]
What I did
Configuration enforcer for VLAN interface
Why I did it
Support interface configuration via configDB for both initialization and incremental update
How I verified it
VLAN trunk test plan: https://github.com/Azure/SONiC/wiki/VLAN-trunk-test-plan
Details if related