Why an Aborted Offline Upgrade Still Printed 'Upgrade Successful'
#Python#Symlinks#Shell#Reliability
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:
- Dangling symlink trap: The script checked
if os.path.exists(link): os.remove(link)before callingos.symlink(target, link). In Python,os.path.exists()follows symlinks and returnsFalsefor a dangling symlink—so deletion was skipped andos.symlink()immediately raisedFileExistsError. - Uncaptured stderr: The logging setup never redirected
stderr, so the unhandled Python traceback vanished into thin air instead of hitting the log file. - Swallowed exit code: The outer shell wrapper did not check
$?(and lackedset -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()withos.path.lexists()when testing whether a symlink path itself exists. - Wired
stderrinto 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.