Repository navigation
Commit 3252e69
authored
feat!: shorten the session working directory name for Windows MAX_PATH (#348)
* feat!: shorten the session working directory name for Windows MAX_PATH
The applications a job runs on Windows -- After Effects and Cinema4D among
them -- use the legacy Win32 file APIs, which cap a path at MAX_PATH (260
characters) regardless of the LongPathsEnabled registry value and regardless
of whether this library prefixes its own paths with \\?\. Nothing but a
shorter path helps them.
The session working directory name was the full session id used verbatim as
the mkdtemp() prefix. For a Deadline Cloud session that is 40 characters
(`session-` plus a 32 character hex uuid) plus mkdtemp()'s 8 random
characters: 48 characters, of which the uuid and the random suffix were both
sources of uniqueness. Only one of them needs to be.
Use the last SESSION_DIR_ID_LENGTH (6) characters of the session id as the
prefix instead, giving a 14 character name -- 34 characters recovered. The
tail rather than the head because a session id conventionally leads with
constant text saying what kind of id it is, so a leading slice can carry no
correlation at all.
Uniqueness is unaffected. mkdtemp() creates each candidate name with an
exclusive mkdir() and retries on FileExistsError (verified identical in
CPython 3.9 through 3.14, the supported range), so it cannot return an
existing directory however short the prefix is. The truncated id is purely an
operator-facing label; the full id is unchanged and still appears on every log
record for the session and immediately beside this directory's path at
initialization.
Also shorten the embedded files subdirectory prefix from "embedded_files" to
"ef", recovering 12 more characters from every embedded file path. That
directory nests inside the session working directory, so its name is charged
to everything beneath it.
BREAKING CHANGE: the on-disk name of the session working directory is no
longer prefixed with the session id, and the embedded files subdirectory is
named "ef<random>" rather than "embedded_files<random>". Neither name is part
of the public Python interface -- Session.working_directory and
Session.files_directory are unchanged, as is OPENJD_SESSION_WORKING_DIR -- but
anything that pattern-matches the directory name must be updated. Known
consumer: deadline-cloud-worker-agent's test/e2e/test_worker_config.py
asserts a `session-[a-f0-9]{32}` directory name, and its docs/state.md
documents the old shape.
Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>
* Address review: deterministic dir-name tests + doc callouts
- test_full_session_id_remains_in_the_log: filter to openjd.sessions
records and default the session_id getattr to None, so a dropped
LoggerAdapter fails the assertion instead of passing vacuously.
- Replace the probabilistic name-inspection assertions with a
deterministic check that TempDir is called with prefix="".
- Assert the name length as a <= budget ceiling rather than == to an
incidental CPython detail.
- Narrow the concurrent test's except from BaseException to Exception
(CodeQL).
- Fix TempDir.prefix docstring (default is None -> "tmp", not "").
- Note on working_directory / retain_working_dir that the directory name
no longer carries session identity; the log holds that mapping.
Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>
---------
Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>1 parent 5a80e92 commit 3252e69
3 files changed
Lines changed: 229 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
77 | 93 | | |
78 | 94 | | |
79 | 95 | | |
| |||
401 | 417 | | |
402 | 418 | | |
403 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
404 | 426 | | |
405 | 427 | | |
406 | 428 | | |
| |||
616 | 638 | | |
617 | 639 | | |
618 | 640 | | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
619 | 645 | | |
620 | 646 | | |
621 | 647 | | |
| |||
2146 | 2172 | | |
2147 | 2173 | | |
2148 | 2174 | | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
2149 | 2179 | | |
2150 | | - | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
2151 | 2186 | | |
2152 | 2187 | | |
2153 | 2188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
265 | 267 | | |
266 | 268 | | |
267 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
548 | 551 | | |
549 | 552 | | |
550 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
551 | 741 | | |
552 | 742 | | |
553 | 743 | | |
| |||
0 commit comments