Skip to content

Commit

Permalink
feat: Use flintlock unique id
Browse files Browse the repository at this point in the history
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 #291

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

remove id and ns from get and delete endpoints
  • Loading branch information
yitsushi committed Jan 25, 2022
1 parent 6dd10df commit 86d92cd
Show file tree
Hide file tree
Showing 52 changed files with 567 additions and 554 deletions.
6 changes: 6 additions & 0 deletions api/events/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type MicroVMSpecCreated struct {
ID string
// Namespace is the namespace of the created microvm.
Namespace string
// UID is the unique id of the created microvm.
UID string
}

// MicroVMSpecUpdated is an event for when a microvm spec is updated.
Expand All @@ -14,6 +16,8 @@ type MicroVMSpecUpdated struct {
ID string
// Namespace is the namespace of the updated microvm.
Namespace string
// UID is the unique id of the updated microvm.
UID string
}

// MicroVMSpecDeleted is an event for when a microvm spec is deleted.
Expand All @@ -22,4 +26,6 @@ type MicroVMSpecDeleted struct {
ID string
// Namespace is the namespace of the deleted microvm.
Namespace string
// UID is the unique id of the deleted microvm.
UID string
}
191 changes: 85 additions & 106 deletions api/services/microvm/v1alpha1/microvms.pb.go

Large diffs are not rendered by default.

84 changes: 22 additions & 62 deletions api/services/microvm/v1alpha1/microvms.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions api/services/microvm/v1alpha1/microvms.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ service MicroVM {
}
rpc DeleteMicroVM(DeleteMicroVMRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1alpha1/microvm/{namespace}/{id}"
delete: "/v1alpha1/microvm/{uid}"
};
}
rpc GetMicroVM(GetMicroVMRequest) returns (GetMicroVMResponse) {
option (google.api.http) = {
get: "/v1alpha1/microvm/{namespace}/{id}"
get: "/v1alpha1/microvm/{uid}"
};
}
rpc ListMicroVMs(ListMicroVMsRequest) returns (ListMicroVMsResponse) {
Expand All @@ -56,13 +56,11 @@ message CreateMicroVMResponse {
}

message DeleteMicroVMRequest {
string id = 1;
string namespace = 2;
string uid = 1;
}

message GetMicroVMRequest {
string id = 1;
string namespace = 2;
string uid = 1;
}

message GetMicroVMResponse {
Expand Down
22 changes: 7 additions & 15 deletions api/services/microvm/v1alpha1/microvms.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
]
}
},
"/v1alpha1/microvm/{namespace}/{id}": {
"/v1alpha1/microvm/{uid}": {
"get": {
"operationId": "MicroVM_GetMicroVM",
"responses": {
Expand All @@ -88,13 +88,7 @@
},
"parameters": [
{
"name": "namespace",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "id",
"name": "uid",
"in": "path",
"required": true,
"type": "string"
Expand Down Expand Up @@ -122,13 +116,7 @@
},
"parameters": [
{
"name": "namespace",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "id",
"name": "uid",
"in": "path",
"required": true,
"type": "string"
Expand Down Expand Up @@ -333,6 +321,10 @@
"type": "string",
"format": "date-time",
"description": "DeletedAt indicates the time the microvm was marked as deleted."
},
"uid": {
"type": "string",
"description": "UID is a globally unique identifier of the microvm."
}
},
"description": "MicroVMSpec represents the specification for a microvm."
Expand Down
Loading

0 comments on commit 86d92cd

Please sign in to comment.