-
Notifications
You must be signed in to change notification settings - Fork 4
Versioning details in exporter to controller and client #29
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,11 @@ service ClientService { | |||||||||||
| option (google.api.http) = {delete: "/v1/{name=namespaces/*/leases/*}"}; | ||||||||||||
| option (google.api.method_signature) = "name"; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| rpc GetServiceVersion(google.protobuf.Empty) returns (GetServiceVersionResponse) { | ||||||||||||
| option (google.api.http) = {get: "/v1/version"}; | ||||||||||||
| option (google.api.method_signature) = ""; | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| message Exporter { | ||||||||||||
|
|
@@ -168,3 +173,9 @@ message DeleteLeaseRequest { | |||||||||||
| (google.api.resource_reference) = {type: "jumpstarter.dev/Lease"} | ||||||||||||
| ]; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| message GetServiceVersionResponse { | ||||||||||||
| string version = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; | ||||||||||||
| string build_date = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; | ||||||||||||
| string git_commit = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; | ||||||||||||
| } | ||||||||||||
|
Comment on lines
+177
to
+181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Remove duplicate message; rely on common.proto’s GetServiceVersionResponse. Defining a second GetServiceVersionResponse in package jumpstarter.client.v1 risks divergence from the canonical one in jumpstarter.v1 (common.proto). Delete this block. -message GetServiceVersionResponse {
- string version = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
- string build_date = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
- string git_commit = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
-}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,9 @@ import "jumpstarter/v1/common.proto"; | |||||||||
|
|
||||||||||
| // A service where a exporter can connect to make itself available | ||||||||||
| service ControllerService { | ||||||||||
| // Get service version1 | ||||||||||
| rpc GetServiceVersion(google.protobuf.Empty) returns (GetServiceVersionResponse); | ||||||||||
|
|
||||||||||
|
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in comment. “Get service version1” → “Get service version”. - // Get service version1
+ // Get service version📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| // Exporter registration | ||||||||||
| rpc Register(RegisterRequest) returns (RegisterResponse); | ||||||||||
|
|
||||||||||
|
|
@@ -61,6 +64,7 @@ message RegisterRequest { | |||||||||
| // jumpstarter.dev/hostname= | ||||||||||
| // jumpstarter.dev/name= | ||||||||||
| repeated DriverInstanceReport reports = 2; | ||||||||||
| string version = 3; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| message DriverInstanceReport { | ||||||||||
|
|
@@ -69,6 +73,8 @@ message DriverInstanceReport { | |||||||||
| map<string, string> labels = 3; | ||||||||||
| optional string description = 4; // optional custom driver description for CLI | ||||||||||
| map<string, string> methods_description = 5; // method name -> help text for CLI | ||||||||||
| string version = 6; // driver software version | ||||||||||
| string minimum_cli_version = 7; // the oldest compatible software version for the client side | ||||||||||
| } | ||||||||||
|
|
||||||||||
| message RegisterResponse { | ||||||||||
|
|
@@ -143,6 +149,7 @@ message GetReportResponse { | |||||||||
| // jumpstarter.dev/name= | ||||||||||
| repeated DriverInstanceReport reports = 3; | ||||||||||
| repeated Endpoint alternative_endpoints = 4; | ||||||||||
| string version = 5; // exporter software version | ||||||||||
| } | ||||||||||
|
|
||||||||||
| message Endpoint { | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
Use the shared type from common.proto and drop empty method_signature.
This RPC should return jumpstarter.v1.GetServiceVersionResponse to stay consistent across services. Also, omit the empty method_signature; leave it unset for Empty requests.
Additionally, verify there’s no HTTP path collision with other services exposing GET /v1/version if these are co-hosted behind the same gateway.
🏁 Script executed:
Length of output: 2149
🏁 Script executed:
Length of output: 96
Use shared GetServiceVersionResponse and remove empty method_signature
No other GET /v1/version endpoints detected.
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GetServiceVersionResponse from the common module does not have any grpc gateway annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I have an empty api method signature for grpc gateway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 2028
@mangelajo You're absolutely right! The shared
GetServiceVersionResponseincommon.protois missing theOUTPUT_ONLYfield behavior annotations, while your local definition inclient.protohas them correctly applied.The best approach would be to add the annotations to the shared type in
common.proto:Then you can use
jumpstarter.v1.GetServiceVersionResponseconsistently across all services (router, jumpstarter, and client) and remove the duplicate definition fromclient.proto. This ensures all services benefit from the proper grpc-gateway annotations.The
router.protoandjumpstarter.protofiles are already using the shared type, so adding the annotations there would improve their generated HTTP APIs as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
💡 Result:
Short best-practices for using google.api.method_signature when google.protobuf.Empty appears
If the RPC request type is google.protobuf.Empty:
If the RPC returns google.protobuf.Empty (i.e., no response body):
Follow the AIP/linter constraints for signatures:
gRPC<->HTTP (transcoding) considerations:
Practical tips:
Sources
@mangelajo According to Google API best practices, when an RPC takes
google.protobuf.Emptyas the request type, you should not include agoogle.api.method_signatureannotation at all—not even an empty one. Client libraries won't generate meaningful overloads from it since there are no request fields to expose.So the correct approach is to simply omit the line:
rpc GetServiceVersion(google.protobuf.Empty) returns (jumpstarter.v1.GetServiceVersionResponse) { option (google.api.http) = {get: "/v1/version"}; }Regarding your earlier comment about
GetServiceVersionResponsenot having gRPC Gateway annotations: that's expected and correct. Thegoogle.api.httpannotations belong on the RPC methods (likeGetServiceVersion), not on the message types (likeGetServiceVersionResponse). The HTTP endpoint mapping is defined at the service level, and the response message is automatically serialized/deserialized by the gateway.The response message only needs
google.api.field_behavior = OUTPUT_ONLYannotations on its fields (which it already has incommon.proto), but it doesn't need HTTP routing annotations.