-
Notifications
You must be signed in to change notification settings - Fork 63
feat: added queue env example that circumvents the Windows path limit with junctions #277
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
base: mainline
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| specificationVersion: 'environment-2023-09' | ||
| parameterDefinitions: | ||
| - name: JunctionPath | ||
| type: STRING | ||
| default: 'C:\tmp\dc-root' | ||
| description: > | ||
| The short path where the junction will be created. This path will point to | ||
| the session's assetroot folder, allowing applications with MAX_PATH limitations | ||
| (such as After Effects) to access files through a shorter path. | ||
| environment: | ||
| name: Assetroot Junction Creation | ||
| description: | | ||
| Creates a Windows directory junction from a short configurable path to the | ||
| session's assetroot folder, and sets the DEADLINE_ASSETROOT_ALIAS environment | ||
| variable so that compatible job scripts can rewrite file paths through the | ||
| junction. | ||
|
|
||
| This works around the Windows MAX_PATH (260 character) limitation for | ||
| applications that use legacy Win32 APIs (e.g. Adobe After Effects, Cinema4D). | ||
|
|
||
| The junction is removed when the session ends. | ||
|
|
||
| This queue environment is only effective on Windows workers. On non-Windows | ||
| workers the onEnter script exits successfully without creating a junction. | ||
| script: | ||
| actions: | ||
| onEnter: | ||
| command: powershell | ||
| args: | ||
| - "{{Env.File.Enter}}" | ||
| onExit: | ||
| command: powershell | ||
| args: | ||
| - "{{Env.File.Exit}}" | ||
| embeddedFiles: | ||
| - name: Enter | ||
| filename: junction-enter.ps1 | ||
| type: TEXT | ||
| data: | | ||
| $ErrorActionPreference = 'Stop' | ||
| $junctionPath = '{{Param.JunctionPath}}' | ||
|
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.
Contributor
Author
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. A worker can run multiple sessions concurrently?? |
||
|
|
||
| # Ensure parent directory exists | ||
| $parentDir = Split-Path $junctionPath -Parent | ||
| if (!(Test-Path $parentDir)) { | ||
| New-Item -ItemType Directory -Path $parentDir | Out-Null | ||
| } | ||
|
|
||
| # Remove stale junction if it exists | ||
| if (Test-Path $junctionPath) { | ||
| cmd /c "rmdir $junctionPath" | ||
| if (Test-Path $junctionPath) { | ||
| Write-Error "Failed to remove stale junction at $junctionPath" | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| # Find the assetroot folder in the session working directory | ||
| $sessionDir = $PWD.Path | ||
| $assetroot = Get-ChildItem $sessionDir -Directory | Where-Object { $_.Name -like 'assetroot-*' } | Select-Object -First 1 | ||
|
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. This assumes a single assetroot folder and blindly takes
Contributor
Author
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. Will address tomorrow |
||
| if (!$assetroot) { | ||
| Write-Error "No assetroot folder found in session directory: $sessionDir" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Create junction | ||
| $result = cmd /c "mklink /J $junctionPath $($assetroot.FullName)" 2>&1 | ||
|
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. The path arguments to |
||
| if (!(Test-Path $junctionPath)) { | ||
| Write-Error "Failed to create junction: $result" | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Host "Junction created: $junctionPath -> $($assetroot.FullName)" | ||
|
|
||
| # Set the environment variable for downstream job scripts | ||
| Write-Host "openjd_env: DEADLINE_ASSETROOT_ALIAS=$junctionPath" | ||
| - name: Exit | ||
| filename: junction-exit.ps1 | ||
| type: TEXT | ||
| data: | | ||
| $junctionPath = '{{Param.JunctionPath}}' | ||
| if (Test-Path $junctionPath) { | ||
| cmd /c "rmdir $junctionPath" | ||
| Write-Host "Junction removed: $junctionPath" | ||
| } | ||
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.
The description promises that "on non-Windows workers the onEnter script exits successfully without creating a junction," but nothing in the script implements that guard.
command: powershellinvokes Windows PowerShell, which does not exist on Linux/macOS workers, so the onEnter action will fail to launch (or, ifpwshwere used,cmd /c mklinkwould fail) rather than exiting0. Either add an early OS check that exits successfully on non-Windows (e.g.if (-not $IsWindows) { exit 0 }), or adjust the description so it does not claim graceful non-Windows behavior. As written the environment will error the session on any non-Windows worker.