Skip to content

Commit a23f75c

Browse files
dthainbtovar
andauthored
Batch Job: Add prune operation to clean cluster state. (#4193)
* Added batch_job_prune to interface and vine implementation. * Connect makeflow garbage collection to batch_job_prune for cluster cleanup. * Add stub prune option to remainder of batch systems * format --------- Co-authored-by: Benjamin Tovar <[email protected]>
1 parent 8733862 commit a23f75c

13 files changed

+64
-2
lines changed

batch_job/src/batch_queue.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static struct batch_queue_module batch_queue_unknown = {
4444
NULL,
4545
NULL,
4646
NULL,
47+
NULL,
4748
};
4849

4950
#define BATCH_JOB_SYSTEMS "local, vine, wq, condor, uge (sge), pbs, lsf, torque, moab, slurm, amazon, k8s, flux, dryrun"
@@ -249,4 +250,9 @@ int batch_queue_remove(struct batch_queue *q, batch_queue_id_t jobid, batch_queu
249250
return q->module->remove(q, jobid, mode);
250251
}
251252

253+
int batch_queue_prune(struct batch_queue *q, const char *filename)
254+
{
255+
return q->module->prune(q, filename);
256+
}
257+
252258
/* vim: set noexpandtab tabstop=8: */

batch_job/src/batch_queue.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ You must still call @ref batch_queue_wait to wait for the removal to complete.
141141
*/
142142
int batch_queue_remove(struct batch_queue *q, batch_queue_id_t jobid, batch_queue_remove_mode_t mode );
143143

144+
/** Remove in-cluster cached data associated with filename.
145+
This call may be used to indicate that cached data associated with the given
146+
filename will no longer be used in the future, and may be freed.
147+
@param q The queue to prune from.
148+
@param filename The name of the file to be pruned.
149+
@return Greater than zero if the file exists and was pruned, zero otherwise.
150+
*/
151+
152+
int batch_queue_prune(struct batch_queue *q, const char *filename );
153+
144154
/** Converts a string into a batch queue type.
145155
@param str A string listing all of the known batch queue types (which changes over time.)
146156
@return The batch queue type corresponding to the string, or BATCH_QUEUE_TYPE_UNKNOWN if the string is invalid.

batch_job/src/batch_queue_amazon.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ static int batch_queue_amazon_create(struct batch_queue *q)
827827
batch_queue_stub_free(amazon);
828828
batch_queue_stub_port(amazon);
829829
batch_queue_stub_option_update(amazon);
830+
batch_queue_stub_prune(amazon);
830831

831832
const struct batch_queue_module batch_queue_amazon = {
832833
BATCH_QUEUE_TYPE_AMAZON,
@@ -840,4 +841,5 @@ const struct batch_queue_module batch_queue_amazon = {
840841
batch_queue_amazon_submit,
841842
batch_queue_amazon_wait,
842843
batch_queue_amazon_remove,
844+
batch_queue_amazon_prune,
843845
};

batch_job/src/batch_queue_cluster.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ static int batch_queue_cluster_create(struct batch_queue *q)
515515
batch_queue_stub_free(cluster);
516516
batch_queue_stub_port(cluster);
517517
batch_queue_stub_option_update(cluster);
518+
batch_queue_stub_prune(cluster);
518519

519520
const struct batch_queue_module batch_queue_cluster = {
520521
BATCH_QUEUE_TYPE_CLUSTER,
@@ -528,6 +529,7 @@ const struct batch_queue_module batch_queue_cluster = {
528529
batch_queue_cluster_submit,
529530
batch_queue_cluster_wait,
530531
batch_queue_cluster_remove,
532+
batch_queue_cluster_prune,
531533
};
532534

533535
const struct batch_queue_module batch_queue_moab = {
@@ -542,6 +544,7 @@ const struct batch_queue_module batch_queue_moab = {
542544
batch_queue_cluster_submit,
543545
batch_queue_cluster_wait,
544546
batch_queue_cluster_remove,
547+
batch_queue_cluster_prune,
545548
};
546549

547550
const struct batch_queue_module batch_queue_uge = {
@@ -556,6 +559,7 @@ const struct batch_queue_module batch_queue_uge = {
556559
batch_queue_cluster_submit,
557560
batch_queue_cluster_wait,
558561
batch_queue_cluster_remove,
562+
batch_queue_cluster_prune,
559563
};
560564

561565
/* retained sge keyword for backwards compatibility after sge->uge name change. */
@@ -571,6 +575,7 @@ const struct batch_queue_module batch_queue_sge = {
571575
batch_queue_cluster_submit,
572576
batch_queue_cluster_wait,
573577
batch_queue_cluster_remove,
578+
batch_queue_cluster_prune,
574579
};
575580

576581
const struct batch_queue_module batch_queue_pbs = {
@@ -585,6 +590,7 @@ const struct batch_queue_module batch_queue_pbs = {
585590
batch_queue_cluster_submit,
586591
batch_queue_cluster_wait,
587592
batch_queue_cluster_remove,
593+
batch_queue_cluster_prune,
588594
};
589595

590596
const struct batch_queue_module batch_queue_lsf = {
@@ -599,6 +605,7 @@ const struct batch_queue_module batch_queue_lsf = {
599605
batch_queue_cluster_submit,
600606
batch_queue_cluster_wait,
601607
batch_queue_cluster_remove,
608+
batch_queue_cluster_prune,
602609
};
603610

604611
const struct batch_queue_module batch_queue_torque = {
@@ -613,6 +620,7 @@ const struct batch_queue_module batch_queue_torque = {
613620
batch_queue_cluster_submit,
614621
batch_queue_cluster_wait,
615622
batch_queue_cluster_remove,
623+
batch_queue_cluster_prune,
616624
};
617625

618626
const struct batch_queue_module batch_queue_slurm = {
@@ -627,6 +635,7 @@ const struct batch_queue_module batch_queue_slurm = {
627635
batch_queue_cluster_submit,
628636
batch_queue_cluster_wait,
629637
batch_queue_cluster_remove,
638+
batch_queue_cluster_prune,
630639
};
631640

632641
/* vim: set noexpandtab tabstop=8: */

batch_job/src/batch_queue_condor.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ static int batch_queue_condor_create(struct batch_queue *q)
390390
batch_queue_stub_free(condor);
391391
batch_queue_stub_port(condor);
392392
batch_queue_stub_option_update(condor);
393+
batch_queue_stub_prune(condor);
393394

394395
const struct batch_queue_module batch_queue_condor = {
395396
BATCH_QUEUE_TYPE_CONDOR,
@@ -403,6 +404,7 @@ const struct batch_queue_module batch_queue_condor = {
403404
batch_queue_condor_submit,
404405
batch_queue_condor_wait,
405406
batch_queue_condor_remove,
407+
batch_queue_condor_prune,
406408
};
407409

408410
/* vim: set noexpandtab tabstop=8: */

batch_job/src/batch_queue_dryrun.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ static int batch_queue_dryrun_create(struct batch_queue *q)
102102
batch_queue_stub_free(dryrun);
103103
batch_queue_stub_port(dryrun);
104104
batch_queue_stub_option_update(dryrun);
105+
batch_queue_stub_prune(dryrun);
105106

106107
const struct batch_queue_module batch_queue_dryrun = {
107108
BATCH_QUEUE_TYPE_DRYRUN,
@@ -115,6 +116,7 @@ const struct batch_queue_module batch_queue_dryrun = {
115116
batch_queue_dryrun_submit,
116117
batch_queue_dryrun_wait,
117118
batch_queue_dryrun_remove,
119+
batch_queue_dryrun_prune,
118120
};
119121

120122
/* vim: set noexpandtab tabstop=8: */

batch_job/src/batch_queue_flux.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ static int batch_queue_flux_free(struct batch_queue *q)
360360

361361
batch_queue_stub_port(flux);
362362
batch_queue_stub_option_update(flux);
363+
batch_queue_stub_prune(flux);
363364

364365
const struct batch_queue_module batch_queue_flux = {
365366
BATCH_QUEUE_TYPE_FLUX,
@@ -373,6 +374,7 @@ const struct batch_queue_module batch_queue_flux = {
373374
batch_queue_flux_submit,
374375
batch_queue_flux_wait,
375376
batch_queue_flux_remove,
377+
batch_queue_flux_prune,
376378
};
377379

378380
/* vim: set noexpandtab tabstop=8: */

batch_job/src/batch_queue_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ struct batch_queue_module {
3232

3333
batch_queue_id_t (*submit) (struct batch_queue *Q, struct batch_job *bt );
3434
batch_queue_id_t (*wait) (struct batch_queue *Q, struct batch_job_info *info, time_t stoptime);
35-
3635
int (*remove) (struct batch_queue *Q, batch_queue_id_t id, batch_queue_remove_mode_t mode );
36+
int (*prune) (struct batch_queue *Q, const char *filename);
3737
};
3838

3939
struct batch_queue {
@@ -53,7 +53,7 @@ struct batch_queue {
5353
#define batch_queue_stub_free(name) static int batch_queue_##name##_free (struct batch_queue *Q) { return 0; }
5454
#define batch_queue_stub_port(name) static int batch_queue_##name##_port (struct batch_queue *Q) { return 0; }
5555
#define batch_queue_stub_option_update(name) static void batch_queue_##name##_option_update (struct batch_queue *Q, const char *what, const char *value) { return; }
56-
56+
#define batch_queue_stub_prune(name) static int batch_queue_##name##_prune (struct batch_queue *Q, const char *filename ) { return 0; }
5757
#endif
5858

5959
/* vim: set noexpandtab tabstop=8: */

batch_job/src/batch_queue_k8s.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ static int batch_queue_k8s_free(struct batch_queue *q)
694694

695695
batch_queue_stub_port(k8s);
696696
batch_queue_stub_option_update(k8s);
697+
batch_queue_stub_prune(k8s);
697698

698699
const struct batch_queue_module batch_queue_k8s = {
699700
BATCH_QUEUE_TYPE_K8S,
@@ -707,6 +708,7 @@ const struct batch_queue_module batch_queue_k8s = {
707708
batch_queue_k8s_submit,
708709
batch_queue_k8s_wait,
709710
batch_queue_k8s_remove,
711+
batch_queue_k8s_prune,
710712
};
711713

712714
/* vim: set noexpandtab tabstop=8: */

batch_job/src/batch_queue_local.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ static int batch_queue_local_create(struct batch_queue *q)
129129
batch_queue_stub_free(local);
130130
batch_queue_stub_port(local);
131131
batch_queue_stub_option_update(local);
132+
batch_queue_stub_prune(local);
132133

133134
const struct batch_queue_module batch_queue_local = {
134135
BATCH_QUEUE_TYPE_LOCAL,
@@ -142,6 +143,7 @@ const struct batch_queue_module batch_queue_local = {
142143
batch_queue_local_submit,
143144
batch_queue_local_wait,
144145
batch_queue_local_remove,
146+
batch_queue_local_prune,
145147
};
146148

147149
/* vim: set noexpandtab tabstop=8: */

0 commit comments

Comments
 (0)