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

Actually move iptables to the nft backend #676

Closed
14 tasks
dustymabe opened this issue Nov 20, 2020 · 47 comments
Closed
14 tasks

Actually move iptables to the nft backend #676

dustymabe opened this issue Nov 20, 2020 · 47 comments
Assignees
Labels
jira for syncing to jira kind/bug

Comments

@dustymabe
Copy link
Member

dustymabe commented Nov 20, 2020

In Fedora 32, Fedora moved the backend of iptables to use the nft implementation by default (see the change proposal. In #26 we decided to ship all the tools and accept the Fedora defaults.

Unfortunately, applying the default of iptables-nft in Fedora 32 didn't work on FCOS because it was implemented via alternatives and alternatives don't currently work with the way rpm-ostree composes the OS (see #677).

Now that we know we're misconfigured, let's figure out how to move to get back in line with Fedora's defaults while we wait on alternatives to get fixed (probably won't happen til Fedora 34).

There were some previous musings about this (before the f32 change landed) in #342.

Rolling out:

@dustymabe dustymabe changed the title actually move to nftables actually move to iptables to the nft backend Nov 20, 2020
@dustymabe
Copy link
Member Author

One proposal:

  1. leave existing systems on the old implementation (similar to the way the Fedora Change intended)
  2. group the switch to iptables-nft into the f33 rebase on the stable stream (would need to go through testing first)

Either way let's discuss it in next week's meeting to see what the most appropriate path forward is.

@dustymabe dustymabe added the meeting topics for meetings label Nov 20, 2020
@travier travier changed the title actually move to iptables to the nft backend Actually move iptables to the nft backend Nov 23, 2020
@dustymabe dustymabe added the jira for syncing to jira label Nov 23, 2020
@dustymabe
Copy link
Member Author

cc @nullr0ute for awareness - since this likely affects IoT

@jlebon
Copy link
Member

jlebon commented Nov 24, 2020

I think conceptually we want the default in the OSTree commit to be nft, and have upgraded systems therefore carry a delta in their /etc for staying on legacy. This is tricky to do though because the symlinks are managed by OSTree itself, so as soon as we change the commit, upgrading nodes will inherit the change.

Hmm, I think to implement this we'd need two barrier releases:

  • do a first barrier release with a systemd service which marks a stamp file at e.g. /var/lib/iptables-nft.stamp if the machine is already using the nft backend
  • in a second barrier release
    • we add a postprocess script that does ln -sf as needed to link /etc/alternatives/iptables to /usr/sbin/iptables-nft (and similarly for the related symlinks) -- once alternatives becomes OSTree-compatible, that postprocess script should no longer be necessary
    • we add a systemd service in the initramfs which determines whether to keep with the new default (nft), or revert back to legacy
      • if it's the first boot, then do nothing (we want freshly booted machines to use nft)
      • if /sysroot/var/lib/iptables-nft.stamp is present, then delete the stamp file and do nothing (we want upgrading machines which previously used nft to stay on nft)
      • if the symlinks are already different from nft, then do nothing (we don't want to touch upgrading machines which previously somehow used neither nft nor legacy, just to be safe)
      • otherwise, revert the /etc symlinks back to legacy; this will mark the symlinks as modified as per ostree admin config-diff

@jlebon
Copy link
Member

jlebon commented Nov 24, 2020

Another approach which requires user action is a single barrier where we add a service which optionally sets the backend to legacy if some stamp file in /var is present. Then we inform users that if no action is taken, their nodes will be moved to iptables-nft. Otherwise, they can touch that stamp file before $release_date. This is more aggressive, though is much simpler in implementation. (I personally lean towards this).

@dustymabe
Copy link
Member Author

  • do a first barrier release with a systemd service which marks a stamp file at e.g. /var/lib/iptables-nft.stamp if the machine is already using the nft backend

Could we get away with doing just one barrier release if we just take a peak at what's in the rollback deployment's /etc/ to determine if it was using nft already or not?

@jlebon
Copy link
Member

jlebon commented Nov 25, 2020

Could we get away with doing just one barrier release if we just take a peak at what's in the rollback deployment's /etc/ to determine if it was using nft already or not?

Hmm, I think that would work in 99% of cases, but it's not entirely foolproof, because there are no guarantees about correspondence between "previous deployment" and "rollback deployment" (what's considered the rollback is more a convention based on deployment ordering) and whether it still exists.

@jlebon
Copy link
Member

jlebon commented Nov 25, 2020

This was discussed in the community meeting today:

AGREED: we will stay with the legacy backend for now while we pursue a fixed alternatives for OSTree systems. meanwhile, we will document how users can move to the nft backend

@travier
Copy link
Member

travier commented Nov 26, 2020

Upstream issue for easier reference: fedora-sysv/chkconfig#9

travier added a commit to travier/fedora-coreos-docs that referenced this issue Nov 26, 2020
travier added a commit to travier/fedora-coreos-docs that referenced this issue Nov 26, 2020
@cgwalters
Copy link
Member

If we switch the default to nft, do we then document+support a way to stay on legacy for new systems too? It'd probably make sense because we need to carry most of that logic for previous systems too, but it is a different case.

@ibotty
Copy link

ibotty commented Dec 1, 2020

Without having anything to say: why support legacy iptables at all? AFAICT there are more bugs in legacy iptables and many features get easier with nft. Most people would not notice anyway.

Isn't current RHEL and RHCOS also on nft? I don't see a reason for legacy iptables.

@nullr0ute
Copy link

cc @nullr0ute for awareness - since this likely affects IoT

We actually use firewalld, as opposed to an iptables based static firewall, and it defaults to the nft backend so I'm not sure how much this applies by default to IoT. Thanks for the heads up, let me know if I've missed something.

@dustymabe
Copy link
Member Author

If people who know much more about this than me tell me that switching the nft on an upgrade is a relatively safe thing to do then we could consider that option. Keep in mind that FCOS auto-updates, so the goal is to not break people's systems that are updating themselves. Do we have a high degree of confidence that iptables-nft is a safe upgrade?

/me wonders why the rpm doesn't just default to it now instead of relying on updating priorities via alternatives in %post scriptlets.

dustymabe pushed a commit to coreos/fedora-coreos-docs that referenced this issue Dec 1, 2020
@dghubble
Copy link
Member

dghubble commented Dec 1, 2020

Host iptables legacy vs nft has been a pain point in Kubernetes-land for years (example). kube-proxy should detect the mode in theory. Other network-related apps, components, or tools need to be prepared as well (e.g. CNIs). I'd have a healthy fear on this topic.

@dustymabe dustymabe removed the meeting topics for meetings label Dec 9, 2020
@champtar
Copy link

champtar commented Dec 9, 2020

Not all CNI autodetect, and they might not autodetect by default.
Also k8s-dns-node-cache support autodetection only since 1.16.0 / nov 16 (kubernetes/dns#367)
You can today run with iptables-nft, but switching automatically will break some prod :)

@jlebon
Copy link
Member

jlebon commented Apr 19, 2021

So if we want to err on the side of caution and not auto-migrate systems on legacy but only affect new nodes, that takes us back to something like #676 (comment).

@dustymabe dustymabe added the meeting topics for meetings label Apr 21, 2021
@jdbarnes-isi
Copy link

Looking forward to the release that has this default. Will it be in whatever is after Stable v 35.20220131.3.0 ? Is it already in Testing v 35.20220213.2.0?

@dustymabe
Copy link
Member Author

It will be when the rebase to Fedora Linux 36 happens. See the email Jonathan sent out.

@travier
Copy link
Member

travier commented Feb 24, 2022

@jdbarnes-isi Note that you can switch to the new backend today with https://docs.fedoraproject.org/en-US/fedora-coreos/alternatives/

jlebon added a commit to jlebon/fedora-coreos-config that referenced this issue Mar 2, 2022
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
jlebon added a commit to jlebon/fedora-coreos-config that referenced this issue Mar 2, 2022
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
jlebon added a commit to jlebon/fedora-coreos-config that referenced this issue Mar 3, 2022
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
jlebon added a commit to jlebon/fedora-coreos-config that referenced this issue Mar 3, 2022
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
jlebon added a commit to jlebon/fedora-coreos-config that referenced this issue Mar 3, 2022
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
jlebon added a commit to coreos/fedora-coreos-config that referenced this issue Mar 7, 2022
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
@dustymabe dustymabe added status/pending-testing-release Fixed upstream. Waiting on a testing release. and removed status/decided status/pending-action Needs action labels Apr 25, 2022
@dustymabe
Copy link
Member Author

The fix for this went into next stream release 36.20220325.1.0. Please try out the new release and report issues.

@dustymabe
Copy link
Member Author

The fix for this went into testing stream release 36.20220505.2.0. Please try out the new release and report issues.

@dustymabe dustymabe added status/pending-stable-release Fixed upstream and in testing. Waiting on stable release. and removed status/pending-testing-release Fixed upstream. Waiting on a testing release. labels May 11, 2022
@dustymabe
Copy link
Member Author

The fix for this went into stable stream release 36.20220505.3.2.

@dustymabe dustymabe removed the status/pending-stable-release Fixed upstream and in testing. Waiting on stable release. label May 25, 2022
elemental-lf added a commit to elemental-lf/typhoon that referenced this issue Sep 2, 2022
kube-proxy and Calico are still using the legacy implementation, so we want our custom rules
to go into the same tables.

See:
  * https://docs.fedoraproject.org/en-US/fedora-coreos/major-changes/#_moving_to_iptables_nft
  * coreos/fedora-coreos-tracker#676
  * coreos/fedora-coreos-config#1324
Snaipe pushed a commit to aristanetworks/monsoon that referenced this issue Apr 13, 2023
* Add `/etc/fedora-coreos/iptables-legacy.stamp` to declare
that `iptables-legacy` should be used instead of `iptables-nft`
(until support is added in future releases)
* coreos/fedora-coreos-tracker#676
HuijingHei pushed a commit to HuijingHei/fedora-coreos-config that referenced this issue Oct 10, 2023
Let's confirm for now that we're using iptables-legacy by default
until we switch to defaulting to iptables-nft.

See coreos/fedora-coreos-tracker#676
HuijingHei pushed a commit to HuijingHei/fedora-coreos-config that referenced this issue Oct 10, 2023
From `overlay.d/README.md`:

Contains systemd service and script for remaining on iptables-nft after
the migration to nft.

Split out because (1) it will roll out to next first, and (2) it can
more easily be deleted after the barrier release.

For more details, see:
coreos/fedora-coreos-tracker#676
coreos#1324
HuijingHei pushed a commit to HuijingHei/fedora-coreos-config that referenced this issue Oct 10, 2023
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
HuijingHei pushed a commit to HuijingHei/fedora-coreos-config that referenced this issue Oct 10, 2023
Let's confirm for now that we're using iptables-legacy by default
until we switch to defaulting to iptables-nft.

See coreos/fedora-coreos-tracker#676
HuijingHei pushed a commit to HuijingHei/fedora-coreos-config that referenced this issue Oct 10, 2023
From `overlay.d/README.md`:

Contains systemd service and script for remaining on iptables-nft after
the migration to nft.

Split out because (1) it will roll out to next first, and (2) it can
more easily be deleted after the barrier release.

For more details, see:
coreos/fedora-coreos-tracker#676
coreos#1324
HuijingHei pushed a commit to HuijingHei/fedora-coreos-config that referenced this issue Oct 10, 2023
Add a new conditional include which migrates streams on Fedora 36 and
higher to iptables-nft. This is magnitudes simpler than the current
alternative rollout procedure detailed in:

coreos/fedora-coreos-tracker#676
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira for syncing to jira kind/bug
Projects
None yet
Development

No branches or pull requests

9 participants