🐛(helm) show the database error while jobs wait for it to be ready - #2578
🐛(helm) show the database error while jobs wait for it to be ready#2578RISK-alt wants to merge 1 commit into
Conversation
The migrate and createsuperuser jobs polled `manage.py check` with its output sent to /dev/null, then printed "Database not ready" whatever the reason. Any failure the check reports, a missing setting or a bad credential for instance, looked like a database that had not started yet, and the job looped forever without a single clue in its logs. The check output is now captured and printed on each failed attempt, along with the attempt number, so the reason the job is still waiting is readable with kubectl logs. The retry behaviour is unchanged. Applied to both jobs in the chart values and in the dev and feature helmfile environments. The chart README table is regenerated accordingly. Signed-off-by: risk-alt <aldu6974@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
WalkthroughHelm migration and superuser initialization jobs now capture database check output, count retry attempts, and print diagnostic details while waiting for database readiness. The behavior is applied to production, development, and feature configurations. The backend Helm documentation and changelog now describe the updated retry reporting. Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Purpose
Fixes #1966
The migrate and createsuperuser jobs wait for the database like this:
Two problems, both of which the issue points at:
> /dev/null 2>&1throws away everything the check has to saymanage.py check --database defaultfails for far more than an unreachable database — a missing required setting, a bad credential, a brokenINSTALLED_APPSentry — and every one of those prints "Database not ready"So the job loops forever, at two seconds an iteration, and its logs contain nothing but a message that is usually wrong.
Proposal
until VAR=$(cmd)takes the exit status of the command substitution, so the loop condition is unchanged; it only gains a copy of the output. Nothing here is bashism:until,$(( ))and command substitution are all POSIX, and the backend image ispython:3.14.6-alpine, whose/bin/shis busybox ash.The issue notes the snippet is duplicated. It is, in six places, all updated:
src/helm/impress/values.yaml—backend.migrateandbackend.createsuperusersrc/helm/env.d/dev/values.impress.yaml.gotmpl— same two jobssrc/helm/env.d/feature/values.impress.yaml.gotmpl— same two jobsI did not try to factor the snippet into a single template helper: the four job definitions live in values files that are meant to be overridden by operators, and hiding the command behind a helper would take that away.
Testing
helmis not installed on my machine, so the chart rendering rests on thehelmfile-lintjob.What I did check locally:
values.yamlparses, and the command list round-trips to the three expected/bin/sh -c <script>elementsshagainst a stub check that fails twice with a two-line stderr then succeeds — both failures print with their attempt number and the full stderr, and the loop exits on successOne note on
src/helm/impress/README.md: the twobackend.*.commandrows are generated from the values, so the table had to be re-rendered, which re-pads every row of that section — hence the large but purely cosmetic diff there. I could not rungenerate-readme.sh(it needs Docker) nor the generator directly: version 3.0.1 stops on a pre-existing metadata mismatch in this chart, unrelated to this PR.So I reproduced the generator's output for those two cells by hand: same compact JSON serialization of the command list, same column padding as the rest of the table. Happy to fix that metadata in a separate PR if you want the generator runnable again.
External contributions
General requirements
CI requirements
helmfile lintis the relevant job and I cannot run it locallygit commit --signoff(DCO compliance)git commit -S)<gitmoji>(type) title description## [Unreleased]section (if noticeable change)AI requirements