Skip to content

Log the result of a Grant and DefaultPrivilege reconcile, and name the failed resource in all reconcile error logs - #96

Merged
ThoSap merged 12 commits into
mainfrom
log-grant-and-defaultprivilege-reconcile-result
Oct 25, 2026
Merged

ThoSap merged 12 commits into
mainfrom
log-grant-and-defaultprivilege-reconcile-result

Conversation

@ThoSap

@ThoSap ThoSap commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Fixes #95

GrantReconciler and DefaultPrivilegeReconciler changed the phase without a log entry. The log showed only Reconciling Grant [...], so the operator log alone could not tell if a Grant or a DefaultPrivilege was READY or ERROR.

What changed

  1. ERROR without an exception is logged. The new BaseReconciler.setErrorPhase sets ERROR and the message, and logs a WARN with the same message: Failed to reconcile <kind> [resource=<namespace>/<name>, message=...]. The kind tells a Grant from a DefaultPrivilege with the same name, because the logger is BaseReconciler for both. The five ERROR branches in the two reconcilers use it.
  2. The result is logged. The reconcilers log Grant up-to-date or Updating Grant, and DefaultPrivilege up-to-date or Updating DefaultPrivilege, in the present tense like the other reconcilers. "Updating" means that at least one GRANT or REVOKE statement changes a privilege. The transaction commits after the log line. For this, GrantService.grantOnAll now returns true when it runs its statement. In "ALL" mode, the bulk grant counts as an update only if a non-owned object misses an expected privilege.
  3. The cleanup error log keeps the exception. Both cleanup methods pass e to log.error, the same as RoleReconciler and DatabaseReconciler.
  4. The "invalid privileges" message names the right resource. resource= now shows the namespace and the name of the Grant or DefaultPrivilege, not of the clusterRef. The two tests for this message now also check the resource= value.
  5. The exception log names the resource. BaseReconciler.handleError now logs Failed to reconcile <kind> [resource=<namespace>/<name>], not only the name. This changes the exception log of all reconcilers.
  6. A failed ClusterConnection check is logged once. ClusterConnectionReconciler logged the exception itself and then again in handleError. It now only uses handleError.
  7. The Grant list messages show a bullet before each object. The "objects do not exist" message and the "the role is the owner" message put the • bullet only between the objects, so the first object had none. The new tests errorWhenTableDoesNotExist and readyWhenRoleOwnsTable check both messages, with the bullet and the resource= value.

Checks that CI cannot do

  • The test output contains the new WARN, Updating … and … up-to-date lines, and the WARN lines name the reconciled resource.

A Grant in ALL mode on tables or sequences runs its bulk grant on each
reconcile, so it always logs "Updated Grant", never "Grant up-to-date".

Assisted-by: Claude:claude-opus-5-5
@ThoSap ThoSap self-assigned this Oct 25, 2026
@ThoSap ThoSap changed the title Log the result of a Grant and DefaultPrivilege reconcile Log the result of a Grant and DefaultPrivilege reconcile Oct 25, 2026
ThoSap added 10 commits October 25, 2026 16:45
Assisted-by: Claude:claude-opus-5-5
The other reconcilers log in the present tense, and the transaction
commits only after the log line.

Assisted-by: Claude:claude-opus-5-5
handleError already logs the exception with the kind, the namespace and
the name of the resource.

Assisted-by: Claude:claude-opus-5-5
Assisted-by: Claude:claude-opus-5-5
Assisted-by: Claude:claude-opus-5-5
@ThoSap ThoSap changed the title Log the result of a Grant and DefaultPrivilege reconcile Log the result of a Grant and DefaultPrivilege reconcile, and name the failed resource in all reconcile error logs Oct 25, 2026
@ThoSap
ThoSap merged commit d73700f into main Oct 25, 2026
4 checks passed
@ThoSap
ThoSap deleted the log-grant-and-defaultprivilege-reconcile-result branch October 25, 2026 16:24
@ThoSap ThoSap added the enhancement New feature or request label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log the result of a Grant and DefaultPrivilege reconcile

1 participant