Skip to content
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

Introduce host firewall connectivity tests #2306

Merged
merged 8 commits into from
Feb 23, 2024

Conversation

giorio94
Copy link
Member

Introduce two new tests covering the host firewall functionality, i.e., asserting that both ingress and egress CiliumClusterwideNetworkPolicies specifying a NodeSelector correctly block the expected traffic. The
tests are executed only when the unsafe tests are enabled, as potentially disruptive if executed against a live cluster.

The initial five commits are refactor and generalize the logic in charge of parsing, registering and creating/updating the policies used during the tests, to uniform it, reduce code duplication, and in preparation for the support for CCNPs. The sixth commit introduces the actual support for CCNPs in connectivity test. The last commit introduces the actual tests.

Please review commit by commit, and refer to the commit messages for additional details.

Let's make use of generics to uniform the logic in charge of parsing
yaml files into the various types of policies, both to reduce code
duplication and simplify the extension to other types (e.g., CCNPs).
While being there, let's also export it, so that it can be leveraged
by external hooks as well.

Signed-off-by: Marco Iorio <[email protected]>
Let's make use of generics to uniform the logic in charge of creating or
updating the different types of policies, to ensure consistent behavior,
reduce code duplication and simplify the extension to other types (e.g.,
CCNPs). While being there, let's also export it, so that it can be
leveraged by external hooks as well.

Signed-off-by: Marco Iorio <[email protected]>
Let's make use of generics to uniform the registration of the policies
necessary for a given test, to reduce code duplication and simplify
the extension to other type (e.g., CCNPs). We do no longer check if
the policy is nil, as tricky, but that was already pointless as
accessed early, triggering a panic if nil. While being there, let's
also export it, so that it can be leveraged by external hooks as well.

Signed-off-by: Marco Iorio <[email protected]>
Extract the logic adapting the namepace configured inside
CiliumNetworkPolicy rules, so that it can be reused for CCNPs
as well.

Signed-off-by: Marco Iorio <[email protected]>
So that it can be easily reused for CCNPs as well.

Signed-off-by: Marco Iorio <[email protected]>
Create the infrastructure to allow defining tests which require
the creation of CiliumClusterwideNetworkPolicies, such as in the
host firewall case.

Signed-off-by: Marco Iorio <[email protected]>
Currently, we configure both the timeout (-W) and the deadline (-w) for
the ping command, with defaults respectively 2 and 10 seconds. Yet, it
appears that the deadline always takes precedence if both are set, which
leads the test to require by default 10 seconds when a network policy
preventing connectivity is in place. Hence, let's configure only the
timeout, so that we stop waiting after two seconds. This is consistent
with the behavior for the curl operations when connectivity is blocked.

Signed-off-by: Marco Iorio <[email protected]>
Introduce two new tests covering the host firewall functionality, i.e.,
asserting that both ingress and egress CiliumClusterwideNetworkPolicies
specifying a NodeSelector correctly block the expected traffic. The
tests are executed only when the unsafe tests are enabled, as
potentially disruptive if executed against a live cluster.

Signed-off-by: Marco Iorio <[email protected]>
@giorio94 giorio94 force-pushed the mio/host-firewall-tests branch from f40e89c to 55f95de Compare February 16, 2024 14:38
@giorio94 giorio94 marked this pull request as ready for review February 16, 2024 17:36
@giorio94 giorio94 requested review from a team as code owners February 16, 2024 17:36
Copy link
Contributor

@viktor-kurchenko viktor-kurchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 23, 2024
@nathanjsweet nathanjsweet merged commit 7a928d6 into cilium:main Feb 23, 2024
13 checks passed
@giorio94 giorio94 deleted the mio/host-firewall-tests branch February 23, 2024 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has passed all tests and received consensus from code owners to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants