Take the target version from the binary when there is no route out

preflight asked the GitHub release API which version it was upgrading to,
so a host with no internet failed there even with the target binary already
on disk - and `run` never passed its own --target-binary down to preflight,
so supplying one did not help. Read the version from the binary instead
when one is given, and fail if it is not the version the run targets.

Found by the first preflight against the production clone, which is
deliberately cut off from the network.
This commit is contained in:
2026-08-24 15:27:20 -07:00
parent 0739866c14
commit b786e89b42
4 changed files with 125 additions and 21 deletions
+13 -11
View File
@@ -24,6 +24,7 @@ func runPreflight(args []string) error {
adminPassword := fs.String("admin-password", os.Getenv("STALWART_MIGRATE_ADMIN_PASSWORD"),
"admin password for the reachability check (or set STALWART_MIGRATE_ADMIN_PASSWORD)")
targetVersion := fs.String("target", "latest", `target Stalwart version, or "latest"`)
targetBinary := fs.String("target-binary", "", "read the target version from this already-downloaded binary instead of the release API (for a host with no route to the internet)")
minFree := fs.Float64("min-free-multiple", 2.0, "required free disk space as a multiple of the data directory size")
stateDir := fs.String("state-dir", checkpoint.DefaultBaseDir, "directory to store run checkpoints in")
pythonPath := fs.String("python", "python3", "path to python3, needed by migrate_v016.py")
@@ -39,17 +40,18 @@ func runPreflight(args []string) error {
}
checker := preflight.New(preflight.Options{
BinaryPath: *binaryPath,
ConfigPath: *configPath,
DataDir: *dataDir,
ContainerName: *containerName,
AdminURL: *adminURL,
AdminUser: *adminUser,
AdminPassword: *adminPassword,
TargetVersion: *targetVersion,
MinFreeMultiple: *minFree,
CLIPath: *stalwartCLI,
PythonPath: *pythonPath,
BinaryPath: *binaryPath,
ConfigPath: *configPath,
DataDir: *dataDir,
ContainerName: *containerName,
AdminURL: *adminURL,
AdminUser: *adminUser,
AdminPassword: *adminPassword,
TargetVersion: *targetVersion,
TargetBinaryPath: *targetBinary,
MinFreeMultiple: *minFree,
CLIPath: *stalwartCLI,
PythonPath: *pythonPath,
})
report, err := checker.Run(context.Background(), store, rs)
+1 -1
View File
@@ -157,7 +157,7 @@ func runRun(args []string) (err error) {
pfReport, err := preflight.New(preflight.Options{
BinaryPath: *binaryPath, ConfigPath: *configPath, DataDir: *dataDir, ContainerName: *containerName,
AdminURL: *adminURL, AdminUser: *adminUser, AdminPassword: *adminPassword,
TargetVersion: *targetVersion, MinFreeMultiple: *minFree, HTTPClient: httpClient,
TargetVersion: *targetVersion, TargetBinaryPath: *targetBinary, MinFreeMultiple: *minFree, HTTPClient: httpClient,
CLIPath: *stalwartCLI, PythonPath: *pythonPath,
}).Run(ctx, store, rs)
fmt.Print(pfReport.String())