Skip to content

Use LTS microcluster#395

Merged
UtkarshBhatthere merged 12 commits intocanonical:mainfrom
masnax:microcluster_v2
Sep 12, 2024
Merged

Use LTS microcluster#395
UtkarshBhatthere merged 12 commits intocanonical:mainfrom
masnax:microcluster_v2

Conversation

@masnax
Copy link
Contributor

@masnax masnax commented Aug 1, 2024

Updates MicroCeph to use the stable release of microcluster at v2.0.0.

For the most part, the changes to the code in MicroCeph are just package imports and changing the definition of state.State to an interface.

The actual behavioural changes are these:

  • state.Context is no longer exposed, so request.Context from the API handler is passed around explicitly to each helper. This should actually result in more precise context handling for MicroCeph.

    • One caveat is a few async API operations which spawn a goroutine. For these context.Background() is used because the request context may cancel before the goroutine is complete.
  • Adds a schema update to MicroCeph that changes their foreign key references to core_cluster_members. This table has been renamed from internal_cluster_members to make it clear that accessing it is expected behaviour. I also took the liberty of renaming the previous schema update function to use an ordered naming scheme so that it doesn't become ambiguous where an update fits among the others.

  • Join tokens now have expiration dates. By default, MicroCeph will set a 3 hour expiration for join tokens, but this can be configured with the --timeout flag added to cluster add.

The project version supplied to microcluster has been set to UNKOWN for now because microcluster requires a value here.

@masnax
Copy link
Contributor Author

masnax commented Aug 2, 2024

Test failures appear to be because of the go module transition. Should be fixed when canonical/microcluster#219 is merged.

@masnax masnax force-pushed the microcluster_v2 branch 3 times, most recently from f496047 to fac5eb6 Compare August 2, 2024 21:24
@masnax masnax requested review from UtkarshBhatthere and sabaini and removed request for UtkarshBhatthere August 2, 2024 22:16
@UtkarshBhatthere
Copy link
Contributor

Thanks for the change @masnax will take a look :D

// schemaUpdate4 updates all tables referencing `internal_cluster_members` to now reference `core_cluster_members` instead.
func schemaUpdate4(ctx context.Context, tx *sql.Tx) error {
stmt := `
CREATE TABLE disks2 (
Copy link
Contributor

Choose a reason for hiding this comment

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

@sabaini It would be good to have a discussion for table names being introduced here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, the tables in MicroCeph have not been renamed, it is only the foreign key reference to the microcluster table that has changed. We ensure that foreign key references are not erased when we changed the table name internally, so no data will be lost.

This had to be retroactively applied to all schema updates in case a very old version of MicroCeph tries to update to the latest version.

daemonArgs := microcluster.DaemonArgs{
Verbose: c.global.flagLogVerbose,
Debug: c.global.flagLogDebug,
Version: "UNKNOWN", // FIXME: Add an explicit version to MicroCeph.
Copy link
Contributor

Choose a reason for hiding this comment

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

@masnax can you please add some comments to describe what versioning is this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When using the MicroCeph API, it is useful to determine the current version of MicroCeph so that compatibility can be verified. We have an endpoint at /core/1.0 that provides basic identifying information like the cluster name, address, and project version.

For example, from MicroCloud, we should be able to tell from the API that MicroCeph is installed from a revision belonging to a supported snap track/risk. Like MicroCloud LTS should verify that MicroCeph is also installed as an LTS version.

Microcluster validates that a version must be present, but I wasn't able to find any value in the project that matched this criteria so I put UNKOWN here.

I'll update the commit with the above information as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a comment in-line with the Version field now.

Copy link
Contributor

@UtkarshBhatthere UtkarshBhatthere left a comment

Choose a reason for hiding this comment

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

Did a round of reviews, have left questions and comments inline.

Copy link
Contributor

@roosterfish roosterfish left a comment

Choose a reason for hiding this comment

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

Thanks @masnax, looks good to me from microcluster perspective.

Aside from those changes I am wondering if we should parse the --timeout duration from string instead of requiring specifying it in seconds.
This way if you intend to use a duration of a few hours you don't have to provide this big int which represents the seconds but instead provide only 6h or 1d.
Something like we do in the microcluster example package.

@masnax
Copy link
Contributor Author

masnax commented Aug 28, 2024

Thanks @masnax, looks good to me from microcluster perspective.

Aside from those changes I am wondering if we should parse the --timeout duration from string instead of requiring specifying it in seconds. This way if you intend to use a duration of a few hours you don't have to provide this big int which represents the seconds but instead provide only 6h or 1d. Something like we do in the microcluster example package.

Good idea, this has been applied now.

Copy link
Collaborator

@sabaini sabaini left a comment

Choose a reason for hiding this comment

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

This lgtm, thanks @masnax!
One comment inline wrt to versioning

Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
microcluster no longer exposes the shutdown context, so these async
operations can no longer use it. It is not possible to use the request
context because it may cancel before the async operation returns, so
that just leaves context.Background.

In the future, MicroCeph should expose its own shutdown context that it
passes to microcluster app.Start.

Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Microcluster no longer exposes the shutdown context, so all context
handling for the API is shifted to use the request.Context as an
explicit argument.

Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Version is set to UNKNOWN until an official version number can be
chosen. This value cannot be blank.

Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
The `internal_cluster_members` table was renamed to
`core_cluster_members` to make it clear that this table is expected to
be accessed. As such, this adds a schema update that fixes the foreign
key reference on all tables.

Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
The database is implemented internally, so instead ServerCert is used to
signify a nil state.

Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
Signed-off-by: Max Asnaashari <max.asnaashari@canonical.com>
@masnax masnax requested a review from sabaini September 10, 2024 16:13
@UtkarshBhatthere UtkarshBhatthere merged commit 54cf522 into canonical:main Sep 12, 2024
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