@@ -60,7 +60,7 @@ def apphub_app_list_services(
60
60
try :
61
61
name_app = f"projects/{ host_project_id } /locations/{ location } /applications/{ application_id } "
62
62
credentials = load_credentials (secrets )
63
- client = apphub_v1 .AppHubClient ()
63
+ client = apphub_v1 .AppHubClient (credentials = credentials )
64
64
request = apphub_v1 .ListServicesRequest (parent = name_app )
65
65
service_uris = []
66
66
updated_uri = None
@@ -228,7 +228,7 @@ def inject_fault_if_url_map_exists_app_hub(
228
228
secrets: (Secrets) default None,
229
229
"""
230
230
231
- if url_map_exists (
231
+ if not url_map_exists (
232
232
url_map ,
233
233
host_project_id ,
234
234
project_id ,
@@ -237,11 +237,15 @@ def inject_fault_if_url_map_exists_app_hub(
237
237
configuration ,
238
238
secrets ,
239
239
):
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 "
243
242
)
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 (
245
249
url_map ,
246
250
target_name ,
247
251
target_path ,
@@ -252,11 +256,7 @@ def inject_fault_if_url_map_exists_app_hub(
252
256
region ,
253
257
configuration ,
254
258
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
+ )
260
260
261
261
262
262
def remove_fault_if_url_map_exists_app_hub (
@@ -286,7 +286,7 @@ def remove_fault_if_url_map_exists_app_hub(
286
286
secrets: (Secrets) default None,
287
287
"""
288
288
289
- if url_map_exists (
289
+ if not url_map_exists (
290
290
url_map ,
291
291
host_project_id ,
292
292
project_id ,
@@ -295,11 +295,15 @@ def remove_fault_if_url_map_exists_app_hub(
295
295
configuration ,
296
296
secrets ,
297
297
):
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 "
301
300
)
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 (
303
307
url_map ,
304
308
target_name ,
305
309
target_path ,
@@ -308,8 +312,6 @@ def remove_fault_if_url_map_exists_app_hub(
308
312
region ,
309
313
configuration ,
310
314
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