Use pg_isready health checks for PostgreSQL#129
Conversation
Add startup, liveness, and readiness probes to the lightspeed-postgres-server container using pg_isready. Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/controller/postgres_deployment.go (1)
201-214: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPositional int32 params are a footgun for future edits.
buildPostgresProbe(period, timeout, failure, initialDelay int32)uses an argument order that doesn't matchcorev1.Probe's field order, and since all four params share the same type, a future call-site swap (e.g.timeout/period) will compile silently and misconfigure probe timing without any error.♻️ Suggested refactor using named fields
-func buildPostgresProbe(period, timeout, failure, initialDelay int32) *corev1.Probe { +type postgresProbeConfig struct { + Period int32 + Timeout int32 + Failure int32 + InitialDelay int32 +} + +func buildPostgresProbe(cfg postgresProbeConfig) *corev1.Probe { return &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ Exec: &corev1.ExecAction{ Command: []string{"pg_isready", "-U", PostgresDefaultUser, "-d", PostgresDefaultDbName}, }, }, - InitialDelaySeconds: initialDelay, - PeriodSeconds: period, - TimeoutSeconds: timeout, - FailureThreshold: failure, + InitialDelaySeconds: cfg.InitialDelay, + PeriodSeconds: cfg.Period, + TimeoutSeconds: cfg.Timeout, + FailureThreshold: cfg.Failure, } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/controller/postgres_deployment.go` around lines 201 - 214, Refactor buildPostgresProbe to avoid the positional int32 footgun by using clearly named inputs or a small config struct instead of relying on the current period/timeout/failure/initialDelay parameter order. Update the probe construction in buildPostgresProbe so the values map explicitly to InitialDelaySeconds, PeriodSeconds, TimeoutSeconds, and FailureThreshold, making future call-site changes safe and readable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/controller/postgres_deployment.go`:
- Around line 201-214: Refactor buildPostgresProbe to avoid the positional int32
footgun by using clearly named inputs or a small config struct instead of
relying on the current period/timeout/failure/initialDelay parameter order.
Update the probe construction in buildPostgresProbe so the values map explicitly
to InitialDelaySeconds, PeriodSeconds, TimeoutSeconds, and FailureThreshold,
making future call-site changes safe and readable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 141b9d37-cf5d-43ea-9353-81966e03777d
📒 Files selected for processing (2)
internal/controller/constants.gointernal/controller/postgres_deployment.go
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lpiwowar, umago The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
06cef90
into
openstack-lightspeed:lcore-migration
Add startup, liveness, and readiness probes to the lightspeed-postgres-server container using pg_isready.
Summary by CodeRabbit
pg_isready, improving pod startup and availability detection.