Skip to content

fix(controller,satellite): stop logging self-healing write conflicts at ERROR - #316

Merged
Andrei Kvapil (kvaps) merged 11 commits into
mainfrom
fix/quiet-expected-conflicts
Nov 24, 2026
Merged

Andrei Kvapil (kvaps) merged 11 commits into
mainfrom
fix/quiet-expected-conflicts

Conversation

@kvaps

Copy link
Copy Markdown
Member

Under normal volume churn the satellites and the controller log Reconciler error at ERROR for writes that controller-runtime retries and that always go through on the next pass: add finalizer, strip finalizer, add snapshot finalizer and strip snapshot finalizer on the satellite, and Resource and ResourceDefinition updates on the controller, all failing with the object has been modified. On a three-node test cluster a couple of hours of volume tests left over a hundred such lines in the satellite logs alone. Operators alert on ERROR lines, and with this behaviour the alert fires on every batch of creates or deletes.

A 409 Conflict means another writer updated the object between our read and our write. The Resource, Snapshot and ResourceDefinition reconcilers now hand such a pass back to the queue through the same rate limiter an error goes through, log it at V(1), and return no error. Every other error is still returned and still logged at ERROR. The handling is one helper, conflict.Retrier, held by each reconciler, so it covers every write in a pass, including ones that arrive in other open PRs (the block-size freeze on the controller, for example), without touching each call site.

A conflict that keeps coming back is a different matter: two writers overwriting the same object forever is a bug, and with the error gone from the log and from controller_runtime_reconcile_errors_total it would otherwise only show as a rising controller_runtime_reconcile_total{result="requeue"}. The helper counts back-to-back conflicts per object and logs the tenth and every later one at the default level, so such a loop is visible in the satellite log too. Normal churn resolves within a retry or two and stays quiet.

The ResourceDefinition reconciler also logged ensure tiebreaker ... not found at ERROR right after a definition was deleted: the pass read the definition just before the delete and its first write found it gone. A step that fails with NotFound now re-reads the definition, and when it is gone or being deleted the pass ends at V(1). A NotFound for a definition that still exists stays an error.

The last ERROR source was IsDeviceFree probe: wipefs -n /dev/zdNNNN: ... No such file or directory. Device discovery dropped zvols only after running the four signature probes on them, so every scan probed every zvol for nothing, and a zvol destroyed between lsblk and the probe failed wipefs with ENOENT. The zvol filter now runs before the probes. This also removes four commands per zvol from every discovery scan.

The satellite logs through slog at INFO level, so its V(1) lines are not emitted at all; the controller shows them with --zap-log-level=debug.

Only the four reconcilers above go through the helper. The satellite StoragePool and PhysicalDevice reconcilers and the controller's auto-diskful and migration reconcilers still log a conflict at ERROR; none of them showed one on the test cluster, so they are left for a follow-up.

When merged onto the alpha.16 development branch, which carries #295 and other open PRs, three files conflict, all mechanically. In pkg/satellite/controllers/resource.go #295 also splits Reconcile: keep #295's Reconcile (it sets the queue priority) and have it call r.conflicts.Reconcile(ctx, req, r.reconcileResource) instead of adding ReconcilePass. In that file, in pkg/satellite/controllers/snapshot.go and in internal/controller/resource_controller.go the other side adds fields at the end of the reconciler struct where this PR adds conflicts, and snapshot.go also conflicts in the import block: keep both sides.

Testing

  • pkg/conflict: a wrapped conflict comes back as a requeue with no error and one V(1) line; a plain error and a NotFound come back unchanged; a clean pass keeps its own result; the tenth conflict in a row on one object is logged at the default level and the ninth is not; the run is counted per object and ends with any pass that did not conflict.
  • Satellite Resource and Snapshot reconcilers: a finalizer write that fails with Conflict is retried without an error; a write that fails otherwise is still returned.
  • Controller Resource reconciler: an update that fails with Conflict is retried without an error. The existing layer-stack race test now expects the lost race to be retried rather than returned.
  • ResourceDefinition reconciler: a pass whose first write finds the definition deleted ends without an error; a NotFound while the definition still exists is returned.
  • Device discovery: no signature probe runs against a zvol, including one whose wipefs fails with ENOENT.
  • Mutation checks: making the helper a no-op, never raising the level, raising it one conflict late, not resetting the run, counting all objects as one, bypassing it in each of the four reconcilers, dropping the NotFound branch, dropping its re-read of the definition, or moving the zvol filter back after the probes each fails a test.
  • make lint-config && make lint: 0 issues.
  • go test ./... with envtest assets: pass.
  • Integration tests (-tags integration ./tests/integration/): pass except TestGroupFRToggleDiskful2DisklessReapsTieBreaker, which fails the same way on main in a full run and passes when run on its own.
  • Merged onto the alpha.16 development branch with the resolution above: builds, go vet is clean, and the pkg/conflict, pkg/satellite/controllers and internal/controller tests pass.

