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

test netavark nftables driver #23234

Merged
merged 5 commits into from
Jul 11, 2024
Merged

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Jul 9, 2024

Make sure this passes podman CI before push out a default change.

ref: https://fedoraproject.org/wiki/Changes/NetavarkNftablesDefault

Does this PR introduce a user-facing change?

None

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 9, 2024
Copy link

We were not able to find or create Copr project packit/containers-podman-23234 specified in the config with the following error:

Cannot create a new Copr project (owner=packit project=containers-podman-23234 chroots=['centos-stream-9-x86_64', 'centos-stream-10-aarch64', 'centos-stream-10-x86_64', 'centos-stream-9-aarch64']): Response is not in JSON format, there is probably a bug in the API code.

Please check your configuration for:

  1. typos in owner and project name (groups need to be prefixed with @)
  2. whether the project name doesn't contain not allowed characters (only letters, digits, underscores, dashes and dots must be used)
  3. whether the project itself exists (Packit creates projects only in its own namespace)
  4. whether Packit is allowed to build in your Copr project
  5. whether your Copr project/group is not private

@Luap99
Copy link
Member Author

Luap99 commented Jul 9, 2024

Looks like we have a few tests that make assumptions on iptables that have to fixed. And upgrade tests will not work like this as you cannot change the firewall driver with running containers and then expect things to keep working so I guess I have to force iptables there.
Also the netavark version in debian is ages old so we cannot run it there at all.

But overall this looks good.

cc @mheon

@mheon
Copy link
Member

mheon commented Jul 9, 2024

Sure, LGTM. I don't think we need to worry about conditionally testing both, once the upstream default is swapped I don't really care about upstream iptables testing.

@Luap99 Luap99 force-pushed the test-nftables branch 2 times, most recently from 3edb6fb to fba33af Compare July 10, 2024 12:49
Luap99 added 5 commits July 11, 2024 14:08
Make sure this passes podman CI before we push out a default change.

ref: https://fedoraproject.org/wiki/Changes/NetavarkNftablesDefault

Signed-off-by: Paul Holzinger <[email protected]>
This test checks a simple publish which is already covered in many other
places, it also used iptables wich is a invalid assumption going forward
as we start to enable nftables as firewall driver.

The only thing these tests added where checking that we cannot resuse
the same port. Given there was more than one kernel regression[1,2]
about correctly failing with EADDRINUSE I also added the
distro-integration tag to make sure we catch this early in fedora
testing.

[1] https://lore.kernel.org/regressions/[email protected]/
[2] https://lore.kernel.org/regressions/CAFsF8vL4CGFzWMb38_XviiEgxoKX0GYup=JiUFXUOmagdk9CRg@mail.gmail.com/

Signed-off-by: Paul Holzinger <[email protected]>
Stop using iptables to check anything, it does not work rootless and
will no longer work with nftables which will be used in the future.

Also fix up the test that say podman run to actually use podman run and
then just check via inspect that the ports are set correctly.

Signed-off-by: Paul Holzinger <[email protected]>
netavark can use iptables or nftables as firewall driver, thus if we try
to flush rules make sure we try both to keep the test working when we
switch the default to nftables.

Signed-off-by: Paul Holzinger <[email protected]>
Old netavark version only supported iptables, however a new version on
th ehost might use nftables. This breaks the networking tests here as
they are not compatible and you would need to reboot to fix that.

Because this is not possible for our tests make sure we force the
iptables driver always to keep the test working.

Signed-off-by: Paul Holzinger <[email protected]>
@Luap99 Luap99 changed the title DNM: test netavark nftables driver test netavark nftables driver Jul 11, 2024
@Luap99 Luap99 marked this pull request as ready for review July 11, 2024 12:10
@openshift-ci openshift-ci bot removed do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 11, 2024
@Luap99
Copy link
Member Author

Luap99 commented Jul 11, 2024

@edsantiago PTAL I expect this only to be temporary until we changed the default in fedora.

Copy link
Member

@edsantiago edsantiago 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 very nice commit breakdown, thank you. Some questions inline, none are blocking (well, depending on the answer to the e2e one).

Comment on lines +323 to +324
iptables -t nat -nvL || true
nft list ruleset || true
Copy link
Member

Choose a reason for hiding this comment

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

Will a future maintainer, looking at failure logs, know what these are? I know it's duplication, but I like to include the commands in the output:

    echo "$_LOG_PROMPT iptables -t nat -nvL"
    iptables -t nat -nvL || true
    echo "$_LOG_PROMPT nft list ruleset"
    nft list ruleset

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I can add this although format is very unique for both so it is easy to know what they are, but I guess I can say this because I look at this stuff often. I will include if I have to repush again.

Comment on lines +328 to +329
iptables -t nat -F "NETAVARK-HOSTPORT-DNAT" || true
nft delete table inet netavark || true
Copy link
Member

Choose a reason for hiding this comment

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

If nft is the desired default, shouldn't that be the first one run?

And, what happens on systems where both are installed? Would it be safer to do this instead?

    nft delete table inet netavark \
        || iptables -t nat -F "..." \
        || true

Copy link
Member Author

Choose a reason for hiding this comment

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

That is what I tried before as well, there is big bug in system there that use CONTAINERS_CONF which will mean they ignore the firewall driver opt.

I had the order iptables || nft which does not work, using nft || iptables would work but not if somebody inverts the order one day where the containers.conf forces iptables and the normal the default is nft. Thus I decied to just always flush both.

In general using CONTAINERS_CONF in system tests seems wrong but well there is a test that excpliclty checks how CONTAINERS_CONF works so it is not like I can just remove/fix it either...

# Test nftables driver, https://fedoraproject.org/wiki/Changes/NetavarkNftablesDefault
# We can drop this once this implemented and pushed into fedora stable. We cannot test it on
# debian because the netavark version there is way to old for nftables support.
printf "[network]\nfirewall_driver=\"nftables\"\n" > /etc/containers/containers.conf.d/90-nftables.conf
Copy link
Member

Choose a reason for hiding this comment

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

This will work for system tests, but can you confirm that it works in e2e? Those have a nasty habit of ignoring all conf files, and requiring command-line overrides for everything.

Copy link
Member Author

Choose a reason for hiding this comment

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

This works for e2e they do not ignore global configs they just overwrite most options via cli but there is no option for the firewall driver so it works (well until they use CONTAINERS_CONF env).
I know it does before the first version failed with the iptables checks in e2e which is why I removed it.

Copy link
Contributor

openshift-ci bot commented Jul 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@edsantiago
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 11, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 360c4f3 into containers:main Jul 11, 2024
89 checks passed
@Luap99 Luap99 deleted the test-nftables branch July 12, 2024 08:54
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Oct 11, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Oct 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants