[Backport 2026.1] refactor(nemesis): extract 6 network disruption monkeys into network.py #15175
Open
scylladbbot wants to merge 5 commits into
Open
[Backport 2026.1] refactor(nemesis): extract 6 network disruption monkeys into network.py #15175scylladbbot wants to merge 5 commits into
scylladbbot wants to merge 5 commits into
Conversation
Author
|
@pehala - This PR has conflicts, therefore it was moved to |
5a05615 to
fce34ca
Compare
Phase 1 of the nemesis extraction plan: move all network disruption logic from the monolithic __init__.py into sdcm/nemesis/monkey/network.py as self-contained monkey classes with inline disrupt() methods. Extracted monkeys: - RandomInterruptionNetworkMonkey (disrupt_network_random_interruptions) - BlockNetworkMonkey (disrupt_network_block) - RejectInterNodeNetworkMonkey (disrupt_network_reject_inter_node_communication) - RejectNodeExporterNetworkMonkey (disrupt_network_reject_node_exporter) - RejectThriftNetworkMonkey (disrupt_network_reject_thrift) - StopStartInterfacesNetworkMonkey (disrupt_network_start_stop_interface) Also extracted 5 helper functions: install_iptables, iptables_randomly_get_random_matching_rule, iptables_randomly_get_disrupting_target, run_commands_wait_and_cleanup, get_rate_limit_for_network_disruption. Removed 13 methods from NemesisRunner and 6 classes from monkey/__init__.py. Cleaned up 6 now-unused imports from __init__.py. Strict behavior-preserving: no logic changes, known bugs preserved as-is. Net reduction: __init__.py 5953->5530 (-423 lines), monkey/__init__.py 995->920 (-75 lines). 53 new unit tests in test_network.py covering helpers, monkey flags, instantiation, UnsupportedNemesis guards, and registry auto-discovery. (cherry picked from commit 3213eca)
…sage Fix bug in iptables_randomly_get_random_matching_rule where the 'statistic' branch compared match_type instead of mode, causing the 'random' (probability) and 'nth' (every-N-packet) sub-branches to always fall through to the default 'every packet' return. Also remove the unreachable 'connbytes' branch that was never present in the choice list. Also standardize all random usage in network.py: helper functions now accept a mandatory rnd parameter, and all monkey classes pass self.runner.random through it. This ensures nemesis randomness is seeded and reproducible. Changes: - iptables_randomly_get_random_matching_rule: match_type -> mode in the statistic sub-branch comparisons; add rnd parameter; remove dead connbytes branch - iptables_randomly_get_disrupting_target: add rnd parameter - get_rate_limit_for_network_disruption: add rnd parameter - All 6 monkey classes: replace bare random.* calls with self.runner.random.* and pass rnd=self.runner.random to helpers 5 new tests covering statistic/random mode, statistic/nth mode, rnd parameter plumbing, and module-level fallback behavior. (cherry picked from commit 9a9e4c7)
…ble-unit bug
- Remove connbytes test case (branch was removed from production code)
- Fix RejectThriftNetworkMonkey docstring: port 9100 -> 9160
- Fix BlockNetworkMonkey._disrupt_k8s: additional_info used 'for {duration}sec'
where duration is already '60s', producing 'for 60ssec'; drop the redundant 'sec'
(cherry picked from commit 6fd8678)
631a54f to
7ea2b50
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.
Phase 1 of nemesis rework plan
Fixes https://scylladb.atlassian.net/browse/SCT-207
Testing
PR pre-checks (self review)
backportlabelsReminders
Add New configuration option and document them (in
sdcm/sct_config.py)Add unit tests to cover my changes (under
unit-test/folder)Update the Readme/doc folder relevant to this change (if needed)
(cherry picked from commit 3213eca)
(cherry picked from commit 9a9e4c7)
(cherry picked from commit 6fd8678)
Parent PR: #14372