Not tested

  • The log output on a running cluster: the change has not been deployed, so the drop in ERROR lines under volume churn is not measured yet.

A finalizer add or strip, or a controller write to a Resource or a
definition, fails with 409 Conflict whenever another writer updated
the object since the pass read it. The next pass re-reads and goes
through, so nothing is wrong, but the reconcilers returned the
conflict and controller-runtime logged each one as "Reconciler error"
at ERROR. Volume churn produced dozens of them an hour, so an alert
on ERROR lines fired on every batch of creates and deletes.

The Resource, Snapshot and ResourceDefinition reconcilers now turn a
conflict into a requeue through the same rate limiter an error would
use and log it at V(1). Every other error is returned as before.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A pass that read a definition just before it was deleted fails its
first write with NotFound. The tiebreaker step logged that at ERROR
and returned it, although a deleted definition has nothing left to
do: the retried pass finds it gone and stops. Such a pass now re-reads
the definition and, when it is gone or being deleted, ends quietly at
V(1). A NotFound for a definition that still exists stays an error.
The steps also stop logging a conflict at ERROR before handing it to
the retry.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Device discovery dropped zvols only after running the four signature
probes on them, so every scan ran pvs, zpool, drbdmeta and wipefs
against each zvol for nothing. A zvol destroyed between lsblk and the
probe made wipefs fail with ENOENT, logged at ERROR as an
"IsDeviceFree probe" failure on every volume delete. The zvol filter
now runs before the probes.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Retrying conflicts quietly also hid the one conflict pattern that is
a bug: two writers overwriting the same object forever. The error is
gone from the log and from the reconcile-error metric, and the
satellite never prints V(1), so such a loop would only show as a
rising requeue count.

Count back-to-back conflicts per object and log the tenth and later
ones at the default level. Normal churn resolves within a retry or
two and stays quiet. Also say why the retry keeps the deprecated
Requeue, so it is not "fixed" into RequeueAfter, which drops the
per-object backoff.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 09903f2d-2104-401e-8327-e18ca2786be3
Commits

Reviewing files that changed from the base of the PR and between 3f511fe and fc4de4c.

Files selected for processing: 25

  • internal/controller/auto_diskful_controller.go
  • internal/controller/conflict_requeue_all_test.go
  • internal/controller/conflict_requeue_test.go
  • internal/controller/node_controller.go
  • internal/controller/node_heartbeat_controller.go
  • internal/controller/node_label_sync_controller.go
  • internal/controller/resource_controller.go
  • internal/controller/resource_migration_controller.go
  • internal/controller/resource_state_projection_controller.go
  • internal/controller/resourcedefinition_controller.go
  • internal/controller/resourcedefinition_layer_stack_test.go
  • internal/controller/resourcedefinition_step.go
  • internal/controller/resourcegroup_controller.go
  • internal/controller/rg_rebalance_controller.go
  • internal/controller/snapshot_controller.go
  • pkg/conflict/conflict.go
  • pkg/conflict/conflict_test.go
  • pkg/satellite/controllers/conflict_requeue_test.go
  • pkg/satellite/controllers/physicaldevice.go
  • pkg/satellite/controllers/physicaldevice_discovery.go
  • pkg/satellite/controllers/physicaldevice_discovery_test.go
  • pkg/satellite/controllers/resource.go
  • pkg/satellite/controllers/resource_retry_priority_test.go
  • pkg/satellite/controllers/snapshot.go
  • pkg/satellite/controllers/storagepool.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

