Skip to content

feat: continuous re-registration reconciliation (#5)#24

Merged
as51340 merged 2 commits into
01-repo-reset-scaffoldfrom
05-continuous-re-registration
Jul 24, 2026
Merged

feat: continuous re-registration reconciliation (#5)#24
as51340 merged 2 commits into
01-repo-reset-scaffoldfrom
05-continuous-re-registration

Conversation

@as51340

@as51340 as51340 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What

Implements specs/operator-mvp/issues/05-continuous-re-registration.md: the operator's reason to exist over the chart's one-shot setup Job. Registration state a pod loses (rescheduled onto a fresh node, wiped storage) is now restored automatically.

The gap this closes

The registration planner already computed full-diff semantics (from #3). The missing piece was on the controller side: a converged reconcile returned ctrl.Result{} with no requeue. A registration lost on a still-running pod produces no watch event — its StatefulSet is unchanged — so the drift would never be detected. Reconciliation was effectively one-shot.

This adds a resyncInterval (30s) and requeues on it from the converged branch, so a converged cluster is continuously re-observed and drift is re-issued without human action. Leadership stays hands-off: the planner never emits a MAIN promotion when a MAIN already exists.

Changes

  • Controller (internal/controller/memgraphcluster_controller.go): periodic resync from the converged branch; docstring updated to describe continuous (not one-shot) reconciliation.

Tests

  • Planner (internal/planner/planner_test.go): multiple lost registrations re-issued without a second MAIN (adds the "multiple lost" case; single-lost, converged-no-op, and recovery-with-MAIN-present were already covered).
  • Controller envtest (internal/controller/memgraphcluster_controller_test.go): re-register a lost data instance leaving MAIN untouched; re-add a lost coordinator; no-op across repeated resyncs (each reschedules the resync). Updated the bootstrap spec's converged assertion to expect the resync requeue.
  • E2E (test/e2e/memgraphcluster_test.go): unregister a data instance on the coordinator leader, confirm it left the view, then assert the operator converges the cluster back to fully registered. Factored the converged-state check into a shared verifyClusterRegistered.

Acceptance criteria

  • A data instance whose registration is lost is automatically re-registered on a subsequent reconcile
  • A missing coordinator is automatically re-added
  • A converged cluster produces zero commands on reconcile (verified no-op)
  • No MAIN promotion is ever issued while a MAIN exists, including during recovery
  • Planner unit tests cover: single lost registration, multiple lost, converged no-op, recovery with MAIN present
  • E2E scenario: wipe one instance's registration state, assert the cluster converges back to fully registered

Verification

make test-unit, controller envtest (go test ./internal/controller/...), and make lint all green locally. E2E runs in CI against the licensed KinD cluster.

as51340 added 2 commits July 24, 2026 15:21
Extend registration reconciliation from one-shot bootstrap to continuous
drift recovery: a converged cluster now reschedules a periodic resync so a
registration a pod loses (rescheduled onto a fresh node, wiped storage) is
re-issued without human action. A lost registration on a still-running pod
produces no watch event, so this resync is the mechanism that detects drift.

The planner already computed full-diff semantics; the gap was the controller
returning no requeue once converged. Add a resyncInterval and requeue on it
from the converged branch.

Tests:
- planner: multiple lost registrations re-issued without a second MAIN
- controller envtest: re-register a lost data instance (MAIN untouched),
  re-add a lost coordinator, no-op across repeated resyncs
- e2e: wipe a data instance's registration on the leader, assert the operator
  converges the cluster back to fully registered
@as51340
as51340 merged commit 03065ba into 01-repo-reset-scaffold Jul 24, 2026
5 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.

1 participant