From b0c47ea68111d30b5f3b62f243cf77ec421be849 Mon Sep 17 00:00:00 2001 From: James Nesbitt Date: Thu, 12 Nov 2026 14:58:14 +0200 Subject: [PATCH] [PRODENG-3924] Diagnose the Windows AllSigned install refusal main cannot install MCR on Windows. Run 43206166973 failed on all three hosts -- Server 2019, 2022 and 2025 -- about two seconds after "running installer": File C:\Users\Administrator\installerWindows40269044.ps1 cannot be loaded. The contents of file ... That is PowerShell refusing the script under -ExecutionPolicy AllSigned, which #699 introduced in place of Bypass. It affects every customer on the default installURLWindows, not just CI. The message is cut off exactly where the reason would be, and the two candidate reasons need opposite fixes: "...might have been changed by an unauthorized party" the file was altered between download and execution "...might not be trusted" the signature is fine but the publisher is not in the host's TrustedPublisher store, and a prompt under -NonInteractive is a hard failure Neither is recoverable from the truncated form, so this adds the diagnostics first. On an install failure the error now carries the installer's own output, Get-AuthenticodeSignature's status, message and signer, and Get-ExecutionPolicy -List. It is the Windows counterpart of the journalctl capture EnableMCR does on Linux, added in #699 for the same reason: the only description of what went wrong was discarded. Ruled out already, measured rather than assumed: the download-and-cache step preserves the file exactly. Replicating downloadInstaller against get.mirantis.com/install.ps1 reproduces the published sha256 at all 71,351 bytes, so if the bytes change it happens in remotefs.Upload, not before it. Also exposes spec.mcr.installURLWindowsAllowUnsigned through the aws-simple example, defaulting false as launchpad does, and sets it true for the smoke suites. Without that every Windows suite dies at Install MCR before reaching any launchpad behaviour, which makes smoke-windows useless as a signal on unrelated work -- #695 was failed by this, having changed nothing on the path. This does not decide what AllSigned should ultimately do. It makes the next Windows run say which fix is needed, and restores smoke-windows as a signal meanwhile. Verified: go build, go vet, make lint 0 issues, make unit-test 0 failures, terraform fmt clean. Written by AI: claude-opus-5 Signed-off-by: James Nesbitt --- .changes/PRODENG-3924-windows-allsigned.md | 18 ++++++++ examples/terraform/aws-simple/launchpad.tf | 12 +++++- pkg/configurer/windows.go | 48 +++++++++++++++++++++- test/smoke/smoke_test.go | 6 +++ 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 .changes/PRODENG-3924-windows-allsigned.md diff --git a/.changes/PRODENG-3924-windows-allsigned.md b/.changes/PRODENG-3924-windows-allsigned.md new file mode 100644 index 00000000..b58a7738 --- /dev/null +++ b/.changes/PRODENG-3924-windows-allsigned.md @@ -0,0 +1,18 @@ +**Windows MCR install failures now say why PowerShell refused the script.** + +rig truncates a command's output into its error at roughly a hundred +characters, so a refusal arrived as `File C:\...\installerWindows123.ps1 +cannot be loaded. The contents of file ...` — cut off exactly where the +reason would be. An install failure now carries the installer's own output, +the script's `Get-AuthenticodeSignature` status and signer, and the host's +effective execution policies. + +**`spec.mcr.installURLWindowsAllowUnsigned` is exposed by the aws-simple +example**, as `launchpad.mcr_install_url_windows_allow_unsigned`. It +defaults to `false`, matching launchpad's own default. + +The smoke suites set it to `true`. Enforcing `-ExecutionPolicy AllSigned` +causes a stock Windows host to refuse the signed script published at +get.mirantis.com, so every Windows host fails at Install MCR before any +launchpad behaviour is exercised. The opt-out keeps the suites meaningful +while the refusal is diagnosed. diff --git a/examples/terraform/aws-simple/launchpad.tf b/examples/terraform/aws-simple/launchpad.tf index 93739644..0f9aa2a4 100644 --- a/examples/terraform/aws-simple/launchpad.tf +++ b/examples/terraform/aws-simple/launchpad.tf @@ -16,8 +16,15 @@ variable "launchpad" { mcr_channel = string mcr_repo_url = optional(string, "https://repos.mirantis.com") - mke_version = string - msr_version = string // unused if you have no MSR hosts + + // Runs the Windows MCR install script without requiring an Authenticode + // signature. Defaults to false, matching launchpad's own default. The + // smoke suites set it true while PRODENG-3924's AllSigned enforcement is + // under investigation: a stock Windows host refuses the signed script and + // the install fails before any launchpad behaviour is exercised. + mcr_install_url_windows_allow_unsigned = optional(bool, false) + mke_version = string + msr_version = string // unused if you have no MSR hosts mke_connect = object({ username = string @@ -257,6 +264,7 @@ spec: channel: ${var.launchpad.mcr_channel} repoURL: ${var.launchpad.mcr_repo_url} installURLWindows: https://get.mirantis.com/install.ps1 + installURLWindowsAllowUnsigned: ${var.launchpad.mcr_install_url_windows_allow_unsigned} prune: true mke: version: ${var.launchpad.mke_version} diff --git a/pkg/configurer/windows.go b/pkg/configurer/windows.go index b49e1a30..50ff0fdc 100644 --- a/pkg/configurer/windows.go +++ b/pkg/configurer/windows.go @@ -106,6 +106,52 @@ func installerExecutionPolicy(allowUnsigned bool) string { return "AllSigned" } +// installerDiagnostics describes why PowerShell refused or failed the install +// script, for attaching to the error the caller returns. +// +// rig truncates a command's output into its error at about a hundred +// characters, so a PowerShell refusal arrives as +// +// File C:\...\installerWindows123.ps1 cannot be loaded. The contents of file ... +// +// cut off exactly where the reason would be. Those reasons need opposite +// fixes -- a hash mismatch means the file was altered in transit, an +// untrusted publisher means the host was never going to accept it -- and +// neither is recoverable from the truncated form. This is the Windows +// counterpart of the journalctl capture EnableMCR does on Linux, and it +// exists for the same reason: the only description of what went wrong was +// being discarded. +// +// Best effort throughout. A failure collecting diagnostics must not replace +// the original error, so every probe's own error is ignored. +func (c WindowsConfigurer) installerDiagnostics(h Host, installer, output string) string { + var diag strings.Builder + + if trimmed := strings.TrimSpace(output); trimmed != "" { + diag.WriteString("\ninstaller output:\n") + diag.WriteString(trimmed) + } + + sig, sigErr := h.ExecOutput(ps.Cmd(fmt.Sprintf( + "$s = Get-AuthenticodeSignature %s; "+ + "Write-Output \"status=$($s.Status)\"; "+ + "Write-Output \"statusMessage=$($s.StatusMessage)\"; "+ + "Write-Output \"signer=$($s.SignerCertificate.Subject)\"", + ps.DoubleQuotePath(installer)))) + if sigErr == nil && strings.TrimSpace(sig) != "" { + diag.WriteString("\nscript signature:\n") + diag.WriteString(strings.TrimSpace(sig)) + } + + policy, policyErr := h.ExecOutput(ps.Cmd("Get-ExecutionPolicy -List | Out-String")) + if policyErr == nil && strings.TrimSpace(policy) != "" { + diag.WriteString("\nexecution policy:\n") + diag.WriteString(strings.TrimSpace(policy)) + } + + return diag.String() +} + // windowsMCRInstallCommand passes the repo URL and channel as installer // parameters, not `set` env vars, which a "cmd.exe /C" prefix loses (PRODENG-4062). func windowsMCRInstallCommand(installer, repoURL, channel string, allowUnsigned bool) string { @@ -169,7 +215,7 @@ func (c WindowsConfigurer) InstallMCR(h Host, engineConfig commonconfig.MCRConfi if isExitCode3010(err) { needsReboot = true } else { - return fmt.Errorf("failed to run MCR installer: %w", err) + return fmt.Errorf("failed to run MCR installer: %w%s", err, c.installerDiagnostics(h, installer, output)) } } diff --git a/test/smoke/smoke_test.go b/test/smoke/smoke_test.go index 0ad29591..e1f37886 100644 --- a/test/smoke/smoke_test.go +++ b/test/smoke/smoke_test.go @@ -109,6 +109,12 @@ func runSmokeTest(t *testing.T, cfg smokeConfig) { "mke_version": cfg.MKEVersion, "msr_version": cfg.MSRVersion, "mke_connect": mkeConnect, + // PRODENG-3924: a stock Windows host refuses the signed install + // script under -ExecutionPolicy AllSigned, so every Windows host + // fails at Install MCR before any launchpad behaviour is reached. + // The suites opt out until that is understood; the reason the host + // refuses is captured by installerDiagnostics in windows.go. + "mcr_install_url_windows_allow_unsigned": true, } if cfg.MCRRepoURL != "" { launchpad["mcr_repo_url"] = cfg.MCRRepoURL