@@ -38,15 +38,18 @@ def run_scenario(scenario):
38
38
# Install or update the helm chart
39
39
print ("Helm - creating simulation objects in namespace mdc-simulation..." )
40
40
try :
41
+ existing_pod = subprocess .run (["kubectl" , "get" , "pod" , ATTACKER , "-n" , NAMESPACE ], capture_output = True , text = True )
42
+ if existing_pod .stdout :
43
+ subprocess .run (["kubectl" , "delete" , "pod" , ATTACKER , "-n" , NAMESPACE ], check = True , capture_output = True )
41
44
subprocess .run (["helm" , "upgrade" , "--install" , HELM_RELEASE , HELM_CHART ,
42
45
"--set" , f"env.name={ NAMESPACE } " , "--set" , f"scenario={ scenario } " ],
43
46
check = True , capture_output = True )
44
- except subprocess .CalledProcessError as e :
45
- print ("Failed to create Helm chart. Exiting" )
46
- raise subprocess .CalledProcessError (returncode = e .returncode , cmd = e .cmd )
47
47
except FileNotFoundError :
48
48
print ("Can't find Helm. Exiting" )
49
49
raise FileNotFoundError
50
+ except subprocess .CalledProcessError as e :
51
+ print ("Failed to create Helm chart. Exiting" )
52
+ raise subprocess .CalledProcessError (returncode = e .returncode , cmd = e .cmd )
50
53
51
54
print ("Creating resources..." )
52
55
attacker_status = subprocess .run (["kubectl" , "get" , "pod" , ATTACKER , "-n" , NAMESPACE , "-o" ,
@@ -99,6 +102,8 @@ def start_simulation():
99
102
100
103
try :
101
104
run_scenario (SCENARIOS [choise - 1 ])
105
+ except FileNotFoundError :
106
+ return
102
107
except Exception :
103
108
release_status = subprocess .run (["helm" , "status" , HELM_RELEASE ], capture_output = True )
104
109
if release_status .returncode == 0 :
0 commit comments