Skip to content

Conversation

@shubhamshinde360
Copy link
Contributor

@shubhamshinde360 shubhamshinde360 commented Jun 3, 2025

Summary

Fix non-idempotency of firewall table creation

Additional Context

The 'iptables-save' command behaves differently on rpm and deb based platforms.
rpm based: If an iptable has been interacted with, it will show up in the command even if it is empty.
deb based: If an iptable has been interacted with, it may not show up in the command if it is empty. If we add and then delete a rule, it shows up. But if we create the table using "iptables -N" it doesn't.

Specific tables always show up with "iptables -t #{table_name}".
Since, the tables are always already created and the module supports a specific set of them. This commit tries to check if they exist one by one using the "iptables -t" command.

Also, since the tables are being checked like this, all tables show up in the output, so adjusted the rpsec according to that.

Root cause: This occurs because iptables do not show up in the 'iptables' command when they are empty in deb based distributions.

Related Issues (if any)

Mention any related issues or pull requests.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

@shubhamshinde360 shubhamshinde360 requested a review from a team as a code owner June 3, 2025 05:40
@shubhamshinde360 shubhamshinde360 marked this pull request as draft June 3, 2025 05:40
@shubhamshinde360 shubhamshinde360 force-pushed the MODULES-11476 branch 5 times, most recently from 2dd97da to f848ce3 Compare June 5, 2025 14:47
@shubhamshinde360 shubhamshinde360 marked this pull request as ready for review June 5, 2025 14:49
@shubhamshinde360
Copy link
Contributor Author

Check failures are due to GPG key expiry issues unrelated to the changes in this PR

david22swan

This comment was marked as outdated.

The 'iptables-save' command behaves differently on rpm and deb based platforms.
rpm based: If an iptable has been interacted with, it will show up in the command even if it is empty.
deb based: If an iptable has been interacted with, it may not show up in the command if it is empty. If we add and then delete a rule, it shows up. But if we create the table using "iptables -N" it doesn't.

Specific tables always show up with "iptables -t #{table_name}".
Since, the tables are always already created and the module supports a specific set of them. This commit tries to check if they exist one by one using the "iptables -t" command.

Also, since the tables are being checked like this, all tables show up in the output, so adjusted the rpsec according to that.
Copy link
Member

@david22swan david22swan left a comment

Choose a reason for hiding this comment

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

LGTM

@shubhamshinde360 shubhamshinde360 merged commit c6cf346 into main Jun 9, 2025
6 of 50 checks passed
@shubhamshinde360 shubhamshinde360 deleted the MODULES-11476 branch June 9, 2025 16:00
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.

4 participants