Skip to content

Keep the current owner of a Database or Schema without owner in the spec - #93

Merged
ThoSap merged 1 commit into
mainfrom
fix-reconcile-without-owner
Oct 25, 2026
Merged

ThoSap merged 1 commit into
mainfrom
fix-reconcile-without-owner

Conversation

@ThoSap

@ThoSap ThoSap commented Oct 25, 2026

Copy link
Copy Markdown
Member

Fixes #90

A Database or Schema without spec.owner went to ERROR on each reconcile after the first one:

SQL [alter database "my-database" owner to ""]; ERROR: zero-length delimited identifier at or near """"

The reconcile compared the current owner, for example the admin user, with null. Objects.equals is null-safe, but it returns true only when both values are null. The current owner is never null, so the reconciler always ran alter … owner to with role(null), which renders as "". This happened at each spec change, at each resync and at each restart of the operator.

What changed

  1. No owner in the spec means "keep the current owner". DatabaseReconciler and SchemaReconciler treat the owner as up to date when spec.owner is null. This agrees with the create path, which also skips the owner when it is null.
  2. Docs. The owner field in DatabaseSpec, SchemaSpec, docs/database.md and docs/schema.md now says that the resource keeps its current owner when owner is not set or is removed.
  3. Tests. New tests reconcile a Database and a Schema without an owner a second time, and expect READY and the same owner as before. The Database and Schema tests from Set the status to READY when a Database, Schema or Role is already up to date #91 no longer set an explicit owner to avoid this bug.

Consequences

  • If owner is removed from a resource, the operator does not change the owner back to the admin user. To change the owner, set owner to the new role.

Checks that CI cannot do

…e spec

Before, the reconcile compared the current owner with null and ran
"alter ... owner to """, which PostgreSQL rejects.

Assisted-by: Claude:claude-opus-5-5
@ThoSap ThoSap self-assigned this Oct 25, 2026
@ThoSap
ThoSap merged commit c59f95d into main Oct 25, 2026
4 checks passed
@ThoSap
ThoSap deleted the fix-reconcile-without-owner branch October 25, 2026 14:53
@ThoSap ThoSap added bug Something isn't working documentation Improvements or additions to documentation labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Database and Schema without an owner go to ERROR on the second reconcile

1 participant