-
Notifications
You must be signed in to change notification settings - Fork 260
[NPM] Use utilexec for IPSet calls and fakeexec in podcontroller tests #861
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
Conversation
4d25267 to
ed574fa
Compare
057f457 to
ed72856
Compare
| output, err := cmd.CombinedOutput() | ||
| if err != nil { | ||
| metrics.SendErrorLogAndMetric(util.IpsmID, "Error: failed to save ipset to file with err %v, stderr: %v", err, string(output)) | ||
| return err |
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.
Is it better to return error with the same format you did in "Run" function to provide more info (e.g., stderr)?
Same for Restore and DestroyNpmIpsets functions.
| LabelsMap: make(map[string]string), | ||
| SetMap: make(map[string]string), | ||
| IpsMgr: ipsm.NewIpsetManager(), | ||
| IpsMgr: ipsm.NewIpsetManager(exec), |
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 far as I understood our code, there is no reason to tie IpsMgr and IptMgr in Namespace struct. In my opinion, it is better to locate them to other places (e.g., IpsMgr in npMgr, IptMgr in networkpolicyController). So, it will be easier to use our main code and UTs. I felt like there are multiple places to pass exec, etc now. However, I think that is beyond of this PR. We will fix it in other PRs. Any thoughts?
JungukCho
left a comment
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.
lgtm and look forward to subsequent PR.
JungukCho
left a comment
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.
lgtm and look forward to subsequent PR again.
Reason for Change:
Our current test framework for NPM is heavily dependent on making actual syscalls to ipset/iptables. By interfacing out the calls to ipset, we can have actual UT coverage, without having to run tests as root, but we can also verify call ordering and have better visibility to the syscalls we're making.
Issue Fixed:
Requirements:
Notes: