Skip to content

feat: in-memory join membership reverter#2309

Closed
louiseschmidtgen wants to merge 6 commits into
mainfrom
KU-4853/join-revert
Closed

feat: in-memory join membership reverter#2309
louiseschmidtgen wants to merge 6 commits into
mainfrom
KU-4853/join-revert

Conversation

@louiseschmidtgen

@louiseschmidtgen louiseschmidtgen commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds an in memory reverter for membership state.

If a node fails anywhere in the process membership get's reverted based on where we failed in the join process:

  • any failure of the join logic triggers the microcluster's remove logic
  • etcd membership
  • Kubernetes membership

Limitation:

Clean-up of etcd is only desirable if we have less than 3 nodes in the cluster. If we were to remove 1 etcd node from a 2 node configuration we would loose quorum. Admins will need to manually need to clean-up the broken configuration.

Manual Testing

Inserted a fake error for the third joining node (see testing commit). After the third node artificially fails to join, I verified the memberships of microcluster, etcd, k8s to ensure the reverter works as expected.

Backport

1.32, 1.33, 1.34, 1.35

Checklist

  • PR title formatted as type: title
  • Covered by unit tests
  • Covered by integration tests
  • Documentation updated
  • CLA signed
  • Backport label added if necessary

Copilot AI review requested due to automatic review settings January 20, 2026 08:01

Copilot AI left a comment

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.

Pull request overview

This PR adds an in-memory reverter mechanism to automatically clean up membership state if a node fails during the join process. The reverter ensures that failed join attempts don't leave orphaned entries in etcd or Kubernetes by registering cleanup functions that execute on join failure.

Changes:

  • Introduces a reverter using the github.com/canonical/lxd/shared/revert package to manage cleanup on join failure
  • Adds etcd membership cleanup for nodes joining with etcd datastore
  • Adds Kubernetes Node object cleanup for nodes that fail after kubelet registration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/k8s/pkg/k8sd/app/hooks_join.go
Comment thread src/k8s/pkg/k8sd/app/hooks_join.go Outdated
Comment thread src/k8s/pkg/k8sd/app/hooks_join.go Outdated

@bschimke95 bschimke95 left a comment

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 good so far. Could you add (or extend) a test-case to verify the reverter behavior for the etcd part?

Comment thread src/k8s/pkg/k8sd/app/hooks_join.go Outdated
Comment thread src/k8s/pkg/k8sd/app/hooks_join.go Outdated
Signed-off-by: Louise K. Schmidtgen <louise.schmidtgen@canonical.com>
@louiseschmidtgen

Copy link
Copy Markdown
Contributor Author

Closed in favor of canonical/k8sd#6.

@louiseschmidtgen louiseschmidtgen deleted the KU-4853/join-revert branch January 27, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants