Skip to content

fix: keep failed UFW replay retryable - #332

Open
damacus wants to merge 5 commits into
mainfrom
codex/fix-ufw-replay-218
Open

fix: keep failed UFW replay retryable#332
damacus wants to merge 5 commits into
mainfrom
codex/fix-ufw-replay-218

Conversation

@damacus

@damacus damacus commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • persist the UFW replay marker only after rules apply successfully
  • keep failed replays retryable on the next converge
  • best-effort re-enable a previously active firewall while preserving the original replay error
  • add deterministic failure, recovery, retry, and idempotency coverage

Closes #218.

Verification

  • chef install Policyfile.rb
  • cookstyle (59 files, no offenses)
  • ChefSpec (4 examples, 0 failures)
  • Ubuntu 24.04 UFW Kitchen/InSpec: 19 successful, 0 failures
  • AlmaLinux 9 UFW Kitchen/InSpec: 15 successful, 0 failures
  • provider retry and post-success idempotency verified
  • independent security review: passed

Risk

UFW cannot atomically restore its previous runtime ruleset. If replay fails after reset, recovery re-enables the successfully replayed/default-deny state rather than leaving a previously active firewall disabled.

@damacus
damacus requested a review from a team as a code owner August 11, 2026 14:04
@ramereth
ramereth force-pushed the codex/fix-ufw-replay-218 branch from 69028e4 to 530b22e Compare August 17, 2026 00:34
@github-actions

Copy link
Copy Markdown

Slowest examples

Top 4 slowest examples (0.01 seconds, 100% of total time)
Example Description Time in seconds
spec/unit/providers/firewall_ufw_spec.rb:57 Chef::Provider::FirewallUfw does not commit desired rules and restores an active firewall after replay fails 0.00775
spec/unit/providers/firewall_ufw_spec.rb:67 Chef::Provider::FirewallUfw logs a recovery failure and re-raises the original replay exception 0.00254
spec/unit/providers/firewall_ufw_spec.rb:80 Chef::Provider::FirewallUfw retries on the next converge, commits after success, and is then idempotent 0.00217
spec/unit/recipes/default_spec.rb:10 default recipe on Ubuntu 20.04 converges successfully 0.00015

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.

Ufw failures can leave the firewall in an open state

1 participant