Skip to content

Commit 16881d1

Browse files
committed
changing to filter to better align with functionality
1 parent 219f389 commit 16881d1

5 files changed

Lines changed: 469 additions & 11 deletions

File tree

krkn/scenario_plugins/network_chaos_ng/modules/node_interface_down.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
import queue
1516
import time
1617
from typing import Tuple
@@ -97,16 +98,13 @@ def run(self, target: str, error_queue: queue.Queue = None):
9798
# to the control plane, so exec_cmd_in_pod can no longer reach the pod.
9899
# The background process runs entirely on the node and fires regardless of
99100
# control-plane connectivity.
100-
# The recovery process runs with all stdio redirected to /dev/null so it does
101-
# not hold the exec session's file descriptors open, allowing exec to return
102-
# immediately after down_cmds completes.
103101
recovery_cmds = " && ".join(
104102
[f"ip link set {iface} up" for iface in interfaces]
105103
)
106104
down_cmds = " && ".join(
107105
[f"ip link set {iface} down" for iface in interfaces]
108106
)
109-
cmd = f"sh -c 'sleep {self.config.test_duration} && {recovery_cmds}' </dev/null >/dev/null 2>&1 & {down_cmds}"
107+
cmd = f"(sleep {self.config.test_duration} && {recovery_cmds}) & {down_cmds}"
110108
self.kubecli.get_lib_kubernetes().exec_cmd_in_pod(
111109
[cmd], pod_name, self.config.namespace
112110
)
@@ -117,6 +115,13 @@ def run(self, target: str, error_queue: queue.Queue = None):
117115
target,
118116
)
119117

118+
log_info(
119+
f"waiting {self.config.test_duration} seconds for interface(s) to recover",
120+
parallel,
121+
target,
122+
)
123+
time.sleep(self.config.test_duration)
124+
120125
log_info(
121126
f"waiting for node {target} to become Ready after interface recovery",
122127
parallel,

krkn/scenario_plugins/network_chaos_ng/modules/vmi_network_chaos.py renamed to krkn/scenario_plugins/network_chaos_ng/modules/vmi_network_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
)
4242

4343

44-
class VmiNetworkChaosModule(AbstractNetworkChaosModule):
44+
class VmiNetworkFilterModule(AbstractNetworkChaosModule):
4545

4646
def __init__(self, config: NetworkFilterConfig, kubecli: KrknTelemetryOpenshift):
4747
super().__init__(config, kubecli)

krkn/scenario_plugins/network_chaos_ng/network_chaos_factory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
from krkn.scenario_plugins.network_chaos_ng.modules.pod_network_filter import (
3737
PodNetworkFilterModule,
3838
)
39-
from krkn.scenario_plugins.network_chaos_ng.modules.vmi_network_chaos import (
40-
VmiNetworkChaosModule,
39+
from krkn.scenario_plugins.network_chaos_ng.modules.vmi_network_filter import (
40+
VmiNetworkFilterModule,
4141
)
4242

4343
supported_modules = [
@@ -46,7 +46,7 @@
4646
"pod_network_chaos",
4747
"node_network_chaos",
4848
"node_interface_down",
49-
"vmi_network_chaos",
49+
"vmi_network_filter",
5050
]
5151

5252

@@ -91,11 +91,11 @@ def get_instance(
9191
if len(errors) > 0:
9292
raise Exception(f"config validation errors: [{';'.join(errors)}]")
9393
return NodeInterfaceDownModule(scenario_config, kubecli)
94-
if config["id"] == "vmi_network_chaos":
94+
if config["id"] == "vmi_network_filter":
9595
scenario_config = NetworkFilterConfig(**config)
9696
errors = scenario_config.validate()
9797
if len(errors) > 0:
9898
raise Exception(f"config validation errors: [{';'.join(errors)}]")
99-
return VmiNetworkChaosModule(scenario_config, kubecli)
99+
return VmiNetworkFilterModule(scenario_config, kubecli)
100100
else:
101101
raise Exception(f"invalid network chaos id {config['id']}")

scenarios/openshift/virt_network.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- id: vmi_network_chaos
1+
- id: vmi_network_filter
22
image: "quay.io/krkn-chaos/krkn-network-chaos:latest"
33
wait_duration: 300
44
test_duration: 120

0 commit comments

Comments
 (0)