Repository navigation
fix(controller,satellite): stop logging self-healing write conflicts at ERROR - #316
Conversation
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>
|
Warning Review limit reachedYou'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. View limit details
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. |
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>
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
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.
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
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.
| // 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
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).
Under normal volume churn the satellites and the controller log
Reconciler errorat ERROR for writes that controller-runtime retries and that always go through on the next pass:add finalizer,strip finalizer,add snapshot finalizerandstrip snapshot finalizeron the satellite, and Resource and ResourceDefinition updates on the controller, all failing withthe 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_totalit would otherwise only show as a risingcontroller_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 foundat 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 betweenlsblkand the probe failedwipefswith 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 splitsReconcile: keep #295'sReconcile(it sets the queue priority) and have it callr.conflicts.Reconcile(ctx, req, r.reconcileResource)instead of addingReconcilePass. In that file, inpkg/satellite/controllers/snapshot.goand ininternal/controller/resource_controller.gothe other side adds fields at the end of the reconciler struct where this PR addsconflicts, andsnapshot.goalso 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.wipefsfails with ENOENT.make lint-config && make lint: 0 issues.go test ./...with envtest assets: pass.-tags integration ./tests/integration/): pass exceptTestGroupFRToggleDiskful2DisklessReapsTieBreaker, which fails the same way onmainin a full run and passes when run on its own.go vetis clean, and thepkg/conflict,pkg/satellite/controllersandinternal/controllertests pass.Not tested