-
-
Notifications
You must be signed in to change notification settings - Fork 734
Cluster Dump SchedulerPlugin #5983
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
25cb5e5
Initial commit
sjperkins 81c99c6
test_cluster_dump.py -> test_cluster_dump_plugin.py
sjperkins ff5962d
Default arguments for cluster dump exclude and format arguments
sjperkins abdce6d
Remove logic for creating default url
sjperkins 79e7b9b
Move plugin.before_close() calls before self.status = Status.closing
sjperkins 68b5dbf
Merge branch 'main' into cluster-dump-plugin
sjperkins 0d2b448
Update cluster dump plugin test
sjperkins 060c3e6
Merge branch 'main' into cluster-dump-plugin
sjperkins e75a3ae
Merge branch 'main' into cluster-dump-plugin
sjperkins cb54986
Address review comments
sjperkins 26ab3ca
Merge branch 'main' into cluster-dump-plugin
sjperkins 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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Any, Collection, Dict, Literal | ||
|
||
from distributed.cluster_dump import ( | ||
DEFAULT_CLUSTER_DUMP_EXCLUDE, | ||
DEFAULT_CLUSTER_DUMP_FORMAT, | ||
) | ||
from distributed.diagnostics.plugin import SchedulerPlugin | ||
from distributed.scheduler import Scheduler | ||
|
||
|
||
class ClusterDump(SchedulerPlugin): | ||
"""Dumps cluster state prior to Scheduler shutdown | ||
|
||
The Scheduler may shutdown in cases where it is in an error state, | ||
or when it has been unexpectedly idle for long periods of time. | ||
This plugin dumps the cluster state prior to Scheduler shutdown | ||
for debugging purposes. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
url: str, | ||
exclude: "Collection[str]" = DEFAULT_CLUSTER_DUMP_EXCLUDE, | ||
format_: Literal["msgpack", "yaml"] = DEFAULT_CLUSTER_DUMP_FORMAT, | ||
**storage_options: Dict[str, Any], | ||
): | ||
self.url = url | ||
self.exclude = exclude | ||
self.format = format_ | ||
self.storage_options = storage_options | ||
|
||
async def start(self, scheduler: Scheduler) -> None: | ||
self.scheduler = scheduler | ||
|
||
async def before_close(self) -> None: | ||
await self.scheduler.dump_cluster_state_to_url( | ||
self.url, self.exclude, self.format, **self.storage_options | ||
) |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from distributed.cluster_dump import DumpArtefact | ||
from distributed.diagnostics.cluster_dump import ClusterDump | ||
from distributed.utils_test import gen_cluster, inc | ||
|
||
|
||
@gen_cluster(client=True) | ||
async def test_cluster_dump_plugin(c, s, *workers, tmp_path): | ||
dump_file = tmp_path / "cluster_dump.msgpack.gz" | ||
await c.register_scheduler_plugin(ClusterDump(str(dump_file)), name="cluster-dump") | ||
plugin = s.plugins["cluster-dump"] | ||
assert plugin.scheduler is s | ||
|
||
f1 = c.submit(inc, 1) | ||
f2 = c.submit(inc, f1) | ||
|
||
assert (await f2) == 3 | ||
await s.close(close_workers=True) | ||
|
||
dump = DumpArtefact.from_url(str(dump_file)) | ||
assert {f1.key, f2.key} == set(dump.scheduler_story(f1.key, f2.key).keys()) | ||
assert {f1.key, f2.key} == set(dump.worker_story(f1.key, f2.key).keys()) |
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
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.
Uh oh!
There was an error while loading. Please reload this page.