Skip to content

Prevent Account deletion from targeting a different NatsCluster #369

Description

@choufraise

Problem

Account reconciliation rejects changes to spec.natsClusterRef when the Account is already bound to another NatsCluster.

The deletion path bypasses that binding check. It resolves the current cluster reference and can execute AccountManager.Delete against a different cluster than the one stored in account.nauth.io/nats-cluster-id.

This can leave the original NATS account orphaned or delete an account with the same ID from the wrong cluster.

Proposed change

Validate the Account’s persisted NATS cluster binding before any deletion-side NATS operation.

If the resolved NatsCluster UID differs from account.nauth.io/nats-cluster-id:

  • Do not call FindAccountID, JetStream lookup, or DeleteAccount.
  • Keep the Account finalizer.
  • Report a clear reconciliation error.

Acceptance criteria

  • Deletion of an Account with a matching cluster UID behaves unchanged.
  • Deletion with a changed or mismatched NatsClusterRef is blocked.
  • A controller regression test verifies that AccountManager.Delete is not called on mismatch.
  • The existing normal-reconciliation rebinding behavior remains unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstype: bugSomething existing is not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions