@@ -55,10 +55,16 @@ def injectChaosInSerialMode(experimentsDetails , chaosDetails , eventsDetails ,
5555 # Detaching the target zones from loa balancer
5656 for azone in targetZones:
5757
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(" "))
6061 if err != None:
6162 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+
6268 if chaosDetails.Randomness:
6369 err = common.RandomInterval(experimentsDetails.ChaosInterval)
6470 if err != None:
@@ -85,19 +91,17 @@ def injectChaosInSerialMode(experimentsDetails , chaosDetails , eventsDetails ,
8591 duration = (datetime.now() - ChaosStartTimeStamp).seconds
8692
8793 logging.info("[Completion]: %s chaos is done",(experimentsDetails.ExperimentName))
88-
8994 return None
9095
9196# injectChaosInParallelMode disable the target available zone from loadbalancer in parallel mode (all at once)
9297def injectChaosInParallelMode(experimentsDetails , chaosDetails , eventsDetails , resultDetails, clients, statusAws):
9398
94-
9599 #ChaosStartTimeStamp contains the start timestamp, when the chaos injection begin
96100 ChaosStartTimeStamp = datetime.now()
97101 duration = (datetime.now() - ChaosStartTimeStamp).seconds
98-
102+ subnet = []
103+
99104 while duration < experimentsDetails.ChaosDuration:
100-
101105 # Get the target available zone details for the chaos execution
102106 targetZones = experimentsDetails.LoadBalancerZones.split(",")
103107 logging.info("[Info]: Target available zone list, %s", targetZones)
@@ -107,12 +111,17 @@ def injectChaosInParallelMode(experimentsDetails , chaosDetails , eventsDetails
107111 types.SetEngineEventAttributes(eventsDetails, types.ChaosInject, msg, "Normal", chaosDetails)
108112 events.GenerateEvents(eventsDetails, chaosDetails, "ChaosEngine",clients)
109113
110- # Detaching the target zones from loa balancer
114+ # Detaching the target zones from load balancer
111115 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)
114119 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
116125
117126 if chaosDetails.Randomness:
118127 err = common.RandomInterval(experimentsDetails.ChaosInterval)
@@ -128,10 +137,10 @@ def injectChaosInParallelMode(experimentsDetails , chaosDetails , eventsDetails
128137 # Attaching the target available zone after the chaos injection
129138 logging.info("[Status]: Attach the available zone back to load balancer")
130139 for azone in targetZones:
131- err = statusAws.attachAZtoLB (experimentsDetails, azone )
140+ err = statusAws.attachSubnet (experimentsDetails, subnet )
132141 if err != None:
133142 return err
134-
143+
135144 #Verify the status of available zone after the chaos injection
136145 logging.info("[Status]: Checking AWS load balancer's AZ status")
137146 err = statusAws.CheckAWSStatus(experimentsDetails)
0 commit comments