-
Notifications
You must be signed in to change notification settings - Fork 537
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfgorch [](start = 61, length = 7)
suggest merge "cfgorch", "intfconfd" into one directory #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vector [](start = 81, length = 6)
Do you want to copy a vector? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The table names for different DB are different. a vector might not be a good fit here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
intfconfd/intfconf.cpp
Outdated
|
||
cmd = "ip address " + opCmd + " "; | ||
cmd += ipPrefixStr + " dev " + alias; | ||
swss::exec(cmd, res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exec [](start = 10, length = 4)
check the return value? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string & [](start = 25, length = 8)
If using a reference, consider using a const reference if possible. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
intfconfd/intfconf.cpp
Outdated
return true; | ||
} | ||
|
||
bool IntfConf::isIntfStateOk(string &alias) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isIntfStateOk [](start = 15, length = 13)
suggest name: readyIntf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
intfconfd/intfconfd.cpp
Outdated
} | ||
catch(const std::exception &e) | ||
{ | ||
SWSS_LOG_ERROR("Runtime error: %s", e.what()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return a non zero error code? #Closed
Signed-off-by: Jipan Yang <[email protected]>
.gitignore
Outdated
@@ -43,6 +43,7 @@ deps/ | |||
teamsyncd/teamsyncd | |||
fpmsyncd/fpmsyncd | |||
intfsyncd/intfsyncd | |||
cfgagent/intfconfd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as requested above, can you rename to IntfMgr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orchbase [](start = 71, length = 8)
Is this file missing in the PR? Why not added it in the same directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in PR #360
retest this please |
cfgagent/intfconf.cpp
Outdated
{ | ||
if (m_stateVlanTable.get(alias, temp)) | ||
{ | ||
SWSS_LOG_DEBUG("Port %s is ready\n", alias.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vlan is ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will fix it.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does this function get called?
configure.ac
Outdated
@@ -87,6 +87,7 @@ AC_CONFIG_FILES([ | |||
teamsyncd/Makefile | |||
swssconfig/Makefile | |||
tests/Makefile | |||
cfgagent/Makefile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfgagent [](start = 4, length = 8)
cfgmgr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ret == 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once vlanmgr is merged.
@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
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