The Resource, Snapshot and ResourceDefinition reconcilers already hand
a pass that failed with 409 Conflict back to the queue and log it at
V(1). The other reconcilers still returned the conflict, so
controller-runtime logged it as "Reconciler error" at ERROR: the
satellite StoragePool and PhysicalDevice finalizer writes, and the
controller's migration, snapshot, node, node heartbeat, node label
sync, state projection, auto-diskful, resource group and rebalance
passes. Each of them writes objects other writers touch too, so an
alert on ERROR lines could still fire on normal churn.

They now go through the same conflict.Retrier. Every other error is
returned as before. The two reconcilers that write nothing, the
controller StoragePool and satellite ResourceDefinition ones, are left
alone.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right to me. apierrors.IsConflict unwraps through the cockroachdb wraps, and it matches only reason Conflict, so an AlreadyExists 409 is still returned as an error. A conflicted pass goes back through the same rate limiter it did before, so retry timing is unchanged and only the log level and the error metric move. The streak resets on the next clean pass, so it does not grow for deleted objects. Moving the zvol filter ahead of the probes changes nothing about what gets published, because publishDeviceWithReason has no other caller.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit applies the same Retrier wrapper to the remaining reconcilers that write, and it looks right to me. The rebalance pass loses its RequeueAfter only on a conflicted pass and gets it back on the next clean one. The PR now conflicts with main, though. The struct conflict in internal/controller/resource_controller.go is just adjacent fields, but the one in the satellite Reconcile is not. Details inline.

Comment thread pkg/satellite/controllers/resource.go Outdated
// optimistic-concurrency race instead of reporting it as an error;
// see conflict.Retrier.
func (r *ResourceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
return r.conflicts.Reconcile(ctx, req, r.ReconcilePass) //nolint:wrapcheck // the pass's own error, already wrapped

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main has since turned this Reconcile into a wrapper that sets normalPriority() on every result that has no priority, with the body moved to reconcileResource. The merge has to pick an order. If the Retrier wraps the priority wrapper, its Result{Requeue: true} has no priority set, so a replica that lost a race is retried at the priority it was dequeued with. For an idle re-check that is the low priority main is trying to avoid. With the priority wrapper outside, the retry runs at normal priority. Could you merge main and pick one of the two? I'd go with priority outside.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, priority outside. Main is merged (8eb1fb3, and again in cee86af) and Reconcile now runs r.conflicts.Reconcile(ctx, req, r.reconcileResource) first and fills in normalPriority() on whatever comes back, so a replica that lost a race is retried at normal priority. fc4de4c adds a conflict case to TestRetriesRunAtNormalPriority; with the Retrier outside it fails with retry priority = <nil>.

The internal/controller/resource_controller.go conflict was the adjacent fields only; both are kept.

…nflicts

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

# Conflicts:
#	internal/controller/resource_controller.go
#	internal/controller/resourcegroup_controller.go
#	pkg/satellite/controllers/resource.go
Each satellite of a snapshot stamps its own entry in the same status
during a take, and the stamps retry a conflict only a few times. When
the budget ran out they returned a new error that no longer said it
was a conflict, so the Retrier passed it on and controller-runtime
logged "Reconciler error" at ERROR for a race the next pass wins. The
exhausted loops now return the last conflict as the cause.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
A failed snapshot delete is recorded in the status before the pass is
retried, and that stamp races the other nodes' stamps of the same
status. Its error is logged rather than returned, so the Retrier never
sees it and the conflict went to the log at ERROR anyway. A conflict
there is now logged at V(1); any other stamp failure stays at ERROR.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
…nflicts

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

# Conflicts:
#	pkg/satellite/controllers/snapshot.go
A pass that lost a write race is retried with the Retrier's own
Result, which names no priority. With the Retrier outside the priority
wrapper, controller-runtime would retry the replica at the priority it
was dequeued with, which for an idle re-check is low. The merge with
main kept the priority wrapper outside; this case keeps it there.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The order is right now: Reconcile runs the Retrier first and then fills in normal priority, so a pass that lost a race is retried at normal priority, and the new "conflict" case in TestRetriesRunAtNormalPriority pins that. The snapshot stamps that ran out of retries now return the last conflict, so the Retrier sees them. With snapshotStatusUpdateRetries at 5, lastConflict is never nil after the loop. LogFailure keeps a lost delete-failure stamp at V(1).

@kvaps
Andrei Kvapil (kvaps) merged commit 1f1d2a0 into main Nov 24, 2026
16 checks passed
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