-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
iptables: test real world roundtrip of iptables rules #52860
Conversation
/retest |
2d2b3c9
to
f32eaf4
Compare
func validateIptablesClean(t *testing.T) { | ||
cur := iptablesSave(t) | ||
if strings.Contains(cur, "ISTIO") { | ||
t.Fatalf("Istio rules leftover: %v", cur) |
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.
This will likely not be enough to completely validate that iptables are clean.
istio-clean-iptables is also tasked with cleaning non-jump rules in non-istio chains and may leave some leftovers is something is incorrect
e.g:
https://github.com/istio/istio/blob/master/tools/istio-clean-iptables/pkg/cmd/cleanup.go#L76-L80
For the purpose of #50328 e2e cleanup tests I have exposed VerifyIptablesState() to perform this validation
residueExists, deltaExists := iptConfigurator.VerifyIptablesState(&iptVer, &ipt6Ver) |
Edit: Actually not even VerifyIptablesState would be enough as I changed it to ignore non-jump rules in non-istio chains. This was done in order to not introduce false positives if the users tinkered with the iptables by themselves.
istio/tools/istio-iptables/pkg/capture/run.go
Line 815 in 4153713
if !ok || (strings.HasPrefix(chain, "ISTIO_") && len(rules) != len(currentRules)) { |
For the tests there is the need to go deeper and rely directly the parsed output of iptables-restore (obtainable via cfg.ruleBuilder.GetStateFromSave(cmdOutput.string())
)
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.
maybe we can iterate with improved validation
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.
These are hard to use directly with this approach since we do not have an iptConfigurator
.
I have updated it to use the old and new cleanup approach though
/retest |
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.
e2e seems like an odd choice. maybe just .../pkg/test/cleanup_test.go
4764994
to
9a3116b
Compare
/retest |
validateIptablesClean(t) | ||
// App, cleanup with the new approach | ||
assert.NoError(t, runIptables(args...)) | ||
assert.NoError(t, runIptablesClean(args...)) |
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 --cleanup-only option is already verified in TestIdempotentUnequaledRerun in the file istio-iptables/pkg/capture/run_test.go.
https://github.com/istio/istio/blob/master/tools/istio-iptables/pkg/capture/run_test.go#L384-L393
The difference between the two is that the one in run_test.go uses the cleanup option programmatically by setting the istio-iptables/config instead of relying on the CLI.
Do you prefer to have a verification via CLI as well?
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.
hmm I guess we probably don't, I missed that part of your 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.
This does test istio-clean-iptables
as well though
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 that's true. The old istio-clean-iptables method has currently zero e2e coverage
This is a building block to test things like #52835 and #50328