File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
krkn/scenario_plugins/network_chaos_ng Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ def validate(self) -> list[str]:
5656 errors .append ("wait_duration must be an int" )
5757 if not isinstance (self .test_duration , int ):
5858 errors .append ("test_duration must be an int" )
59+ if not isinstance (self .instance_count , int ):
60+ errors .append ("instance_count must be an int" )
61+ elif self .instance_count < 0 :
62+ errors .append ("instance_count must be >= 0" )
5963 return errors
6064
6165
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ #
13# Copyright 2025 The Krkn Authors
24#
35# Licensed under the Apache License, Version 2.0 (the "License");
1113# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214# See the License for the specific language governing permissions and
1315# limitations under the License.
16+
1417import logging
1518import queue
1619import random
@@ -65,8 +68,8 @@ def run(
6568 )
6669
6770 if (
68- network_chaos_config .instance_count != 0
69- and network_chaos_config . instance_count < len (targets )
71+ network_chaos_config .instance_count > 0
72+ and len (targets ) > network_chaos_config . instance_count
7073 ):
7174 targets = random .sample (
7275 targets , network_chaos_config .instance_count
@@ -76,7 +79,7 @@ def run(
7679 self .run_parallel (targets , network_chaos )
7780 else :
7881 self .run_serial (targets , network_chaos )
79- if len (config ) > 1 :
82+ if len (scenario_config ) > 1 :
8083 logging .info (
8184 f"waiting { network_chaos_config .wait_duration } seconds before running the next "
8285 f"Network Chaos NG Module"
You can’t perform that action at this time.
0 commit comments