fix(ec2): re-apply SG firewall after restart-recovery and reboot#1762
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Bug-hunt 2026-06-18 findings 4.1, 4.2. The security-group nft/NetworkPolicy reconcile is event-triggered, but two lifecycle paths didn't fire it: - 4.1: recover_persisted_containers rebuilds containers after a restart but never reconciled. The startup reaper had cleared the previous process's nft table / NetworkPolicies, so with enforcement enabled the recovered instances ran unfiltered until some unrelated later op triggered a reconcile. Now a coordinator task awaits all per-instance recovery tasks and fires one reconcile once they're up. - 4.2: RebootInstances can change an instance's IP (k8s Pod recreate), leaving a stale /32 in peers' SG rules. The reboot bg task now reconciles after the recreate loop. Both gated on network_isolation_enforced() (no-op when enforcement is off).
778f545 to
b5f3f38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bug-hunt 2026-06-18 findings 4.1, 4.2. The SG nftables/NetworkPolicy reconcile is event-triggered, but two lifecycle paths didn't fire it:
recover_persisted_containersrebuilds containers after a restart but never reconciled. The startup reaper had cleared the previous process's nft table / NetworkPolicies, so with enforcement enabled the recovered instances ran unfiltered until some unrelated later op triggered a reconcile. A coordinator task now awaits all per-instance recovery tasks and fires one reconcile once they're up.RebootInstancescan change an instance's IP (k8s Pod recreate), leaving a stale/32in peers' SG rules. The reboot bg task now reconciles after the recreate loop.Both gated on
network_isolation_enforced()(no-op when enforcement is off — the default).Test plan
cargo test -p fakecloud-ec2, clippy, fmt clean. Enforcement-path behavior (nft/NetworkPolicy actually applied) needsCAP_NET_ADMIN/a CNI and isn't CI-testable — same as the feat(ec2): enforce real VPC network isolation + security-group packet filtering #1745 phase-3/4 enforcement code; the reconcile model itself is unit-tested.Summary by cubic
Re-applies SG firewall rules after restart recovery and instance reboot so instances don’t run unfiltered or with stale peer IPs when network isolation is enforced.
RebootInstances, we reconcile to refresh SG rules if instance IPs changed.network_isolation_enforced()(no-op when disabled).Written for commit b5f3f38. Summary will update on new commits.