Skip to content

Conversation

@matmerr
Copy link
Member

@matmerr matmerr commented Apr 28, 2021

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:

@matmerr matmerr force-pushed the npmexec branch 5 times, most recently from 4d25267 to ed574fa Compare April 29, 2021 22:09
@matmerr matmerr force-pushed the npmexec branch 2 times, most recently from 057f457 to ed72856 Compare April 30, 2021 23:04
@matmerr matmerr changed the title [NPM] Use utilexec for IPSet syscalls [NPM] Use utilexec for IPSet calls and fakeexec in podcontroller tests May 3, 2021
@matmerr matmerr requested review from JungukCho and vakalapa May 3, 2021 17:22
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
Copy link
Contributor

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),
Copy link
Contributor

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
JungukCho previously approved these changes May 5, 2021
Copy link
Contributor

@JungukCho JungukCho left a 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.

@matmerr matmerr requested a review from JungukCho May 6, 2021 18:08
Copy link
Contributor

@JungukCho JungukCho left a 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.

@matmerr matmerr merged commit 6312309 into Azure:master May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants