fixed sheepit functionality for sheepit blender 5.0 update

This commit is contained in:
Nathan
2025-11-25 13:31:13 -07:00
parent 3ef8b09737
commit 0b8f4f30fa
3 changed files with 4887 additions and 11 deletions

View File

@@ -0,0 +1,45 @@
<!-- Generated by SpecStory, Markdown v2.1.0 -->
<!-- cursor Session 21c1dff0-7d20-4158-84d9-19180276948d (2025-11-21 01:14Z) -->
# Workers failing and SSH connection issues (2025-11-21 01:14Z)
_**User (2025-11-21 01:14Z)**_
all workers are failing?
Connecting to i9kf...
exec request failed on channel 0
SSH session ended.
Press Enter to close:
---
_**Agent (model gpt-5.1-codex, mode Agent)**_
<think><details><summary>Thought Process</summary>
**Checking workspace directory**</details></think>
---
<tool-use data-tool-type="generic" data-tool-name="list_dir">
<details>
<summary>Tool use: **list_directory** • Listed directory undefined • **0** results</summary>
No results found
</details>
</tool-use>
---
---

File diff suppressed because one or more lines are too long

View File

@@ -40,11 +40,6 @@ function Get-RemoteSheepItCommand {
$safeKey = $RenderKey -replace "'", "''" $safeKey = $RenderKey -replace "'", "''"
$safeUser = $Username -replace "'", "''" $safeUser = $Username -replace "'", "''"
$userLine = if ([string]::IsNullOrWhiteSpace($Username)) {
''
} else {
" Write-Host 'Authenticating as ${safeUser} via render key.' -ForegroundColor Yellow`n"
}
$urlLiteral = '@(' + (($SheepItJarUrls | ForEach-Object { "'$_'" }) -join ', ') + ')' $urlLiteral = '@(' + (($SheepItJarUrls | ForEach-Object { "'$_'" }) -join ', ') + ')'
@@ -150,15 +145,73 @@ catch {
function New-SheepItSessionScript { function New-SheepItSessionScript {
param( param(
[object]$Worker, [object]$Worker,
[string]$EncodedCommand [string]$RemoteCommand
) )
@" $rawArgs = @($Worker.SSHArgs -split '\s+' | Where-Object { $_ -and $_.Trim().Length -gt 0 })
$sshArgsJson = if ($rawArgs) { ($rawArgs | ConvertTo-Json -Compress) } else { '[]' }
$targetHost = ($rawArgs | Where-Object { $_ -notmatch '^-{1,2}' } | Select-Object -Last 1)
$hostLiteral = if ($targetHost) { "'" + ($targetHost -replace "'", "''") + "'" } else { '$null' }
$portValue = $null
for ($i = 0; $i -lt $rawArgs.Count; $i++) {
if ($rawArgs[$i] -eq '-p' -and $i -lt ($rawArgs.Count - 1)) {
$portValue = $rawArgs[$i + 1]
break
}
}
$portLiteral = if ($portValue) { "'" + ($portValue -replace "'", "''") + "'" } else { '$null' }
$remoteScriptBase64 = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($RemoteCommand))
$scriptContent = @"
Write-Host 'Connecting to $($Worker.Name)...' -ForegroundColor Cyan Write-Host 'Connecting to $($Worker.Name)...' -ForegroundColor Cyan
ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=30 $($Worker.SSHArgs) `"powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -EncodedCommand $EncodedCommand`" `$sshArgs = ConvertFrom-Json '$sshArgsJson'
`$targetHost = $hostLiteral
`$port = $portLiteral
`$scriptBase64 = '$remoteScriptBase64'
if (-not `$targetHost) {
Write-Host "Unable to determine SSH host for $($Worker.Name)." -ForegroundColor Red
return
}
`$localTemp = [System.IO.Path]::GetTempFileName() + '.ps1'
`$remoteScript = [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String(`$scriptBase64))
Set-Content -Path `$localTemp -Value `$remoteScript -Encoding UTF8
`$remoteFile = "sheepit-$([System.Guid]::NewGuid().ToString()).ps1"
`$scpArgs = @('-o','ServerAliveInterval=60','-o','ServerAliveCountMax=30')
if (`$port) {
`$scpArgs += '-P'
`$scpArgs += `$port
}
`$scpArgs += `$localTemp
`$scpArgs += ("${targetHost}:`$remoteFile")
Write-Host "Transferring SheepIt script to `$targetHost..." -ForegroundColor Gray
& scp @scpArgs
if (`$LASTEXITCODE -ne 0) {
Write-Host "Failed to copy script to `$targetHost." -ForegroundColor Red
Remove-Item `$localTemp -ErrorAction SilentlyContinue
return
}
`$sshBase = @('-o','ServerAliveInterval=60','-o','ServerAliveCountMax=30') + `$sshArgs
`$execArgs = `$sshBase + @('powershell','-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-File',"`$remoteFile")
Write-Host "Starting SheepIt client on `$targetHost..." -ForegroundColor Cyan
& ssh @execArgs
Write-Host "Cleaning up remote script..." -ForegroundColor Gray
`$cleanupArgs = `$sshBase + @('powershell','-NoLogo','-NoProfile','-ExecutionPolicy','Bypass','-Command',"`$ErrorActionPreference='SilentlyContinue'; Remove-Item -LiteralPath ``"$remoteFile``" -ErrorAction SilentlyContinue")
& ssh @cleanupArgs | Out-Null
Remove-Item `$localTemp -ErrorAction SilentlyContinue
Write-Host "`nSSH session ended." -ForegroundColor Yellow Write-Host "`nSSH session ended." -ForegroundColor Yellow
Read-Host "Press Enter to close" Read-Host "Press Enter to close"
"@ "@
return $scriptContent
} }
function Start-SheepItTab { function Start-SheepItTab {
@@ -188,8 +241,7 @@ function Start-SheepItWorker {
Initialize-SheepItCredentials Initialize-SheepItCredentials
$remoteCommand = Get-RemoteSheepItCommand -RenderKey $script:SheepItRenderKey -Username $script:SheepItUsername $remoteCommand = Get-RemoteSheepItCommand -RenderKey $script:SheepItRenderKey -Username $script:SheepItUsername
$encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($remoteCommand)) $sessionScript = New-SheepItSessionScript -Worker $Worker -RemoteCommand $remoteCommand
$sessionScript = New-SheepItSessionScript -Worker $Worker -EncodedCommand $encoded
$title = "$($Worker.Name) - SheepIt" $title = "$($Worker.Name) - SheepIt"
Start-SheepItTab -Title $title -Content $sessionScript Start-SheepItTab -Title $title -Content $sessionScript