Repository navigation
fix(pg_upgrade_scripts): mpg-1579 fix ship logs - #2739
Merged
Merged
Conversation
…re the ANON key it holds is up-to-date
Package version diffCompares built package versions in legacyPackages between this PR and the tip of the base branch, per system. aarch64-linux: Closure size: 372 -> 372 (2 paths added, 2 paths removed, delta +0, disk usage +7.7KiB).x86_64-linux: Closure size: 370 -> 370 (2 paths added, 2 paths removed, delta +0, disk usage +7.7KiB). |
valigula
reviewed
Nov 26, 2026
valigula
left a comment
Contributor
There was a problem hiding this comment.
Automated review findings (unverified; please sanity-check before acting).
tkren
approved these changes
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Use the ANON key generated on the new box (TARGET) of an upgrade on the SOURCE box, so we're 100% sure the anonymous key is up-to-date when it come to ship logs on error, upon an upgrade.
Handles
pg_upgradeoutputs fully, and ship thems to the reporting project. Only ship the log files of the latest attempt, placing older logs into another folder in/var/log.Added usage of
lsofandfuserin theprepare.shif they are present: they will be used to detect what's going on when we can'tumount /data. AMIs don't ship them actually, but they might in the future. The previous listing is of course still there (user, pid and command actually on/data/)What is the current behavior?
If the SOURCE box is "old enough", there are chances that this anonymous key isn't valid anymore. As a consequence, when a log needs to be shipped because the upgrade process is failing on the TARGET box (curl / post on the error_logs project), it is not shipped. This is mostly annoying when it's the
initiate.shscript that fails, because it is runs on the TARGET box, and if the upgrade fails, everything falls back onto the previous version of project in the SOURCE box, hence, the log from theinitiate.shscript is lost, because the TARGET is destroyed at the very end of this "rollback" process.pg_upgrade logs aren't logged and then, not shipped. This is annoying to debug failed pg_upgrade attempts: an SSH on the box is then mandatory.
We only list which user/pid is on
/data/as current working directory, but an user/process could actually write on it or use a file in there preventing theumount.What is the new behavior?
To ensure that in such case the log is shipped properly, with a freshly created ANON Key of the error_logs project, we simply pass over that key in the
prepare.shpart of the upgrade, directly copying it to the/data/that will be later mounted on the SOURCE. This is the same mechanism we do already for the pgsodium key. This way, if (only) an anonymous key exists, then, we backup it (.bkp extension locally) and put in place that fresh anonymous key instead. Also, in the beginning of theinitiate.shscript we do the same we already did in theprepare.sh, i.e hardening a bit the creation of the LOG_FILE, don't append to it anymore (previous attempts from the past where already logged anyways).We ship every log output of
pg_upgradeand eventually the.txtgenerated on special checks (see PostgreSQL's source atpg_upgrade/check.c). If previous attemps are detected, we don't add those in the same directory, to not ship everything. Instead we move the previous attempts in a /previous/ post-fixed directory name in/var/log.lsofandfuserwill be used if they are present on the system. This is to enable better logs in the future when those binaries might be present. If they aren't, they aren't used, and the list of user+pid currently in/dataas their working directory is still listed and logged.