Skip to content

remove observedGeneration from postgresDatabase#1812

Draft
DmytroPI-dev wants to merge 2 commits intofeature/database-controllersfrom
check-observed-generation-usage-database-CR
Draft

remove observedGeneration from postgresDatabase#1812
DmytroPI-dev wants to merge 2 commits intofeature/database-controllersfrom
check-observed-generation-usage-database-CR

Conversation

@DmytroPI-dev
Copy link
Copy Markdown

@DmytroPI-dev DmytroPI-dev commented Apr 2, 2026

Description

This PR aligns PostgresDatabase with the watch-driven reconciliation approach used for PostgresCluster. It removes the reconcile skip based on ObservedGeneration, reacts to owned Secret/ConfigMap drift even when the spec is unchanged, repairs configmap drift declaratively, and degrades status instead of recreating previously provisioned managed secrets that were deleted.

Key Changes

  • postgresdatabase_controller.go add explicit drift-trigger predicates for owned Secret, ConfigMap, and relevant CNPG Database changes. Conflict retries are requeued without surfacing noisy reconcile errors.
  • database.go remove the ObservedGeneration short-circuit and revalidated stages on every reconcile. Add drift handling for managed user secrets, configmap repair/re-adoption, retained-resource adoption, conflict-friendly database reconcile handling, and quieter ready/not-found paths.
  • events.go Add events for drift and retained-resource adoption.
  • cluster.go reduced log noise on transient status-update conflicts.

Testing and Verification

  • Update controller tests in postgresdatabase_controller_test.go for:
    • configmap drift repair
    • deleted configmap recreation
    • deleted managed secret degradation without recreation
    • secret ownership re-adoption
    • adding a new database to an already provisioned resource
    • secondary-resource watch predicates
    • cluster-missing and role-conflict regressions
  • Add unit tests in database_unit_test.go for secret/configmap drift and adoption paths.
  • Verified behavior from controller logs/events during delete/recreate flows with both Delete and Retain policies.
  • Automated tests were updated. All tests passed

Related Issues

CPI-1950

PR Checklist

  • Code changes adhere to the project's coding standards.
  • Relevant unit and integration tests are included.
  • Documentation has been updated accordingly.
  • All tests pass locally.
  • The PR description follows the project's guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants