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

feat: Use flintlock unique id #327

Merged
merged 6 commits into from
Jan 26, 2022
Merged

Conversation

yitsushi
Copy link
Contributor

@yitsushi yitsushi commented Dec 17, 2021

What this PR does / why we need it:

This commit message will be a QA like commit message

Why in the spec and not somewhere else?

Historically we are using the same spec in create request an responses,
we do not return with status on create request because it's mostly
empty. The uuid could be there, but on create there is no status yet.

Why is it set on create request?

We can't return the uuid in the response if it's not generated and
without the uuid they can't delete the resource, it would be a disaster
if capmvm sends a request to create ns1/mvm1, then it wants to delete it
even before we created the resources. If the delete request would be
only ns1/mvm1 it would delete the old one, or basically any other
microvms that has the same name and namespace (coming from other
management clusters).

Why is it global and not microvm specific?

It seems logical and generating and maintaining a unique id shouldn't be
the job of the microvm provider, their responsibility should be to
manage microvms, metadata and other stuffs are provider independent.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #291

Special notes for your reviewer:

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2022

Codecov Report

Merging #327 (eec3be9) into main (3807bed) will decrease coverage by 0.46%.
The diff coverage is 63.04%.

❗ Current head eec3be9 differs from pull request most recent head 97182d0. Consider uploading reports for the commit 97182d0 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #327      +/-   ##
==========================================
- Coverage   57.76%   57.30%   -0.47%     
==========================================
  Files          51       51              
  Lines        2517     2546      +29     
==========================================
+ Hits         1454     1459       +5     
- Misses        945      964      +19     
- Partials      118      123       +5     
Impacted Files Coverage Δ
core/application/errors.go 0.00% <0.00%> (ø)
core/application/reconcile.go 0.00% <0.00%> (ø)
infrastructure/firecracker/provider.go 0.00% <0.00%> (ø)
infrastructure/firecracker/state.go 0.00% <0.00%> (ø)
core/models/vmid.go 61.11% <43.47%> (-24.26%) ⬇️
infrastructure/grpc/convert.go 41.98% <60.00%> (+0.18%) ⬆️
infrastructure/containerd/repo.go 74.25% <80.00%> (+0.01%) ⬆️
core/application/commands.go 71.64% <85.71%> (-1.38%) ⬇️
core/application/query.go 100.00% <100.00%> (ø)
core/plans/microvm_delete.go 60.37% <100.00%> (-0.74%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3807bed...97182d0. Read the comment docs.

@yitsushi yitsushi force-pushed the 291-uuid branch 2 times, most recently from 84d9839 to 841dcf3 Compare January 14, 2022 09:29
jmickey
jmickey previously approved these changes Jan 14, 2022
Copy link
Contributor

@jmickey jmickey left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -58,11 +58,13 @@ message CreateMicroVMResponse {
message DeleteMicroVMRequest {
string id = 1;
string namespace = 2;
string uuid = 3;
Copy link
Member

@richardcase richardcase Jan 19, 2022

Choose a reason for hiding this comment

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

I'm not sure about this. I think we need 2 versions of the Delete/Get API methods:

  • Delete/Get(name, namespace)
  • DeleteById/GetById(id)

I still think its valid to get or delete a microvm based on its namespace/name only

Copy link
Member

Choose a reason for hiding this comment

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

This would probably then mean changing id to name throughout flintlock

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 wouldn't let users to delete by ns/name only because in some cases it will not be only one, same for get. The get endpoint returns one spec, but without the uid, it's not guaranteed that's the only one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or we have to update the Get return a list of specs.

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 would even go remove everything from the delete and get and leave it only the uid. So you can Get (single spec response) only with uid and delete the same way.

Copy link
Member

Choose a reason for hiding this comment

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

Yes i think perhaps you are right. Get and delete should only accept the id. I think we should also implement (in a different PR) a Find that we can use to find by the ns/name.....wdyt?

if err != nil {
return nil, fmt.Errorf("creating vmid: %w", err)
}

mvm.ID = *vmid
}

uuid, err := a.ports.IdentifierService.GenerateRandom()
Copy link
Member

Choose a reason for hiding this comment

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

The infrastructure implementation that we use for the identifier service doesn't generate a UUID but instead a ULID. It does say a ULID is compatible with a UUID but its not formatted as a UUID with this call.

Maybe we need to refer to this as a uid instead of uuid to indicate that its not a UUID? Or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, it's even more confusing now. Turned out i used a.ports.IdentifierService.GenerateRandom() here and in the grpc server uuid.New().String() which one should we keep?

Copy link
Contributor Author

@yitsushi yitsushi Jan 20, 2022

Choose a reason for hiding this comment

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

i'll use ulid to be more consistent with the rest of the system.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah ulid from the identifier service is the best.

This commit message will be a QA like ocmmit message

Why in the spec and not somewhere else?

Historically we are using the same spec in create request an responses,
we do not return with status on create request because it's mostly
empty. The uuid could be there, but on create there is no status yet.

Why is it set on create request?

We can't return the uuid in the response if it's not generated and
without the uuid they can't delete the resource, it would be a disaster
if capmvm sends a request to create ns1/mvm1, then it wants to delete it
even before we created the resources. If the delete request would be
only ns1/mvm1 it would delete the old one, or basically any other
microvms that has the same name and namespace (coming from other
management clusters).

Why is it global and not microvm specific?

It seems logical and generating and maintaining a unique id shouldn't be
the job of the microvm provider, their responsibility should be to
manage microvms, metadata and other stuffs are provider independent.

Fixes liquidmetal-dev#291

rename field to be uid instead of uuid because it is an ulid now

remove id and ns from get and delete endpoints
Callisto13
Callisto13 previously approved these changes Jan 25, 2022
core/application/commands.go Outdated Show resolved Hide resolved
@@ -1,4 +1,5 @@
{
"id": "mvm1",
"namespace": "ns1"
"namespace": "ns1",
"uid": "b1c0aa3c-ebba-498a-a7c7-903d91758d83"
Copy link
Member

Choose a reason for hiding this comment

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

should the other 2 be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that "tooling" has to be refined after Find.

Comment on lines 49 to 54
/*
if req.Microvm.Uid == nil {
newUID := uuid.New().String()
req.Microvm.Uid = &newUID
}
*/
Copy link
Member

Choose a reason for hiding this comment

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

this meant to be here still?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope XD

richardcase
richardcase previously approved these changes Jan 25, 2022
Co-authored-by: Claudia <claudiaberesford@gmail.com>
@yitsushi yitsushi dismissed stale reviews from richardcase and Callisto13 via 979ea2e January 25, 2022 15:54
@yitsushi yitsushi merged commit 054c6c3 into liquidmetal-dev:main Jan 26, 2022
yitsushi added a commit that referenced this pull request Jan 26, 2022
* e2e path was not updated.
* Get tried to use empty name and namespace as a filter, not it does not
  use those values if they are empty.
* UpdateMicroVM required all fields.

Related to #291 (issue)
Related to #327 (pr)
@yitsushi yitsushi mentioned this pull request Jan 26, 2022
4 tasks
yitsushi added a commit that referenced this pull request Jan 26, 2022
* fix: uid related issues

* e2e path was not updated.
* Get tried to use empty name and namespace as a filter, not it does not
  use those values if they are empty.
* UpdateMicroVM required all fields.

Related to #291 (issue)
Related to #327 (pr)

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create globally unique identifier per microvm
5 participants