Track Gjallar witness surgery in Idunn

This commit is contained in:
Meta Vens 2026-06-16 19:29:20 +01:00
commit 3609fdc680
3 changed files with 52 additions and 20 deletions

View file

@ -2,6 +2,7 @@ param(
[string] $GjallarRoot = "E:\Projects\Gjallar",
[string] $SshTarget = "nwroot",
[string] $RemoteDir = "/opt/gamecult/gjallar",
[string] $CultCachePath = "/var/lib/gamecult/gjallar/cultcache/gjallar.service.cc",
[string] $IdunnRudpHealth = "10.77.0.2:17870",
[string] $IdunnDaemon = "nightwing-gjallar",
[string] $IdunnHealthContract = "gjallar.cultnet-rudp-framebuffer-composition-health"
@ -45,15 +46,17 @@ if ($LASTEXITCODE -ne 0) {
throw "scp failed with exit code $LASTEXITCODE"
}
$cultCacheDir = if ($CultCachePath.LastIndexOf('/') -gt 0) { $CultCachePath.Substring(0, $CultCachePath.LastIndexOf('/')) } else { "." }
$dropIn = @"
[Service]
Environment=GJALLAR_CULTCACHE_PATH=$CultCachePath
Environment=GJALLAR_IDUNN_RUDP_HEALTH=$IdunnRudpHealth
Environment=GJALLAR_IDUNN_DAEMON=$IdunnDaemon
Environment=GJALLAR_IDUNN_HEALTH_CONTRACT=$IdunnHealthContract
"@
$dropInBase64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($dropIn))
ssh.exe $SshTarget "mkdir -p '$RemoteDir' /etc/systemd/system/gjallar.service.d && tar -xf /tmp/gjallar-publish.tar -C '$RemoteDir' && chmod +x '$RemoteDir/Gjallar' && printf '%s' '$dropInBase64' | base64 -d > /etc/systemd/system/gjallar.service.d/idunn-rudp-health.conf && systemctl daemon-reload && systemctl restart gjallar.service && systemctl is-active --quiet gjallar.service"
ssh.exe $SshTarget "mkdir -p '$RemoteDir' '$cultCacheDir' /etc/systemd/system/gjallar.service.d && tar -xf /tmp/gjallar-publish.tar -C '$RemoteDir' && chmod +x '$RemoteDir/Gjallar' && printf '%s' '$dropInBase64' | base64 -d > /etc/systemd/system/gjallar.service.d/idunn-rudp-health.conf && systemctl daemon-reload && systemctl restart gjallar.service && systemctl is-active --quiet gjallar.service"
if ($LASTEXITCODE -ne 0) {
throw "remote deploy or restart failed with exit code $LASTEXITCODE"
}

View file

@ -3,6 +3,7 @@ param(
[string] $SshTarget = "nightwing",
[string] $RemoteManifest = "/opt/gamecult/gjallar/gamecult-gjallar-deploy-manifest.txt",
[string] $RemoteStatus = "/var/log/gjallar.status",
[string] $RemoteCultCache = "/var/lib/gamecult/gjallar/cultcache/gjallar.service.cc",
[int] $MaxStatusAgeSeconds = 120,
[int] $MinCatalogProviders = 1,
[int] $MinComposedProviders = 1
@ -66,6 +67,11 @@ if ($status.status -ne "rendered") {
Fail-IdunnHealth -State "failed" -Message "Nightwing Gjallar framebuffer status is '$($status.status)', expected rendered."
}
if ($null -eq $status.cultCacheWitness -or $status.cultCacheWitness.status -ne "published") {
$detail = if ($null -eq $status.cultCacheWitness) { "missing cultCacheWitness status" } else { $status.cultCacheWitness.error }
Fail-IdunnHealth -State "degraded" -Message "Nightwing Gjallar has not published the daemon-owned CultCache witness. $detail"
}
if ($status.receive.status -ne "catalog-composed") {
$detail = $status.receive.error
if ([string]::IsNullOrWhiteSpace($detail)) {
@ -87,4 +93,25 @@ if ($null -eq $status.idunnRudpHealth -or $status.idunnRudpHealth.status -ne "pu
Fail-IdunnHealth -State "degraded" -Message "Nightwing Gjallar has not published daemon-owned Idunn RUDP health. $detail"
}
$cultCacheStat = ssh.exe -o BatchMode=yes -o ConnectTimeout=5 $SshTarget "stat -c '%s %Y' '$RemoteCultCache' 2>/dev/null"
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($cultCacheStat)) {
Fail-IdunnHealth -State "failed" -Message "Nightwing Gjallar CultCache witness is missing at $RemoteCultCache."
}
$cultCacheParts = $cultCacheStat.Trim() -split '\s+'
if ($cultCacheParts.Length -lt 2) {
Fail-IdunnHealth -State "failed" -Message "Nightwing Gjallar CultCache witness stat output was malformed: $cultCacheStat"
}
$cultCacheSize = [int64]$cultCacheParts[0]
$cultCacheModifiedUtc = [DateTimeOffset]::FromUnixTimeSeconds([int64]$cultCacheParts[1])
$cultCacheAgeSeconds = ([DateTimeOffset]::UtcNow - $cultCacheModifiedUtc).TotalSeconds
if ($cultCacheSize -le 0) {
Fail-IdunnHealth -State "failed" -Message "Nightwing Gjallar CultCache witness at $RemoteCultCache is empty."
}
if ($cultCacheAgeSeconds -gt $MaxStatusAgeSeconds) {
Fail-IdunnHealth -State "failed" -Message "Nightwing Gjallar CultCache witness is stale ($([math]::Round($cultCacheAgeSeconds))s old)."
}
Write-Host "Nightwing Gjallar is active, deployed at $localCommit, and composing $($status.receive.composedProviders)/$($status.receive.catalogProviders) providers."