fix(update): write the agent version sidecar with a real newline
printf '%s\\n' emitted the literal characters backslash-n, which archie-update-check's release-version check rejects, so every managed-agent update left the installed agent version reported as unknown.
This commit is contained in:
1 parent
b1ec7f3ded
commit
18bbd699c1
2 files changed
+22
-1
No files matched your search
@@ -830,3 +830,24 @@ func TestUpdateInstallRefusesWhenTaskDatabaseCannotBeBackedUp(t *testing.T) {
|
||||
}
|
||||
assertCallAbsent(t, calls, "arhied.prev")
|
||||
}
|
||||
|
||||
// The sidecar is the only record of the managed agent version, and
|
||||
// archie-update-check refuses anything but a bare release version, so a stray
|
||||
// escape in the write leaves the installed agent reported as unknown forever.
|
||||
func TestUpdateInstallWritesABareAgentVersionSidecar(t *testing.T) {
|
||||
versionFile := filepath.Join(t.TempDir(), "archie-agent.version")
|
||||
runUpdateInstallScript(t, map[string]string{
|
||||
"ARCHIE_UPDATE_DAEMON_PREVIOUS": "1.13.0",
|
||||
"ARCHIE_UPDATE_AGENT_PREVIOUS": "1.9.9",
|
||||
"ARCHIE_UPDATE_AGENT_VERSION": "1.10.0",
|
||||
"ARCHIE_AGENT_VERSION_FILE": versionFile,
|
||||
})
|
||||
|
||||
recorded, err := os.ReadFile(versionFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(recorded) != "1.10.0\n" {
|
||||
t.Fatalf("sidecar = %q, want %q", recorded, "1.10.0\n")
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ if [[ ",$components," == *,agent,* ]]; then
|
||||
# Only record a version after the image build succeeds. Write beside the
|
||||
# state atomically so the check never observes a partial version.
|
||||
version_tmp="$(mktemp "$AGENT_VERSION_FILE.tmp.XXXXXX")"
|
||||
printf '%s\\n' "$RT" > "$version_tmp"
|
||||
printf '%s\n' "$RT" > "$version_tmp"
|
||||
chmod 600 "$version_tmp"
|
||||
mv -f "$version_tmp" "$AGENT_VERSION_FILE"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user