Skip to content

Commit f9da0e7

Browse files
authored
Merge pull request #3290 from dmargala/bugfix/slurm-avail-allow-reserved
[bugfix] Allow RESERVED nodes for Slurm "avail" state
2 parents 4c7fef0 + 9465374 commit f9da0e7

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

reframe/core/schedulers/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def filter_nodes_by_state(nodelist, state):
160160
:arg state: The state of the nodes.
161161
If ``all``, the initial list is returned untouched.
162162
If ``avail``, only the available nodes will be returned.
163-
All other values are interpretes as a state string.
163+
All other values are interpreted as a state string.
164164
State match is exclusive unless the ``*`` is added at the end of the
165165
state string.
166166
:returns: the filtered node list
@@ -169,7 +169,7 @@ def filter_nodes_by_state(nodelist, state):
169169
nodelist = {n for n in nodelist if n.is_avail()}
170170
elif state != 'all':
171171
if state.endswith('*'):
172-
# non-exclusive stat match
172+
# non-exclusive state match
173173
state = state[:-1]
174174
nodelist = {
175175
n for n in nodelist if n.in_state(state)
@@ -180,8 +180,6 @@ def filter_nodes_by_state(nodelist, state):
180180
}
181181

182182
return nodelist
183-
nodes[part.fullname] = [n.name for n in nodelist]
184-
185183

186184

187185
class Job(jsonext.JSONSerializable, metaclass=JobMeta):
@@ -603,7 +601,15 @@ def guess_num_tasks(self):
603601
available_nodes = filter_nodes_by_state(
604602
available_nodes, self.sched_flex_alloc_nodes.lower()
605603
)
604+
getlogger().debug(
605+
f'[F] Total available in state='
606+
f'{self.sched_flex_alloc_nodes.lower()}: {len(available_nodes)}'
607+
)
606608
available_nodes = self.scheduler.filternodes(self, available_nodes)
609+
getlogger().debug(
610+
f'[F] Total available after scheduler filter: '
611+
f'{len(available_nodes)}'
612+
)
607613
return len(available_nodes) * num_tasks_per_node
608614

609615
def submit(self):

reframe/core/schedulers/slurm.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,12 @@ def filternodes(self, job, nodes):
358358
if reservation:
359359
reservation = reservation.strip()
360360
nodes &= self._get_reservation_nodes(reservation)
361-
self.log(f'[F] Filtering nodes by reservation {reservation}: '
362-
f'available nodes now: {len(nodes)}')
361+
else:
362+
nodes = {node for node in nodes if not node.in_state('RESERVED')}
363+
364+
self.log(f'[F] Filtering nodes by reservation={reservation}: '
365+
f'available nodes now: {len(nodes)}')
366+
363367
if partitions:
364368
partitions = set(partitions.strip().split(','))
365369
else:
@@ -693,8 +697,13 @@ def in_statex(self, state):
693697
return self._states == set(state.upper().split('+'))
694698

695699
def is_avail(self):
696-
return any(self.in_statex(s)
697-
for s in ('ALLOCATED', 'COMPLETING', 'IDLE'))
700+
available_states = {
701+
'ALLOCATED',
702+
'COMPLETING',
703+
'IDLE',
704+
'RESERVED',
705+
}
706+
return self._states <= available_states
698707

699708
def is_down(self):
700709
return not self.is_avail()

0 commit comments

Comments
 (0)