fix(build): stamp gatewayVersion/runtimeVersion in the right package
-X main.gatewayVersion/main.runtimeVersion targeted package main, but those vars live in internal/app/archied (cmd/archied is a thin wrapper). An -X target that doesn't exist is silently ignored by the linker, so every archied binary this shipped -- task build, install.sh, Dockerfile.archied, and the carina self-update script -- reported "dev" instead of its real version. Point every one of those ldflags at the actual package. Also, while chasing the carina incident this surfaced: - restart.go: /restart didn't check for an in-flight /update install. The install runs as archied's own child process, so a restart killed it mid-build (observed: "signal: terminated") instead of letting it finish or fail cleanly. Refuse the restart while updateInProgress. - update.go / update_report.go: the "no version could be confirmed running" branch still opened with "Update complete", contradicting its own next clause. Reworded so an unverified outcome isn't reported as completion.
This commit is contained in:
1 parent
bd5d4b9b13
commit
1425050506
8 files changed
+59
-35
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ COPY . .
|
||||
ARG GATEWAY_VERSION=dev
|
||||
ARG RUNTIME_VERSION=dev
|
||||
RUN CGO_ENABLED=0 go build \
|
||||
-ldflags "-X main.gatewayVersion=${GATEWAY_VERSION} -X main.runtimeVersion=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=container" \
|
||||
-ldflags "-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion=${GATEWAY_VERSION} -X github.com/samcharles93/archie-core/internal/app/archied.runtimeVersion=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=container" \
|
||||
-o /usr/local/bin/archied ./cmd/archied/
|
||||
# archied is static, but this can't be scratch: in inprocess mode the daemon
|
||||
# runs agent tools itself, and the shell tool invokes bash; codesearch shells
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ tasks:
|
||||
- "{{.BIN_DIR}}/archied"
|
||||
- "{{.BIN_DIR}}/archie-agent"
|
||||
cmds:
|
||||
- go build -ldflags "-X main.gatewayVersion={{.GATEWAY_VERSION}} -X main.runtimeVersion={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archied ./cmd/archied
|
||||
- go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion={{.GATEWAY_VERSION}} -X github.com/samcharles93/archie-core/internal/app/archied.runtimeVersion={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archied ./cmd/archied
|
||||
- go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-agent ./cmd/archie-agent
|
||||
|
||||
test:
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ echo "==> Building native archied..."
|
||||
# even the right kind of update for a script-built native binary.
|
||||
GATEWAY_VERSION="$(git describe --tags --match 'archied/v*' 2>/dev/null | sed 's|^archied/v||' || echo dev)"
|
||||
RUNTIME_VERSION="$(git describe --tags --match 'archie/v*' 2>/dev/null | sed 's|^archie/v||' || echo dev)"
|
||||
go build -ldflags "-X main.gatewayVersion=${GATEWAY_VERSION} -X main.runtimeVersion=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o "${ARCHIE_BIN_DIR}/archied" ./cmd/archied
|
||||
go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion=${GATEWAY_VERSION} -X github.com/samcharles93/archie-core/internal/app/archied.runtimeVersion=${RUNTIME_VERSION} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o "${ARCHIE_BIN_DIR}/archied" ./cmd/archied
|
||||
install -m755 "${SRC_DIR}/scripts/archie-update-install" "${ARCHIE_BIN_DIR}/archie-update-install"
|
||||
)
|
||||
echo " Installed archied and updater to ${ARCHIE_BIN_DIR}/"
|
||||
|
||||
@@ -28,6 +28,19 @@ func (g *Gateway) restartHandler() bot.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
// Restarting tears down this process, and the update installer runs
|
||||
// as its child -- a restart mid-install kills the install outright
|
||||
// (signal: terminated) rather than letting it finish or fail
|
||||
// cleanly, leaving the daemon on its old binary with no clear error
|
||||
// surfaced to the operator.
|
||||
g.updateMu.Lock()
|
||||
updating := g.updateInProgress
|
||||
g.updateMu.Unlock()
|
||||
if updating {
|
||||
g.sendMessage(ctx, b, msg.Chat.ID, msg.MessageThreadID, "⚠️ An update is currently installing -- restarting now would kill it mid-install. Wait for it to finish, then try again.")
|
||||
return
|
||||
}
|
||||
|
||||
// Acknowledge on the current instance: it is about to be torn
|
||||
// down, and the relaunched one confirms completion.
|
||||
g.sendMessage(ctx, b, msg.Chat.ID, msg.MessageThreadID, "🔄 Reloading Archie…")
|
||||
|
||||
@@ -288,35 +288,7 @@ func formatVersionChanges(result releaseupdate.Result) string {
|
||||
// evidence that the install took effect.
|
||||
func formatPendingReport(report releaseupdate.Report, running map[string]string) string {
|
||||
if !report.RolledBack && report.HealthCheck == "passed" {
|
||||
verification := report.Verify(running)
|
||||
if len(verification.Drift) > 0 {
|
||||
return formatVersionDrift(verification.Drift)
|
||||
}
|
||||
changes := formatVersionChanges(releaseupdate.Result{Previous: report.Previous, Installed: report.Installed})
|
||||
text := "Update complete"
|
||||
if changes != "" {
|
||||
text += ": " + changes
|
||||
}
|
||||
if len(verification.Confirmed) == 0 {
|
||||
// Nothing self-reported a version we could check the claim
|
||||
// against, so a passed health probe is all we have -- and it
|
||||
// only ever proved that *something* answered. Saying "healthy
|
||||
// on the new version" here would assert the exact thing that
|
||||
// went unverified in the incident this check was added for.
|
||||
return text + ". Health check passed, but I could not confirm which version is actually running."
|
||||
}
|
||||
text += ". Health check passed — archie-core is healthy on the new version."
|
||||
if len(verification.Unverified) > 0 {
|
||||
// Something WAS confirmed, so the headline is earned -- but the
|
||||
// version change printed above covers every component the
|
||||
// installer claimed, including ones nothing checked. Naming them
|
||||
// keeps the confirmed part from silently vouching for the rest.
|
||||
// This is the ordinary case, not an edge one: only the daemon
|
||||
// can self-report today, so the agent lands here on every
|
||||
// successful update.
|
||||
text += " Not independently checked: " + strings.Join(verification.Unverified, ", ") + "."
|
||||
}
|
||||
return text
|
||||
return formatHealthyReport(report, report.Verify(running))
|
||||
}
|
||||
|
||||
ids := make([]string, 0, len(report.Previous))
|
||||
@@ -336,6 +308,45 @@ func formatPendingReport(report releaseupdate.Report, running map[string]string)
|
||||
return fmt.Sprintf("Update failed health check after restarting and could NOT be rolled back automatically (no backup was found). archie-core may still be running the broken version, or may not be running at all — manual intervention is required. Previous version was %s.", previousVersions)
|
||||
}
|
||||
|
||||
// formatHealthyReport words the report once RolledBack is false and the
|
||||
// health check passed -- the branch where a passed probe alone is tempting
|
||||
// to read as "the update worked," which is exactly the false-confidence
|
||||
// this whole verification path exists to prevent.
|
||||
func formatHealthyReport(report releaseupdate.Report, verification releaseupdate.Verification) string {
|
||||
if len(verification.Drift) > 0 {
|
||||
return formatVersionDrift(verification.Drift)
|
||||
}
|
||||
changes := formatVersionChanges(releaseupdate.Result{Previous: report.Previous, Installed: report.Installed})
|
||||
if len(verification.Confirmed) == 0 {
|
||||
// Nothing self-reported a version we could check the claim against,
|
||||
// so a passed health probe is all we have -- and it only ever
|
||||
// proved that *something* answered. Calling this "Update complete"
|
||||
// would assert the exact thing that went unverified in the incident
|
||||
// this check was added for.
|
||||
text := "Update install finished"
|
||||
if changes != "" {
|
||||
text += " (" + changes + ")"
|
||||
}
|
||||
return text + ", health check passed, but I could not confirm which version is actually running. Treat this as UNCONFIRMED, not complete."
|
||||
}
|
||||
text := "Update complete"
|
||||
if changes != "" {
|
||||
text += ": " + changes
|
||||
}
|
||||
text += ". Health check passed — archie-core is healthy on the new version."
|
||||
if len(verification.Unverified) > 0 {
|
||||
// Something WAS confirmed, so the headline is earned -- but the
|
||||
// version change printed above covers every component the
|
||||
// installer claimed, including ones nothing checked. Naming them
|
||||
// keeps the confirmed part from silently vouching for the rest.
|
||||
// This is the ordinary case, not an edge one: only the daemon can
|
||||
// self-report today, so the agent lands here on every successful
|
||||
// update.
|
||||
text += " Not independently checked: " + strings.Join(verification.Unverified, ", ") + "."
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
// formatVersionDrift words the case where the installer reported success and
|
||||
// the health check passed, but a component reports it is running something
|
||||
// other than what was installed.
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestUpdateInstallGatewayOnlySkipsRuntimeWork(t *testing.T) {
|
||||
assertCallAbsent(t, calls, "git pull")
|
||||
assertCallContains(t, calls, "git -C", "rev-parse --verify refs/tags/archied/v1.13.0^{commit}")
|
||||
assertCallContains(t, calls, "checkout --quiet --detach approved-release-commit")
|
||||
assertCallContains(t, calls, "go build", "main.runtimeVersion=1.9.9", "./cmd/archied")
|
||||
assertCallContains(t, calls, "go build", "internal/app/archied.runtimeVersion=1.9.9", "./cmd/archied")
|
||||
assertCallAbsent(t, calls, "./cmd/archie-agent")
|
||||
assertCallAbsent(t, calls, "docker compose build agent")
|
||||
if got := result.Installed[ComponentDaemon]; got != "1.13.0" {
|
||||
|
||||
@@ -109,7 +109,7 @@ func summarizeUpdateReport(report releaseupdate.Report, verification releaseupda
|
||||
return "Update did NOT take effect: " + strings.Join(ids, "; ") + "."
|
||||
}
|
||||
if len(verification.Confirmed) == 0 {
|
||||
return "Update complete. Health check passed, but no version could be confirmed running."
|
||||
return "Update installed and health check passed, but no running version could be verified -- treat this as UNCONFIRMED, not complete."
|
||||
}
|
||||
text := "Update complete. Health check passed -- confirmed running on the new version (" + strings.Join(verification.Confirmed, ", ") + ")."
|
||||
if len(verification.Unverified) > 0 {
|
||||
|
||||
@@ -126,7 +126,7 @@ install -m755 "$source_dir/scripts/archie-update-check" "$BIN_DIR/archie-update-
|
||||
|
||||
if [[ ",$components," == *,daemon,* ]]; then
|
||||
echo "==> building archied $GW"
|
||||
go build -ldflags "-X main.gatewayVersion=$GW -X main.runtimeVersion=$RT -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" \
|
||||
go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion=$GW -X github.com/samcharles93/archie-core/internal/app/archied.runtimeVersion=$RT -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" \
|
||||
-o "$tmp/archied" ./cmd/archied
|
||||
fi
|
||||
if [[ ",$components," == *,daemon,* ]]; then
|
||||
|
||||
Reference in new issue
Block a user