Skip to content

Commit 3e097e6

Browse files
ashishjain2412Lawouach
authored andcommitted
updated Apphub actions with cred"
Signed-off-by: Ashish Jain <ashishjn@google.com>
1 parent 6edc315 commit 3e097e6

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

chaosgcp/apphub/actions.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def apphub_app_list_services(
6060
try:
6161
name_app = f"projects/{host_project_id}/locations/{location}/applications/{application_id}"
6262
credentials = load_credentials(secrets)
63-
client = apphub_v1.AppHubClient()
63+
client = apphub_v1.AppHubClient(credentials=credentials)
6464
request = apphub_v1.ListServicesRequest(parent=name_app)
6565
service_uris = []
6666
updated_uri = None
@@ -228,7 +228,7 @@ def inject_fault_if_url_map_exists_app_hub(
228228
secrets: (Secrets) default None,
229229
"""
230230

231-
if url_map_exists(
231+
if not url_map_exists(
232232
url_map,
233233
host_project_id,
234234
project_id,
@@ -237,11 +237,15 @@ def inject_fault_if_url_map_exists_app_hub(
237237
configuration,
238238
secrets,
239239
):
240-
# URL map exists, proceed with your processing logic here
241-
logger.info(
242-
f"Given URL map '{url_map}' found in given Apphub Application. Proceeding with Fault Injection Action "
240+
raise ActivityFailed(
241+
f"Given URL map '{url_map}' not found in given Apphub Application, Cannot Inject Fault "
243242
)
244-
inject_traffic_faults(
243+
244+
# URL map exists, proceed with your processing logic here
245+
logger.info(
246+
f"Given URL map '{url_map}' found in given Apphub Application. Proceeding with Fault Injection Action "
247+
)
248+
inject_traffic_faults(
245249
url_map,
246250
target_name,
247251
target_path,
@@ -252,11 +256,7 @@ def inject_fault_if_url_map_exists_app_hub(
252256
region,
253257
configuration,
254258
secrets,
255-
)
256-
else:
257-
raise ActivityFailed(
258-
f"Given URL map '{url_map}' not found in given Apphub Application, Cannot Inject Fault "
259-
)
259+
)
260260

261261

262262
def remove_fault_if_url_map_exists_app_hub(
@@ -286,7 +286,7 @@ def remove_fault_if_url_map_exists_app_hub(
286286
secrets: (Secrets) default None,
287287
"""
288288

289-
if url_map_exists(
289+
if not url_map_exists(
290290
url_map,
291291
host_project_id,
292292
project_id,
@@ -295,11 +295,15 @@ def remove_fault_if_url_map_exists_app_hub(
295295
configuration,
296296
secrets,
297297
):
298-
# URL map exists, proceed with your processing logic here
299-
logger.info(
300-
f"URL map '{url_map}' - Rollback of Fault Injection Action "
298+
raise ActivityFailed(
299+
f"Given URL map '{url_map}' not found, RollBack not required "
301300
)
302-
remove_fault_injection_traffic_policy(
301+
302+
# URL map exists, proceed with your processing logic here
303+
logger.info(
304+
f"URL map '{url_map}' - Rollback of Fault Injection Action "
305+
)
306+
remove_fault_injection_traffic_policy(
303307
url_map,
304308
target_name,
305309
target_path,
@@ -308,8 +312,6 @@ def remove_fault_if_url_map_exists_app_hub(
308312
region,
309313
configuration,
310314
secrets,
311-
)
312-
else:
313-
raise ActivityFailed(
314-
f"Given URL map '{url_map}' not found, RollBack not required "
315-
)
315+
)
316+
317+

0 commit comments

Comments
 (0)