@@ -149,6 +149,9 @@ def wipe_cluster(client):
149
149
wipe_tasks (client )
150
150
wipe_node_shutdown_metadata (client )
151
151
wait_for_pending_datafeeds_and_jobs (client )
152
+ wipe_calendars (client )
153
+ wipe_filters (client )
154
+ wipe_transforms (client )
152
155
153
156
wait_for_cluster_state_updates_to_finish (client )
154
157
if close_after_wipe :
@@ -334,7 +337,7 @@ def wait_for_pending_tasks(client, filter, timeout=30):
334
337
break
335
338
336
339
337
- def wait_for_pending_datafeeds_and_jobs (client , timeout = 30 ):
340
+ def wait_for_pending_datafeeds_and_jobs (client : Elasticsearch , timeout = 30 ):
338
341
end_time = time .time () + timeout
339
342
while time .time () < end_time :
340
343
resp = client .ml .get_datafeeds (datafeed_id = "*" , allow_no_match = True )
@@ -345,6 +348,7 @@ def wait_for_pending_datafeeds_and_jobs(client, timeout=30):
345
348
datafeed_id = datafeed ["datafeed_id" ]
346
349
)
347
350
351
+ end_time = time .time () + timeout
348
352
while time .time () < end_time :
349
353
resp = client .ml .get_jobs (job_id = "*" , allow_no_match = True )
350
354
if resp ["count" ] == 0 :
@@ -353,6 +357,56 @@ def wait_for_pending_datafeeds_and_jobs(client, timeout=30):
353
357
client .options (ignore_status = 404 ).ml .close_job (job_id = job ["job_id" ])
354
358
client .options (ignore_status = 404 ).ml .delete_job (job_id = job ["job_id" ])
355
359
360
+ end_time = time .time () + timeout
361
+ while time .time () < end_time :
362
+ resp = client .ml .get_data_frame_analytics (id = "*" )
363
+ if resp ["count" ] == 0 :
364
+ break
365
+ for job in resp ["data_frame_analytics" ]:
366
+ client .options (ignore_status = 404 ).ml .stop_data_frame_analytics (id = job ["id" ])
367
+ client .options (ignore_status = 404 ).ml .delete_data_frame_analytics (
368
+ id = job ["id" ]
369
+ )
370
+
371
+
372
+ def wipe_filters (client : Elasticsearch , timeout = 30 ):
373
+ end_time = time .time () + timeout
374
+ while time .time () < end_time :
375
+ resp = client .ml .get_filters (filter_id = "*" )
376
+ if resp ["count" ] == 0 :
377
+ break
378
+ for filter in resp ["filters" ]:
379
+ client .options (ignore_status = 404 ).ml .delete_filter (
380
+ filter_id = filter ["filter_id" ]
381
+ )
382
+
383
+
384
+ def wipe_calendars (client : Elasticsearch , timeout = 30 ):
385
+ end_time = time .time () + timeout
386
+ while time .time () < end_time :
387
+ resp = client .ml .get_calendars (calendar_id = "*" )
388
+ if resp ["count" ] == 0 :
389
+ break
390
+ for calendar in resp ["calendars" ]:
391
+ client .options (ignore_status = 404 ).ml .delete_calendar (
392
+ calendar_id = calendar ["calendar_id" ]
393
+ )
394
+
395
+
396
+ def wipe_transforms (client : Elasticsearch , timeout = 30 ):
397
+ end_time = time .time () + timeout
398
+ while time .time () < end_time :
399
+ resp = client .transform .get_transform (transform_id = "*" )
400
+ if resp ["count" ] == 0 :
401
+ break
402
+ for trasnform in resp ["transforms" ]:
403
+ client .options (ignore_status = 404 ).transform .stop_transform (
404
+ transform_id = trasnform ["id" ]
405
+ )
406
+ client .options (ignore_status = 404 ).transform .delete_transform (
407
+ transform_id = trasnform ["id" ]
408
+ )
409
+
356
410
357
411
def wait_for_cluster_state_updates_to_finish (client , timeout = 30 ):
358
412
end_time = time .time () + timeout
0 commit comments