-
Notifications
You must be signed in to change notification settings - Fork 372
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
Periodic IPTables sync #1751
Periodic IPTables sync #1751
Conversation
@siddhant94, you must sign our contributor license agreement before your changes are merged. Click here to sign the agreement. If you are a VMware employee, read this for further instruction. |
Codecov Report
@@ Coverage Diff @@
## main #1751 +/- ##
=======================================
Coverage ? 63.19%
=======================================
Files ? 192
Lines ? 16436
Branches ? 0
=======================================
Hits ? 10386
Misses ? 4986
Partials ? 1064
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Thanks for opening this PR, I left some comments. Please make sure you sign the CLA as well.
test/integration/agent/route_test.go
Outdated
deleteRuleCmd := deleteOption + strings.Join([]string{"-m", "comment", "--comment", "\"Antrea: jump to Antrea prerouting rules\"", "-j", "ANTREA-PREROUTING"}, " ") | ||
|
||
// #nosec G204: ignore in test code | ||
actualData, err := exec.Command("bash", "-c", deleteRuleCmd).Output() |
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 notice other tests doing the same thing (calling iptables
through bash
), but I wonder why the iptables
executable cannot be invoked directly instead?
986b7df
to
7a5c7d2
Compare
Hi @antoninbas , just to collate feedback points,
I have addressed these, let me know if implementation is still inconsistent.
|
d7ec98b
to
179930e
Compare
Looking into ci failures |
@siddhant94, VMware has approved your signed contributor license agreement. |
179930e
to
2cceaec
Compare
Fixed, updated the PR. |
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.
@siddhant94 thanks for the PR, I left some comments.
2cceaec
to
5468132
Compare
Updated the PR @tnqn |
5468132
to
abaed16
Compare
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.
Thanks @siddhant94. One comment about the interface argument, otherwise LGTM.
cmd/antrea-agent/agent.go
Outdated
@@ -253,6 +255,8 @@ func run(o *Options) error { | |||
|
|||
log.StartLogFileNumberMonitor(stopCh) | |||
|
|||
go routeClient.Run(stopCh, ipTablesSyncInterval) |
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 had a comment about the consistant in #1751 (comment). Could we move ipTablesSyncInterval
to route_linux.go
? For two reasons:
- routeClient is an interface for both windows and linux platform, the argument doesn't make sense to windows.
- the argument is not configurable and specific to routeClient internal logic so no need to be the main package. Almost all such constants/variables are declared in their own package.
informerDefaultResync
is the only one declared here because it's an argument of the global component informerFactory which is used by several components.
For testing, you may declare it as a variable instead.
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.
Agreed @tnqn , this should also stay internal. I missed this in previous iteration. I was thinking of exposing a function SetSyncInterval
which would override the variable, it would be meant to be called from route package's Initialization() method and from the integration test.
Let me know if this is inconsistent. Also, if there's someplace in antrea code where we have a similar issue, I can look at that and change this part.
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 forgot that the integration test is in a different package. I'm ok with just declaring the variable as public, but we should comment why it's made so. We had a similar case before that an integration test needs to use package internal consistant/variable and it just made them public to solve it. However, that code has been deleted when implmenetation evolves.
@antoninbas what do you think?
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.
typically my favorite approach is to have a way to pass it to the constructor:
const ipTablesSyncInterval = 60 * time.Second
type ClientConfig struct {
IPTablesSyncInterval time.Duration
}
func NewClient(serviceCIDR *net.IPNet, networkConfig *config.NetworkConfig, noSNAT bool, configFns ...func(*ReporterConfig)) *Client {
config := ClientConfig{
IPTablesSyncInterval: defaultIPTablesSyncInterval,
}
for _, fn := range configFns {
fn(&config)
}
return &Client{
ClientConfig: config,
// other members
}
}
This way the call to NewClient
does not need to change in cmd/antrea-agent/agent.go
, but for the integration tests (or unit tests for that matter), we can easily provide a different value for the sync interval.
Of course that may be a bit overkill here with a single configuration parameter. So if you prefer to make the variable public and add a comment, that's fine by me.
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.
@antoninbas I actually missed this last comment, I just noticed it after push.
abaed16
to
1ca681f
Compare
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.
@siddhant94 The commit message seems having a very long title or missing empty line between title and body. Could you update it following https://github.com/golang/go/wiki/CommitMessage?
49ef3ae
to
e312148
Compare
Updated it as per the wiki. |
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.
@siddhant94 The body of commit message should be wrapped to ~76 characters, otherwise it wouldn't look good from git log
. And I think you don't need to add "pkg/agent/route:" as prefix as the other words can already scope the change well.
e312148
to
5cbe431
Compare
@tnqn I updated the Run fn comment and removed the said prefix from commit, but, for commit body, I could only reduce it to ~100 chars. Should I just omit the body? Just keep the "Fixes" line and title/subject line. |
@siddhant94 By wrapping the body of commit message, I meant to limit each line ~76 chars.
By wrapping it, it appears as:
|
Add a long-running goroutine which periodically syncs iptables. To be able to configure the sync interval for integration tests, IPTablesSyncInterval is exported. Fixes antrea-io#628
5cbe431
to
6c0cc35
Compare
@tnqn I missed the "wrapped" word, thus misunderstood it completely. I have updated the commit msg, with each line within ~76 chars. |
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, thanks @siddhant94
Thanks @tnqn @antoninbas for the patient iterations. Learnt new stuff and got to know a lot of antrea context also. |
/test-all |
/test-windows-conformance |
1 similar comment
/test-windows-conformance |
@lzhecheng do you know why the commands cannot trigger windows e2e tests? |
There was something wrong with Jenkins smee service. Now it should work. |
/test-windows-conformance |
|
Fixes #628 .
Add a long running goroutine which periodically syncs antrea required iptables rules on linux.
If the sync call/operation fails (for example - xtables lock contention), the next attempt would occur at the next sync interval.