Skip to content

Commit

Permalink
Sched crash when array job and reservation is submitted (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
arungrover authored and bhroam committed May 1, 2019
1 parent 247e454 commit af90831
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
24 changes: 19 additions & 5 deletions src/scheduler/simulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,21 @@ create_events(server_info *sinfo)
int errflag = 0;
int i = 0;
time_t end = 0;
resource_resv **all_resresv_copy;
int all_resresv_len;

/* all_resresv is sorted such that the timed events are in the front of
* the array. Once the first non-timed event is reached, we're done
/* create a temporary copy of all_resresv array which is sorted such that
* the timed events are in the front of the array.
* Once the first non-timed event is reached, we're done
*/
all = sinfo->all_resresv;
all_resresv_len = count_array((void **)sinfo->all_resresv);
all_resresv_copy = malloc((all_resresv_len + 1) * sizeof(resource_resv *));
if (all_resresv_copy == NULL)
return 0;
for (i = 0; sinfo->all_resresv[i] != NULL; i++)
all_resresv_copy[i] = sinfo->all_resresv[i];
all_resresv_copy[i] = NULL;
all = all_resresv_copy;

/* sort the all resersv list so all the timed events are in the front */
qsort(all, count_array((void **)all), sizeof(resource_resv *), cmp_events);
Expand Down Expand Up @@ -901,18 +911,22 @@ create_events(server_info *sinfo)
if (node->is_sleeping) {
te = create_event(TIMED_NODE_UP_EVENT, sinfo->server_time + PROVISION_DURATION,
(event_ptr_t *) node, (event_func_t) node_up_event, NULL);
if (te == NULL)
return 0;
if (te == NULL) {
errflag++;
break;
}
events = add_timed_event(events, te);
}
}

/* A malloc error was encountered, free all allocated memory and return */
if (errflag > 0) {
free_timed_event_list(events);
free(all_resresv_copy);
return 0;
}

free(all_resresv_copy);
return events;
}

Expand Down
31 changes: 28 additions & 3 deletions test/tests/pbs_smoketest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,42 @@ def test_submit_job_array(self):
self.server.expect(JOB, {'job_state=R': 3}, count=True,
id=jid, extend='t')

@skipOnCpuSet
def test_advance_reservation(self):
"""
Test to submit an advanced reservation
Test to submit an advanced reservation and submit jobs to that
reservation. Check if the reservation gets confimed and the jobs
inside the reservation starts running when the reservation runs.
"""
r = Reservation()
a = {'Resource_List.select': '1:ncpus=1'}
a = {'resources_available.ncpus': 4}
self.server.manager(MGR_CMD_SET, NODE, a, id=self.mom.shortname)
r = Reservation(TEST_USER)
now = int(time.time())
a = {'Resource_List.select': '1:ncpus=4',
'reserve_start': now + 10,
'reserve_end': now + 110}
r.set_attributes(a)
rid = self.server.submit(r)
rid_q = rid.split('.')[0]
a = {'reserve_state': (MATCH_RE, "RESV_CONFIRMED|2")}
self.server.expect(RESV, a, id=rid)

# submit a normal job and an array job to the reservation
a = {'Resource_List.select': '1:ncpus=1',
ATTR_q: rid_q}
j1 = Job(TEST_USER, attrs=a)
jid1 = self.server.submit(j1)

a = {'Resource_List.select': '1:ncpus=1',
ATTR_q: rid_q, ATTR_J: '1-2'}
j2 = Job(TEST_USER, attrs=a)
jid2 = self.server.submit(j2)

a = {'reserve_state': (MATCH_RE, "RESV_RUNNING|5")}
self.server.expect(RESV, a, id=rid, interval=1)
self.server.expect(JOB, {'job_state': 'R'}, jid1)
self.server.expect(JOB, {'job_state': 'B'}, jid2)

def test_standing_reservation(self):
"""
Test to submit a standing reservation
Expand Down

0 comments on commit af90831

Please sign in to comment.