Skip to content

feat: Apply firewall config for multiple bridges and IPv6#28

Merged
simondeziel merged 1 commit intocanonical:mainfrom
bschimke95:bschimke95/make-bridges-configurable
May 20, 2025
Merged

feat: Apply firewall config for multiple bridges and IPv6#28
simondeziel merged 1 commit intocanonical:mainfrom
bschimke95:bschimke95/make-bridges-configurable

Conversation

@bschimke95
Copy link
Contributor

Add a new bridges input parameter to allow specifying a comma-separated list of LXD bridges for iptables configuration. This makes the action more flexible for setups with multiple bridge interfaces.

Also, extends the firewall configuration for IPv6

@tomponline tomponline requested a review from simondeziel May 8, 2025 08:24
@tomponline
Copy link
Member

Nice thanks!

@tomponline
Copy link
Member

@bschimke95 needs to be signed off please

@bschimke95 bschimke95 force-pushed the bschimke95/make-bridges-configurable branch from 65e8821 to f8bb0b8 Compare May 8, 2025 08:29
Add a new `bridges` input parameter to allow specifying a comma-separated list of LXD bridges for iptables configuration.
This makes the action more flexible for setups with multiple bridge interfaces.

Also, extends the firewall configuration for IPv6

Signed-off-by: Benjamin Schimke <benjamin.schimke@canonical.com>
@bschimke95 bschimke95 force-pushed the bschimke95/make-bridges-configurable branch from f8bb0b8 to 3e62261 Compare May 8, 2025 08:31
@bschimke95
Copy link
Contributor Author

Thanks, that was a quick review :)

Can we do a release with that change or should I use the commit?

@bschimke95
Copy link
Contributor Author

bschimke95 commented May 8, 2025

Test run using the multiple bridges input: https://github.com/canonical/k8s-snap/actions/runs/14901878737/job/41856443865?pr=1422#step:8:108

@tomponline
Copy link
Member

I'm happy to make a release, but will wait for @simondeziel review first.

Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM but I have a tiny question.

IFS=',' read -ra bridges <<< "${{ inputs.bridges }}"
for i in "${bridges[@]}"; do
bridge=$(echo "$i" | xargs) # Trim whitespace
set +e
Copy link
Member

Choose a reason for hiding this comment

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

Is that because the IPv6 chain might be missing? If so, how about having another if block to check for its existence and move the bridges array out of the conditional blocks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this essentially applies the rules on a best-effort basis, and it's not a problem if some steps fail — they can fail, for example, if:

  • the DOCKER-USER chain doesn’t exist, or
  • iptables or ip6tables aren’t available on the system.

I feel that adding conditional checks would make this section unnecessarily complex, but I’m happy to include them if you think it’s worthwhile.

Copy link
Member

Choose a reason for hiding this comment

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

The if sudo iptables -L DOCKER-USER; then condition validates that both the tool and the chain are there so I've opened up #29 to do so.

@bschimke95
Copy link
Contributor Author

Hey @simondeziel
I hope you had a great sprint and safe travels back home.
Is there anything else for this PR to land or can we go ahead and merge this? :)

@simondeziel simondeziel merged commit 51c1b87 into canonical:main May 20, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants