Repository navigation
Conversation
execCreateDatabaseSchema ignored errors of execAlterSchemaDefaultPrivileges, and syncPreparedSchemas skipped schemas that already exist, so missing privileges were never retried. Return the errors and run the idempotent create/privilege statements for existing schemas, too. Fixes zalando#3230 Signed-off-by: João Rito <16895040+ritojoao@users.noreply.github.com>
ritojoao
requested review from
FxKu,
Jan-M,
hughcapet,
idanovinda,
jopadi and
mikkeloscar
as code owners
November 11, 2026 21:19
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, and thank you for maintaining the operator.
This is a small fix for #3230.
Problem:
execCreateDatabaseSchema()ignored errors fromexecAlterSchemaDefaultPrivileges(), andsyncPreparedSchemas()skipped schemas that already exist. If granting failed once (for example because a reader/writer role was missing), the sync reported no error and the privileges were never retried.Change:
execCreateDatabaseSchema().CREATE SCHEMA IF NOT EXISTSandALTER DEFAULT PRIVILEGESare idempotent, so missing privileges get fixed on the next sync.database/sqldriver covering the failure, the retry and the recovery.One trade-off: default privileges are re-applied on every sync. I am happy to change the approach if you prefer another one.
Testing (golang:1.26.4 container):
gofmt -lon the changed files: cleango generate ./...andgo vet ./pkg/cluster/: OKgo test ./pkg/cluster/ -run TestPreparedSchemaPrivilegeErrors -v: PASSgo test ./pkg/cluster/: OKdatabase.goandsync.goreverted to the base commit,TestPreparedSchemaPrivilegeErrorsfailsI did not run the e2e suite.
Fixes #3230