Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UUID fields into spaces and subnets #139

Merged
merged 3 commits into from
Apr 15, 2024
Merged

Add UUID fields into spaces and subnets #139

merged 3 commits into from
Apr 15, 2024

Conversation

nvinuesa
Copy link
Member

@nvinuesa nvinuesa commented Apr 3, 2024

This patch adds the UUID field to spaces and subnets. Also, it adds the spaceUUID field to subnets.

The idea behind this, is that on Juju 4+ we will keep the entity's UUID when migrating them. One of the reasons is to keep the relation between entities sound after migration.

For migrations 3.5 -> 4.0, the UUID will naturally be empty when importing the model on the 4.0 controller and thus creating the entity with a new UUID.

nvinuesa added 2 commits April 3, 2024 18:41
We have added the UUID to the spaces in the  serialized model for migrations, because
we want to keep the UUIDs of entities across migrations.
Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

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

We need to think about removing ID, at least on export.

@@ -15,6 +15,7 @@ type spaces struct {

type space struct {
Id_ string `yaml:"id"`
Copy link
Member

Choose a reason for hiding this comment

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

With the addition of uuid, can't we do away with Id now?

Copy link
Member Author

Choose a reason for hiding this comment

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

answered below

space.go Outdated
@@ -138,6 +147,28 @@ func importSpaceV2(source map[string]interface{}) (*space, error) {
}, nil
}

func importSpaceV3(source map[string]interface{}) (*space, error) {
fields, defaults := spaceV2Fields()
Copy link
Member

Choose a reason for hiding this comment

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

Don't do this here - add a spaceV3Fields() method.
I see that V2 used this pattern - whomever did it originally did it wrong :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -150,3 +181,10 @@ func spaceV1Fields() (schema.Fields, schema.Defaults) {
}
return fields, defaults
}

func spaceV2Fields() (schema.Fields, schema.Defaults) {
Copy link
Member

Choose a reason for hiding this comment

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

So this method is added.
But we still don't use it, eg we still have this code in import v1

	fields, defaults := spaceV1Fields()
	fields["id"] = schema.String()

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, added V3 and used this func

space.go Outdated
@@ -138,6 +147,28 @@ func importSpaceV2(source map[string]interface{}) (*space, error) {
}, nil
}

func importSpaceV3(source map[string]interface{}) (*space, error) {
Copy link
Member

Choose a reason for hiding this comment

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

We should use the pattern where the import version is passed in to a common import function (as is done elsewhere).

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, done

@@ -35,7 +37,9 @@ type subnet struct {
// SubnetArgs is an argument struct used to create a
// new internal subnet type that supports the Subnet interface.
type SubnetArgs struct {
// Deprecated in favor of UUID
ID string
Copy link
Member

Choose a reason for hiding this comment

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

Since this is v6, we can get rid of ID since it's being replaced bu UUID.

Copy link
Member Author

Choose a reason for hiding this comment

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

So we discussed with @jameinel and @SimonRichardson and the idea is to keep these deprecated fields to ensure not breaking in the future (although this version shouldn't be used in juju <4). This is coherent to what was done previously in subnets with SpaceName.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we will need to reconcile V3 to V4 by the IDs anyway.

model.go Outdated
Comment on lines 1242 to 1246
// TODO(nvinuesa): How will we identify the alpha space
// in UUID?
if subnet.SpaceUUID() == "" {
continue
}
Copy link
Member Author

Choose a reason for hiding this comment

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

IMO we shouldn't be doing these checks at this level, this should be a serialization/deserialization library and with these validate functions we are adding business logic. This particular check is not OK anymore and we should decide if we want to add the (new) alpha space UUID here or remove this validate altogether. @wallyworld @SimonRichardson

Copy link
Member Author

Choose a reason for hiding this comment

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

after discussing with @manadart, we are keeping 0 as the uuid for the alpha space.

@nvinuesa nvinuesa requested a review from wallyworld April 4, 2024 20:26
Copy link
Member

@manadart manadart left a comment

Choose a reason for hiding this comment

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

This looks OK to me.

@@ -35,7 +37,9 @@ type subnet struct {
// SubnetArgs is an argument struct used to create a
// new internal subnet type that supports the Subnet interface.
type SubnetArgs struct {
// Deprecated in favor of UUID
ID string
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we will need to reconcile V3 to V4 by the IDs anyway.

@nvinuesa nvinuesa merged commit 8c1d144 into v6 Apr 15, 2024
1 check passed
@SimonRichardson SimonRichardson deleted the add-uuid-spaces branch July 29, 2024 08:30
jujubot added a commit that referenced this pull request Jul 29, 2024
…ta-manifest

#148

Cherry-pick of #147 to v7, to allow landing of 3.6 without bringing in #139

We can't land this into v6 as that is for main. So effectively, v6 branch is dead and we should never have cut a release for main against v6. The main branch is unfinished and we should have been just iterating on a hash.
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.

3 participants