Skip to content

feat(natscluster): block deletion while accounts are bound#290

Merged
henriropp merged 11 commits into
mainfrom
feat/block-natscluster-deletion
May 12, 2026
Merged

feat(natscluster): block deletion while accounts are bound#290
henriropp merged 11 commits into
mainfrom
feat/block-natscluster-deletion

Conversation

@henriropp
Copy link
Copy Markdown
Contributor

@henriropp henriropp commented May 8, 2026

Summary

Prevent NatsCluster deletion from completing while Account resources are still bound to that cluster. This protects cluster/account relationships from being orphaned and surfaces the blocked deletion state through controller status until the bindings are removed.

What changed

  • add a NatsCluster finalizer and deletion logic that checks for bound accounts by cluster UID before allowing removal
  • watch Account delete events from the NatsCluster controller so deletion is retried after bindings are removed
  • persist the bound cluster UID on Account resources via account.nauth.io/nats-cluster-id
  • reject rebinding an account to a different cluster UID once it has already been bound
  • update manager RBAC to allow natsclusters updates/finalizer updates and add Helm test coverage for those permissions
  • extend KUTTL coverage to verify account-to-cluster binding and add an e2e scenario that confirms NatsCluster deletion is blocked until the bound account is deleted
  • refactor account and nats cluster controller tests to setup state in given, without using the reconcile function that it is testing
  • refactor cluster target lookup to happen in controller, and pass down to manager.

How to validate

make lint
make test
make test-e2e

@henriropp henriropp changed the title Feat/block natscluster deletion feat(natscluster): block deletion while accounts are bound May 8, 2026
@henriropp henriropp marked this pull request as ready for review May 8, 2026 14:08
@henriropp henriropp requested a review from a team as a code owner May 8, 2026 14:08
@henriropp henriropp marked this pull request as draft May 8, 2026 14:09
@henriropp henriropp force-pushed the feat/block-natscluster-deletion branch 4 times, most recently from 669ccba to 44c637f Compare May 12, 2026 12:22
henriropp added 9 commits May 12, 2026 14:23
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
…econciler

Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
…accounts exist

Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
@henriropp henriropp force-pushed the feat/block-natscluster-deletion branch 2 times, most recently from 0e7da0a to 6f517b7 Compare May 12, 2026 12:25
@henriropp henriropp marked this pull request as ready for review May 12, 2026 12:28
@henriropp henriropp force-pushed the feat/block-natscluster-deletion branch from 6f517b7 to 5beb0fa Compare May 12, 2026 12:39
choufraise
choufraise previously approved these changes May 12, 2026
Copy link
Copy Markdown
Collaborator

@choufraise choufraise left a comment

Choose a reason for hiding this comment

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

👍 LGTM

Comment thread test/e2e/cluster-ref-test/02-assert.yaml
Comment thread internal/adapter/inbound/controller/natscluster_test.go
henriropp added 2 commits May 12, 2026 15:04
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
Signed-off-by: Henri Ropponen <henriropponen@gmail.com>
@henriropp henriropp force-pushed the feat/block-natscluster-deletion branch from 8f9fb29 to c0a603f Compare May 12, 2026 13:05
@henriropp henriropp merged commit c0a603f into main May 12, 2026
8 checks passed
@henriropp henriropp deleted the feat/block-natscluster-deletion branch May 12, 2026 13:11
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