@@ -55,10 +55,16 @@ def injectChaosInSerialMode(experimentsDetails , chaosDetails , eventsDetails ,
55
55
# Detaching the target zones from loa balancer
56
56
for azone in targetZones :
57
57
58
- logging .info ("[Info]: Detaching the following zone(s), Zone Name : %s" , azone )
59
- err = statusAws .detachAZfromLB (experimentsDetails , azone )
58
+ logging .info ("[Info]: Detaching the following zone, Zone Name %s" , azone )
59
+ targetSubnet , err = statusAws .getTargetSubnet (experimentsDetails , azone )
60
+ subnetList = list (targetSubnet .split (" " ))
60
61
if err != None :
61
62
return err
63
+ logging .info ("[Info]: Detaching the following subnet, %s" , subnetList )
64
+ err = statusAws .detachSubnet (experimentsDetails , subnetList )
65
+ if err != None :
66
+ return err
67
+
62
68
if chaosDetails .Randomness :
63
69
err = common .RandomInterval (experimentsDetails .ChaosInterval )
64
70
if err != None :
@@ -85,19 +91,17 @@ def injectChaosInSerialMode(experimentsDetails , chaosDetails , eventsDetails ,
85
91
duration = (datetime .now () - ChaosStartTimeStamp ).seconds
86
92
87
93
logging .info ("[Completion]: %s chaos is done" ,(experimentsDetails .ExperimentName ))
88
-
89
94
return None
90
95
91
96
# injectChaosInParallelMode disable the target available zone from loadbalancer in parallel mode (all at once)
92
97
def injectChaosInParallelMode (experimentsDetails , chaosDetails , eventsDetails , resultDetails , clients , statusAws ):
93
98
94
-
95
99
#ChaosStartTimeStamp contains the start timestamp, when the chaos injection begin
96
100
ChaosStartTimeStamp = datetime .now ()
97
101
duration = (datetime .now () - ChaosStartTimeStamp ).seconds
98
-
102
+ subnet = []
103
+
99
104
while duration < experimentsDetails .ChaosDuration :
100
-
101
105
# Get the target available zone details for the chaos execution
102
106
targetZones = experimentsDetails .LoadBalancerZones .split ("," )
103
107
logging .info ("[Info]: Target available zone list, %s" , targetZones )
@@ -107,12 +111,17 @@ def injectChaosInParallelMode(experimentsDetails , chaosDetails , eventsDetails
107
111
types .SetEngineEventAttributes (eventsDetails , types .ChaosInject , msg , "Normal" , chaosDetails )
108
112
events .GenerateEvents (eventsDetails , chaosDetails , "ChaosEngine" ,clients )
109
113
110
- # Detaching the target zones from loa balancer
114
+ # Detaching the target zones from load balancer
111
115
for azone in targetZones :
112
- logging .info ("[Info]: Detaching the following zone(s), Zone Name %s" , azone )
113
- err = statusAws .detachAZfromLB (experimentsDetails , azone )
116
+ logging .info ("[Info]: Detaching the following zone, Zone Name %s" , azone )
117
+ targetSubnet , err = statusAws .getTargetSubnet (experimentsDetails , azone )
118
+ subnet .append (targetSubnet )
114
119
if err != None :
115
- return err
120
+ return err
121
+ logging .info ("[Info]: Detaching the following subnet(s), %s" , subnet )
122
+ err = statusAws .detachSubnet (experimentsDetails ,subnet )
123
+ if err != None :
124
+ return err
116
125
117
126
if chaosDetails .Randomness :
118
127
err = common .RandomInterval (experimentsDetails .ChaosInterval )
@@ -128,10 +137,10 @@ def injectChaosInParallelMode(experimentsDetails , chaosDetails , eventsDetails
128
137
# Attaching the target available zone after the chaos injection
129
138
logging .info ("[Status]: Attach the available zone back to load balancer" )
130
139
for azone in targetZones :
131
- err = statusAws .attachAZtoLB (experimentsDetails , azone )
140
+ err = statusAws .attachSubnet (experimentsDetails , subnet )
132
141
if err != None :
133
142
return err
134
-
143
+
135
144
#Verify the status of available zone after the chaos injection
136
145
logging .info ("[Status]: Checking AWS load balancer's AZ status" )
137
146
err = statusAws .CheckAWSStatus (experimentsDetails )
0 commit comments