Skip to content

feat: Bump microcluster to v3#9

Merged
HomayoonAlimohammadi merged 5 commits into
mainfrom
KU-5052/microcluster-v3
Mar 5, 2026
Merged

feat: Bump microcluster to v3#9
HomayoonAlimohammadi merged 5 commits into
mainfrom
KU-5052/microcluster-v3

Conversation

@HomayoonAlimohammadi

@HomayoonAlimohammadi HomayoonAlimohammadi commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR bumps Microcluster to v3. There were a couple of breaking changes between v2 and v3:

  • The cluster package is now internal to Microcluster. Functions like cluster.DeleteClusterMember, cluster.GetClusterMember etc. are now not accessible externally. The Microcluster app instance offers these functionalities in v3 by creating a local client and calling into the internal API.
  • Some packages were shuffled around (e.g. /microcluster/types)
  • We're no longer using lxd/response, instead it's baked into Microcluster. However, some functionalities were missing and a PR is currently open to add the missing functionalities: feat: Add response and log functionalities microcluster#603

@github-actions

Copy link
Copy Markdown

Microcluster Schema Changes Detected

⚠️ Warning: This pull request contains changes to the microcluster version.

Please ensure that the changes are intentional and have been reviewed by the appropriate team members.

Adding a migration:

You should not change the Microcluster migration files in interim Kubernetes releases to ensure a smooth
upgrade path from one LTS to the next. In case of upgrade failures, we need to be able to rollback to the last Kubernetes LTS which is only possible if the microcluster migrations have not been changed.

Do not under any circumstances remove any migrations and never change the order of migrations in the microcluster schema files.

Copilot AI left a comment

Copy link
Copy Markdown

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 upgrades the project from Microcluster v2 to v3, which introduces several breaking API changes. The upgrade addresses package reorganization, internal API restrictions, and response handling consolidation.

Changes:

  • Updated all import paths from microcluster/v2 to microcluster/v3 and reorganized package imports (e.g., rest/typesmicrocluster/types, lxd/responsemicrocluster/rest/response)
  • Replaced database cluster operations (cluster.Stmt, cluster.RegisterStmt) with new db package equivalents (db.Stmt, db.RegisterStmt)
  • Migrated from s.Leader() client to snap.K8sdClient("") for cluster operations, and updated method names (e.g., DeleteClusterMemberRemoveClusterMember)
  • Updated State API method calls to function calls (e.g., s.FileSystem().StateDirs.FileSystem().StateDir())
  • Created new utils.Path() helper function to replace the removed s.Address().Path() method
  • Added microcluster client methods to the mock implementation and k8sd client interface

Reviewed changes

Copilot reviewed 66 out of 67 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/utils/url.go New utility function for URL path construction
pkg/utils/node/node.go Updated to accept snap parameter and use new k8sd client
pkg/utils/microcluster/state.go Updated microcluster import path
pkg/utils/http.go Migrated from lxd response to microcluster response
pkg/snap/mock/provider.go Updated microcluster import path
pkg/k8sd/features/* Updated microcluster import paths
pkg/k8sd/database/* Migrated from cluster package to db package for database operations
pkg/k8sd/controllers/feature.go Updated microcluster import path
pkg/k8sd/app/* Updated hooks to use new APIs, removed deprecated config fields, updated certificate methods
pkg/k8sd/api/* Updated all response types and client access patterns
pkg/client/k8sd/* Updated client implementation and added cluster member operations
cmd/k8sd/* Updated filesystem API calls and deprecated flag descriptions
go.mod/go.sum Updated dependency to microcluster v3 with temporary replace directive

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

Comment thread pkg/k8sd/app/hooks_remove.go Outdated
Comment thread pkg/k8sd/api/cluster_remove.go Outdated
Comment thread go.mod Outdated
Signed-off-by: Homayoon (Hue) Alimohammadi <homayoon.alimohammadi@canonical.com>
Signed-off-by: Homayoon (Hue) Alimohammadi <homayoon.alimohammadi@canonical.com>
Signed-off-by: Homayoon (Hue) Alimohammadi <homayoon.alimohammadi@canonical.com>
Signed-off-by: Homayoon (Hue) Alimohammadi <homayoon.alimohammadi@canonical.com>
@HomayoonAlimohammadi

Copy link
Copy Markdown
Contributor Author

e2e tests on the k8s-snap repo: canonical/k8s-snap#2347

@louiseschmidtgen louiseschmidtgen 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.

A few smaller comments, could you also trigger the version upgrade and rollback tests (nightly suite) for this PR?

retries++
} else {
// NOTE(Hue): We can not check for `cluster.Pending` with the `Role` type since it's internal to Microcluster
notPending = member.Role != "PENDING"

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.

Can we ask Julian to expose this type for us? Checking for the string equivalent doesn't seem ideal.

@HomayoonAlimohammadi HomayoonAlimohammadi Mar 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great point! I've raised this PR: canonical/microcluster#650

Comment thread pkg/k8sd/api/cluster_remove.go Outdated
Comment thread pkg/k8sd/app/hooks_remove.go
Comment thread go.mod
Signed-off-by: Homayoon (Hue) Alimohammadi <homayoon.alimohammadi@canonical.com>
@HomayoonAlimohammadi

Copy link
Copy Markdown
Contributor Author

I've decided to bump to v3.0.2 since it's been out recently and there's almost no changes compared to the commit hash that we've been using in this PR.

@bschimke95 bschimke95 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, please create a follow up card "bump to 3.0.3" to address Louise comment. IMHO we don't need to wait on this to merge this PR. It has been long enough.

@HomayoonAlimohammadi

Copy link
Copy Markdown
Contributor Author

The e2e tests are passing. Let's gooo!

@HomayoonAlimohammadi HomayoonAlimohammadi merged commit 7af059e into main Mar 5, 2026
6 checks passed
@HomayoonAlimohammadi HomayoonAlimohammadi deleted the KU-5052/microcluster-v3 branch March 5, 2026 15:06
ktsakalozos-canonical pushed a commit that referenced this pull request May 28, 2026
* feat: Bump microcluster to v3

* chore: use mctypes alias for microcluster/types import

---------

Signed-off-by: Homayoon (Hue) Alimohammadi <homayoon.alimohammadi@canonical.com>
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.

4 participants