Skip to content

Commit bb5ee6e

Browse files
authored
Merge pull request #5144 from chu11/job_list_cleanup
job-list: misc cleanup
2 parents b0baf4e + d0597ee commit bb5ee6e

File tree

8 files changed

+57
-34
lines changed

8 files changed

+57
-34
lines changed

doc/man1/flux-jobs.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ OPTIONS
4646
Limit output to N jobs (default 1000)
4747

4848
**--since**\ *WHEN*
49-
Limit output to jobs that completed or have become inactive since a
50-
given timestamp. This option implies ``-a`` if no other ``--filter``
51-
options are specified. If *WHEN* begins with ``-`` character, then
52-
the remainder is considered to be a an offset in Flux standard duration
49+
Limit output to jobs that have been active since a given timestamp. In other
50+
words, jobs that are currently pending, currently running, or became inactive
51+
since the given timestamp. This option implies ``-a`` if no other
52+
``--filter`` options are specified. If *WHEN* begins with ``-`` character,
53+
then the remainder is considered to be a an offset in Flux standard duration
5354
(RFC 23). Otherwise, any datetime expression accepted by the Python
5455
`parsedatetime <https://github.com/bear/parsedatetime>`_ module is
5556
accepted. Examples: "-6h", "-1d", "yesterday", "2021-06-21 6am",

src/bindings/python/flux/job/list.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ def set_user(self, user):
236236
def add_filter(self, fname):
237237
"""Append a state or result filter to JobList query"""
238238
fname = fname.lower()
239-
if fname == "all":
240-
self.states |= self.STATES["pending"]
241-
self.states |= self.STATES["running"]
242-
return
243-
244239
if fname in self.STATES:
245240
self.states |= self.STATES[fname]
246241
elif fname in self.RESULTS:

src/cmd/flux-job.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ int cmd_list (optparse_t *p, int argc, char **argv)
13811381
flux_future_destroy (f);
13821382
flux_close (h);
13831383

1384-
return (0);
1384+
return (0);
13851385
}
13861386

13871387
int cmd_list_inactive (optparse_t *p, int argc, char **argv)
@@ -2566,7 +2566,7 @@ void attach_event_continuation (flux_future_t *f, void *arg)
25662566
else if (streq (name, "submit")) {
25672567
if (!(ctx->exec_eventlog_f = flux_job_event_watch (ctx->h,
25682568
ctx->id,
2569-
"guest.exec.eventlog",
2569+
"guest.exec.eventlog",
25702570
0)))
25712571
log_err_exit ("flux_job_event_watch");
25722572
if (flux_future_then (ctx->exec_eventlog_f,
@@ -2855,12 +2855,12 @@ int cmd_status (optparse_t *p, int argc, char **argv)
28552855
else if (verbose > 1 || exitcode != 0) {
28562856
if (!exception)
28572857
log_msg ("%s: exited with exit code %d",
2858-
jobid,
2859-
exitcode);
2858+
jobid,
2859+
exitcode);
28602860
else
28612861
log_msg ("%s: exception type=%s",
2862-
jobid,
2863-
exc_type);
2862+
jobid,
2863+
exc_type);
28642864
}
28652865
}
28662866
flux_future_destroy (futures[i]);
@@ -3601,10 +3601,10 @@ int cmd_memo (optparse_t *p, int argc, char **argv)
36013601
"id", id,
36023602
"volatile", optparse_hasopt (p, "volatile"),
36033603
"memo", memo)))
3604-
log_err_exit ("flux_rpc_pack");
3604+
log_err_exit ("flux_rpc_pack");
36053605

36063606
if (flux_rpc_get (f, NULL) < 0)
3607-
log_msg_exit ("memo: %s", future_strerror (f, errno));
3607+
log_msg_exit ("memo: %s", future_strerror (f, errno));
36083608

36093609
flux_future_destroy (f);
36103610
flux_close (h);
@@ -3782,10 +3782,10 @@ static char *flux_job_nodeid_to_hostname (flux_jobid_t id, int nodeid)
37823782
log_err_exit ("flux_open");
37833783

37843784
if (!(f = flux_rpc_pack (h, "job-info.lookup", FLUX_NODEID_ANY, 0,
3785-
"{s:I s:[s] s:i}",
3786-
"id", id,
3787-
"keys", "R",
3788-
"flags", 0)))
3785+
"{s:I s:[s] s:i}",
3786+
"id", id,
3787+
"keys", "R",
3788+
"flags", 0)))
37893789
log_err_exit ("flux_rpc_pack");
37903790
if (flux_rpc_get_unpack (f, "{s:s}", "R", &R) < 0
37913791
|| !(rl = rlist_from_R (R))

src/modules/job-list/list.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ int get_jobs_from_list (json_t *jobs,
7979
job = zlistx_first (list);
8080
while (job) {
8181

82-
/* If job->t_inactive > 0. (we're on the inactive jobs list),
83-
* and job->t_inactive > since, then we're done since inactive
84-
* jobs are sorted by inactive time.
82+
/* If job->t_inactive > 0. we're on the inactive jobs list and jobs are
83+
* sorted on the inactive list, larger t_inactive first.
84+
*
85+
* If job->t_inactive > since, this is a job that could potentially be returned
86+
*
87+
* So if job->t_inactive <= since, then we're done b/c the rest of the inactive
88+
* jobs cannot be returned.
8589
*/
8690
if (job->t_inactive > 0. && job->t_inactive <= since)
8791
break;

src/modules/job-list/list.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
void list_cb (flux_t *h, flux_msg_handler_t *mh,
1717
const flux_msg_t *msg, void *arg);
1818

19-
void list_inactive_cb (flux_t *h, flux_msg_handler_t *mh,
20-
const flux_msg_t *msg, void *arg);
21-
2219
void list_id_cb (flux_t *h, flux_msg_handler_t *mh,
2320
const flux_msg_t *msg, void *arg);
2421

t/t2250-job-archive.t

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ test_expect_success 'job-archive: load module' '
171171
flux module load job-archive
172172
'
173173

174+
test_expect_success 'job-archive: launch a running job' '
175+
jobid=`flux submit sleep inf` &&
176+
echo $jobid > long_running_job.id
177+
'
178+
174179
test_expect_success 'job-archive: stores inactive job info (job good)' '
175180
jobid=`flux submit hostname` &&
176181
fj_wait_event $jobid clean &&
@@ -189,6 +194,27 @@ test_expect_success 'job-archive: stores inactive job info (job fail)' '
189194
db_check_values_run $jobid ${ARCHIVEDB}
190195
'
191196

197+
# ensure long running job wasn't stored
198+
test_expect_success 'job-archive: check 2 jobs stored' '
199+
count=`db_count_entries ${ARCHIVEDB}` &&
200+
test $count -eq 2
201+
'
202+
203+
test_expect_success 'job-archive: cancel long running job' '
204+
jobid=$(cat long_running_job.id) &&
205+
flux cancel $jobid &&
206+
fj_wait_event $jobid clean &&
207+
wait_jobid_state $jobid inactive &&
208+
wait_db $jobid ${ARCHIVEDB} &&
209+
db_check_entries $jobid ${ARCHIVEDB} &&
210+
db_check_values_run $jobid ${ARCHIVEDB}
211+
'
212+
213+
test_expect_success 'job-archive: check 3 jobs stored' '
214+
count=`db_count_entries ${ARCHIVEDB}` &&
215+
test $count -eq 3
216+
'
217+
192218
# to ensure job canceled before we run, we submit a job to eat up all
193219
# resources first.
194220
test_expect_success 'job-archive: stores inactive job info (job cancel)' '
@@ -217,7 +243,7 @@ test_expect_success 'job-archive: stores inactive job info (resources)' '
217243

218244
test_expect_success 'job-archive: all jobs stored' '
219245
count=`db_count_entries ${ARCHIVEDB}` &&
220-
test $count -eq 5
246+
test $count -eq 6
221247
'
222248

223249
test_expect_success 'job-archive: reload module' '
@@ -226,7 +252,7 @@ test_expect_success 'job-archive: reload module' '
226252

227253
test_expect_success 'job-archive: doesnt restore old data' '
228254
count=`db_count_entries ${ARCHIVEDB}` &&
229-
test $count -eq 5
255+
test $count -eq 6
230256
'
231257

232258
test_expect_success 'job-archive: stores more inactive job info' '
@@ -246,7 +272,7 @@ test_expect_success 'job-archive: stores more inactive job info' '
246272

247273
test_expect_success 'job-archive: all jobs stored' '
248274
count=`db_count_entries ${ARCHIVEDB}` &&
249-
test $count -eq 7
275+
test $count -eq 8
250276
'
251277

252278
# we don't check values in module stats b/c it can be racy w/ polling
@@ -260,7 +286,7 @@ test_expect_success 'job-archive: unload module' '
260286

261287
test_expect_success 'job-archive: db exists after module unloaded' '
262288
count=`db_count_entries ${ARCHIVEDB}` &&
263-
test $count -eq 7
289+
test $count -eq 8
264290
'
265291

266292
test_expect_success 'job-archive: setup config file without dbpath' '

t/t2260-job-list.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ test_expect_success 'flux job list inactive jobs results are correct' '
185185
test_cmp list_result_I.out list_result_I.exp
186186
'
187187

188-
# Hard code results values for these tests, as we did not add a results
189-
# option to flux_job_list() or the flux-job command.
188+
# flux job list does not take results as an option, test via direct
189+
# call to job-list.list
190190

191191
test_expect_success 'flux job list only canceled jobs' '
192192
id=$(id -u) &&

t/t2800-jobs-cmd.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test_expect_success 'flux-jobs: custom format with numeric spec works' '
182182
test_expect_success 'flux-jobs: collapsible fields work' '
183183
flux jobs -ao "{id.f58:<12} ?:{exception.type:>8}" >nocollapse.out &&
184184
flux jobs -f running,completed \
185-
-ao "{id.f58:<12} ?:{exception.type:>8}" >collapsed.out &&
185+
-o "{id.f58:<12} ?:{exception.type:>8}" >collapsed.out &&
186186
test_debug "head -n1 nocollapse.out" &&
187187
test_debug "head -n1 collapsed.out" &&
188188
grep EXCEPTION-TYPE nocollapse.out &&

0 commit comments

Comments
 (0)