-
Notifications
You must be signed in to change notification settings - Fork 117
[feat] Improve handling of maintenance reservations in Slurm #3573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ekouts
wants to merge
9
commits into
reframe-hpc:develop
Choose a base branch
from
ekouts:feat/maint_nodes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2e35f41
Add maintenance as avail state for maintenance reservations
ekouts 08dbe18
Merge branch 'develop' of https://github.com/reframe-hpc/reframe into…
ekouts c0d9fb3
Merge branch 'develop' of https://github.com/reframe-hpc/reframe into…
ekouts e2be277
Merge branch 'develop' of https://github.com/reframe-hpc/reframe into…
ekouts c7e38c4
Add log
ekouts 24aa49a
Move is_avail and is_down functions in scheduler
ekouts 0ff3fa4
Small fixes
ekouts d93555c
Merge branch 'develop' of https://github.com/reframe-hpc/reframe into…
ekouts beec7ab
Extend and enhance the unit tests for Slurm available nodes
vkarak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -147,6 +147,13 @@ def __init__(self): | |||||
| self._sched_access_in_submit = self.get_option( | ||||||
| 'sched_access_in_submit' | ||||||
| ) | ||||||
| self.node_available_states = { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this needs to be public:
Suggested change
|
||||||
| 'ALLOCATED', | ||||||
| 'COMPLETING', | ||||||
| 'IDLE', | ||||||
| 'PLANNED', | ||||||
| 'RESERVED' | ||||||
| } | ||||||
|
|
||||||
| def make_job(self, *args, **kwargs): | ||||||
| return _SlurmJob(*args, **kwargs) | ||||||
|
|
@@ -317,7 +324,7 @@ def submit(self, job): | |||||
|
|
||||||
| def allnodes(self): | ||||||
| try: | ||||||
| completed = _run_strict('scontrol -a show -o nodes') | ||||||
| completed = _run_strict('scontrol -a show -o node') | ||||||
| except SpawnedProcessError as e: | ||||||
| raise JobSchedulerError( | ||||||
| 'could not retrieve node information') from e | ||||||
|
|
@@ -429,14 +436,24 @@ def filternodes(self, job, nodes): | |||||
|
|
||||||
| def _get_reservation_nodes(self, reservation): | ||||||
| completed = _run_strict('scontrol -a show res %s' % reservation) | ||||||
| node_match = re.search(r'(Nodes=\S+)', completed.stdout) | ||||||
| node_match = re.search(r'Nodes=(\S+)', completed.stdout) | ||||||
| if node_match: | ||||||
| reservation_nodes = node_match[1] | ||||||
| else: | ||||||
| raise JobSchedulerError("could not extract the node names for " | ||||||
| "reservation '%s'" % reservation) | ||||||
|
|
||||||
| completed = _run_strict('scontrol -a show -o %s' % reservation_nodes) | ||||||
| flags_match = re.search(r'Flags=(\S+)', completed.stdout) | ||||||
| if flags_match: | ||||||
| if 'MAINT' in flags_match.group(1).split(','): | ||||||
| self.node_available_states.add('MAINTENANCE') | ||||||
| else: | ||||||
| self.log(f"could not extract the reservation flags for " | ||||||
| f"reservation '{reservation}'") | ||||||
|
Comment on lines
+450
to
+452
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if instead of logging only the self.log(f'reservation info\n{completed.stdout}') |
||||||
|
|
||||||
| completed = _run_strict( | ||||||
| f'scontrol -a show -o node {reservation_nodes}' | ||||||
| ) | ||||||
| node_descriptions = completed.stdout.splitlines() | ||||||
| return _create_nodes(node_descriptions) | ||||||
|
|
||||||
|
|
@@ -594,7 +611,7 @@ def _do_cancel_if_blocked(self, job, reason_descr): | |||||
| self.log(f'Checking if nodes {node_names!r} ' | ||||||
| f'are indeed unavailable') | ||||||
| nodes = self._get_nodes_by_name(node_names) | ||||||
| if not any(n.is_down() for n in nodes): | ||||||
| if not any(self.is_node_down(n) for n in nodes): | ||||||
| return | ||||||
|
|
||||||
| self.cancel(job) | ||||||
|
|
@@ -630,6 +647,12 @@ def cancel(self, job): | |||||
| def finished(self, job): | ||||||
| return slurm_state_completed(job.state) | ||||||
|
|
||||||
| def is_node_avail(self, node): | ||||||
| return node.states <= self.node_available_states | ||||||
|
|
||||||
| def is_node_down(self, node): | ||||||
| return not self.is_node_avail(node) | ||||||
|
|
||||||
|
|
||||||
| @register_scheduler('squeue') | ||||||
| class SqueueJobScheduler(SlurmJobScheduler): | ||||||
|
|
@@ -734,19 +757,6 @@ def in_state(self, state): | |||||
| def in_statex(self, state): | ||||||
| return self._states == set(state.upper().split('+')) | ||||||
|
|
||||||
| def is_avail(self): | ||||||
| available_states = { | ||||||
| 'ALLOCATED', | ||||||
| 'COMPLETING', | ||||||
| 'IDLE', | ||||||
| 'PLANNED', | ||||||
| 'RESERVED' | ||||||
| } | ||||||
| return self._states <= available_states | ||||||
|
|
||||||
| def is_down(self): | ||||||
| return not self.is_avail() | ||||||
|
|
||||||
| def satisfies(self, slurm_constraint): | ||||||
| # Convert the Slurm constraint to a Python expression and evaluate it, | ||||||
| # but restrict our syntax to accept only AND or OR constraints and | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if made this a scheduler's method?