← Back to PureKit

Why an Aborted Offline Upgrade Still Printed 'Upgrade Successful'

#Python#Symlinks#Shell#Reliability
Why an Aborted Offline Upgrade Still Printed 'Upgrade Successful'

The Symptom

An offline cluster upgrade finished quickly and printed “Upgrade Successful”—yet several services failed to start afterward, with zero error messages in the upgrade log.

Three Traps Chained Together

Reproducing the exact step-by-step sequence uncovered three subtle bugs stacking on top of each other:

  1. Dangling symlink trap: The script checked if os.path.exists(link): os.remove(link) before calling os.symlink(target, link). In Python, os.path.exists() follows symlinks and returns False for a dangling symlink—so deletion was skipped and os.symlink() immediately raised FileExistsError.
  2. Uncaptured stderr: The logging setup never redirected stderr, so the unhandled Python traceback vanished into thin air instead of hitting the log file.
  3. Swallowed exit code: The outer shell wrapper did not check $? (and lacked set -e), happily printing "Upgrade Successful" right after the Python script crashed.

While auditing the same code path, I also found the exact same pattern silently dropping custom CORS allow-lists during upgrades.

The Fix

  • Replaced os.path.exists() with os.path.lexists() when testing whether a symlink path itself exists.
  • Wired stderr into the persistent logger and enforced strict non-zero exit-code propagation in all wrapper scripts.
  • Preserved and verified custom CORS configurations across upgrade boundaries.

Enjoyed this note or seen a similar bug?

Feel free to drop a line—always glad to exchange ideas with fellow engineers.

Say hi · [email protected]