fix(scenarios): fix network_chaos_ng variable shadowing and instance_count condition#1219
Conversation
Review Summary by QodoFix network_chaos_ng variable shadowing and instance_count condition
WalkthroughsDescription• Fixed variable shadowing: changed len(config) to len(scenario_config) for correct inter-scenario wait logic • Corrected inverted instance_count condition from instance_count > len(targets) to len(targets) > instance_count • Added Apache 2.0 license header to the file Diagramflowchart LR
A["Bug: len(config) checks dict length"] -->|Fix| B["Use len(scenario_config) for scenario list"]
C["Bug: Inverted instance_count condition"] -->|Fix| D["Correct to len(targets) > instance_count"]
E["Missing license header"] -->|Add| F["Apache 2.0 license header"]
B --> G["Correct scenario execution flow"]
D --> G
F --> G
File Changes1. krkn/scenario_plugins/network_chaos_ng/network_chaos_ng_scenario_plugin.py
|
Code Review by Qodo
1.
|
krkn/scenario_plugins/network_chaos_ng/network_chaos_ng_scenario_plugin.py
Show resolved
Hide resolved
…ive values Per qodo-code-review bot on PR krkn-chaos#1219: - Add instance_count type and range validation in BaseNetworkChaosConfig.validate() so negative or non-int values from YAML are caught early with a clear error - Tighten sampling guard to require isinstance(int) and instance_count > 0 before calling random.sample(), preventing a runtime crash on negative values Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
krkn/scenario_plugins/network_chaos_ng/network_chaos_ng_scenario_plugin.py
Outdated
Show resolved
Hide resolved
|
are you able to squash your commits into 1 and we can get this merged! 👍 |
a4eac54 to
09a9bf2
Compare
…count condition Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
d002521 to
7eaed6d
Compare
|
@paigerube14 I've squashed the commits into a single commit and force-pushed the changes. Please review. |
Description
This PR fixes two bugs in
krkn/scenario_plugins/network_chaos_ng/network_chaos_ng_scenario_plugin.py:len(config) > 1, which was checking the length of a dictionary instead of the scenario list. Updated tolen(scenario_config) > 1so inter-scenario wait is applied only when multiple scenarios are configuredinstance_countguard frominstance_count > len(targets)tolen(targets) > instance_count, ensuring sampling only occurs when there are more targets than requestedThese fixes ensure correct scenario execution flow and prevent invalid sampling behavior.
Type of change
Related Tickets & Documents
Checklist before requesting a review
Tests Performed
python run_kraken.py # Output: No runtime errors observed. Scenario execution behaves correctly with proper delay handling. Instance selection logic works as expected.