Initial project import
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
param(
|
||||
[string]$RestDockerHost = "ssh://docker-gpu.cin.su",
|
||||
[string]$RestDockerHost = "ssh://docker.cin.su",
|
||||
[string]$McpDockerHost = "ssh://docker.cin.su",
|
||||
[string]$RestComposePath = "core/deploy/docker-gpu/adapter-1c/compose.yaml",
|
||||
[string]$RestComposePath = "core/deploy/docker/adapter-1c/compose.yaml",
|
||||
[string]$McpComposePath = "core/deploy/docker/adapter-1c-mcp/compose.yaml",
|
||||
[string]$RestEnvFile,
|
||||
[string]$McpEnvFile,
|
||||
[string]$RestServiceName = "adapter-1c-rest",
|
||||
[string]$RestAuditServiceName = "adapter-1c-audit",
|
||||
[string]$McpServiceName = "adapter-1c-mcp",
|
||||
[string]$McpAuditServiceName = "adapter-1c-mcp-audit",
|
||||
[string[]]$BaseId,
|
||||
[string]$AdapterUrl = "http://docker-gpu.cin.su:8011",
|
||||
[string]$AdapterUrl = "http://docker.cin.su:8011",
|
||||
[string]$McpUrl = "http://docker.cin.su:8021",
|
||||
[string]$ObjectRef,
|
||||
[string]$ObjectKind,
|
||||
@@ -19,6 +23,7 @@ param(
|
||||
[switch]$SkipRest,
|
||||
[switch]$SkipMcp,
|
||||
[switch]$SkipVerify,
|
||||
[switch]$SkipDrainCheck,
|
||||
[switch]$SkipWritePlanSafetySmoke,
|
||||
[switch]$SkipWriteRollbackSafetySmoke,
|
||||
[switch]$SkipSavedStateDiffSmoke,
|
||||
@@ -50,9 +55,13 @@ function Invoke-ComposeUp {
|
||||
[string]$Label,
|
||||
[string]$DockerHost,
|
||||
[string]$ComposePath,
|
||||
[string]$EnvFile,
|
||||
[string]$ServiceName
|
||||
)
|
||||
$command = @("docker", "--host", $DockerHost, "compose", "-f", $ComposePath, "up", "-d", "--no-deps")
|
||||
if ($EnvFile) {
|
||||
$command = @("docker", "--host", $DockerHost, "compose", "--env-file", $EnvFile, "-f", $ComposePath, "up", "-d", "--no-deps")
|
||||
}
|
||||
if (-not $NoBuild) {
|
||||
$command += "--build"
|
||||
}
|
||||
@@ -60,6 +69,34 @@ function Invoke-ComposeUp {
|
||||
Invoke-CheckedCommand -Label $Label -Command $command
|
||||
}
|
||||
|
||||
function Wait-RestAdapterIdle {
|
||||
if ($SkipDrainCheck) {
|
||||
Write-Host "[skip] REST drain check was explicitly skipped"
|
||||
return
|
||||
}
|
||||
$deadline = [DateTime]::UtcNow.AddSeconds($TimeoutSec)
|
||||
$lastIssue = ""
|
||||
while ([DateTime]::UtcNow -lt $deadline) {
|
||||
try {
|
||||
$health = Invoke-RestMethod -Method Get -Uri ($AdapterUrl.TrimEnd('/') + "/health") -TimeoutSec 10
|
||||
$runtime = $health.runtime
|
||||
if (-not $runtime) {
|
||||
Write-Warning "REST adapter is a legacy image without runtime drain telemetry; proceeding with this one transition deployment"
|
||||
return
|
||||
}
|
||||
if ($runtime -and $runtime.state -eq "ready" -and [int]$runtime.active_rpc_count -eq 0) {
|
||||
Write-Host "[ready] REST adapter has no active RPC calls"
|
||||
return
|
||||
}
|
||||
$lastIssue = "state=$($runtime.state) active_rpc_count=$($runtime.active_rpc_count)"
|
||||
} catch {
|
||||
$lastIssue = $_.Exception.Message
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
throw "REST adapter did not become idle before deployment: $lastIssue. Re-run later or pass -SkipDrainCheck only after confirming no write is active."
|
||||
}
|
||||
|
||||
function Ensure-RestServiceToken {
|
||||
if ($env:ONEC_ADAPTER_SERVICE_TOKEN) {
|
||||
return
|
||||
@@ -135,15 +172,27 @@ try {
|
||||
$env:ONEC_ADAPTER_ALLOW_UNAUTHENTICATED_ADMIN = "true"
|
||||
}
|
||||
Ensure-RestServiceToken
|
||||
Wait-RestAdapterIdle
|
||||
Invoke-ComposeUp `
|
||||
-Label "Deploy REST adapter" `
|
||||
-DockerHost $RestDockerHost `
|
||||
-ComposePath $RestComposePath `
|
||||
-EnvFile $RestEnvFile `
|
||||
-ServiceName $RestServiceName
|
||||
Write-ContainerSummary `
|
||||
-Label "REST adapter container" `
|
||||
-DockerHost $RestDockerHost `
|
||||
-ServiceName $RestServiceName
|
||||
Invoke-ComposeUp `
|
||||
-Label "Deploy REST audit analyzer" `
|
||||
-DockerHost $RestDockerHost `
|
||||
-ComposePath $RestComposePath `
|
||||
-EnvFile $RestEnvFile `
|
||||
-ServiceName $RestAuditServiceName
|
||||
Write-ContainerSummary `
|
||||
-Label "REST audit analyzer container" `
|
||||
-DockerHost $RestDockerHost `
|
||||
-ServiceName $RestAuditServiceName
|
||||
}
|
||||
|
||||
if (-not $SkipMcp) {
|
||||
@@ -151,11 +200,22 @@ try {
|
||||
-Label "Deploy MCP proxy" `
|
||||
-DockerHost $McpDockerHost `
|
||||
-ComposePath $McpComposePath `
|
||||
-EnvFile $McpEnvFile `
|
||||
-ServiceName $McpServiceName
|
||||
Write-ContainerSummary `
|
||||
-Label "MCP proxy container" `
|
||||
-DockerHost $McpDockerHost `
|
||||
-ServiceName $McpServiceName
|
||||
Invoke-ComposeUp `
|
||||
-Label "Deploy MCP audit analyzer" `
|
||||
-DockerHost $McpDockerHost `
|
||||
-ComposePath $McpComposePath `
|
||||
-EnvFile $McpEnvFile `
|
||||
-ServiceName $McpAuditServiceName
|
||||
Write-ContainerSummary `
|
||||
-Label "MCP audit analyzer container" `
|
||||
-DockerHost $McpDockerHost `
|
||||
-ServiceName $McpAuditServiceName
|
||||
}
|
||||
|
||||
if (-not $SkipVerify) {
|
||||
|
||||
Reference in New Issue
Block a user