-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Expose Thanos HTTP APIs to OpenAPI/protobuf Proposal #4426
Conversation
Signed-off-by: Hangzhi <[email protected]>
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.
Nice, great work! I love it, LGTM 💪🏽
@@ -0,0 +1,73 @@ | |||
| type | title | status | menu | |
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.
I think we use different format of front matter - hopefully we can get rid of this too, but right now it's required to be yaml between ---
letters.
|
||
## **Motivations** | ||
|
||
In order to improve Thanos usage for users, we would like to define our HTTP APIs in protobuf/OpenAPI and expose those in the website. This would allow users to use tools for documentation, validation, type checking, and even code generation to use our APIs efficiently. |
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.
In order to improve Thanos usage for users, we would like to define our HTTP APIs in protobuf/OpenAPI and expose those in the website. This would allow users to use tools for documentation, validation, type checking, and even code generation to use our APIs efficiently. | |
In order to improve Thanos usage for users, we would like to define our HTTP APIs in protobuf/OpenAPI and expose those in our repository. This would allow users to use tools for documentation, validation, type checking, and even code generation to use our APIs efficiently. | |
Similarly we want reuse this work in Prometheus. | |
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.
For readability it would be good to expand on the following parts:
In order to improve Thanos usage for users
- what do we mean by improve here? What positive benefit will this bring to users?protobuf/OpenAPI
- as far as I am aware these are two different & non-interchangeable things?
|
||
### **Pitfalls of the current solution** | ||
|
||
- Documentation needs to be written manually. |
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.
- Documentation needs to be written manually. | |
- Documentation, Server code and client code boilerplate needs to be written manually. | |
- It's hard to discover the current API programmatically. | |
- It's easy to make an accidental breaking changes when modifying API |
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.
I would reword the final point to be something like
When modifying the API, it is very difficult to know if this breaks downstream users
Or similar :)
- Be able to generate OpenAPI3 from protobuf. | ||
- Auto-generate documentation with OpenAPI3 specification. | ||
- Generate server code from API specification (OpenAPI3 or protobuf). | ||
- Define all configuration potentially in protobuf too: https://github.com/openproto/protoconfig. |
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.
Maybe we can drop that to focus more on APIs in this phase (:
|
||
## **Non-Goals** | ||
|
||
- Not define Thanos gRPC APIs in protobuf specification. |
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.
- Not define Thanos gRPC APIs in protobuf specification. | |
- Don't mix gRPC with HTTP APIs in same protobuf package | |
|
||
## **How** | ||
|
||
- Define Thanos APIs in protobuf specification. |
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.
- Define Thanos APIs in protobuf specification. | |
- Define Thanos HTTP APIs in protobuf specification. | |
- Define Thanos APIs in protobuf specification. | ||
- Generate OpenAPI from protobuf with gnostic extension. | ||
- Generate documentation from OpenAPI with [swagger](https://github.com/swagger-api/swagger-codegen). | ||
- Generate server API client and server stubs potentially from OpenAPI with [swagger](https://github.com/swagger-api/swagger-codegen) or [oapi-codegen](https://github.com/deepmap/oapi-codegen). |
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.
- Generate server API client and server stubs potentially from OpenAPI with [swagger](https://github.com/swagger-api/swagger-codegen) or [oapi-codegen](https://github.com/deepmap/oapi-codegen). | |
- Generate server and client API stubs potentially from OpenAPI with [swagger](https://github.com/swagger-api/swagger-codegen) or [oapi-codegen](https://github.com/deepmap/oapi-codegen). | |
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.
I'm not a big fan of having 'potentially' in proposals - we're either going to do it or not :)
|
||
## **Alternatives** | ||
|
||
## **Only define HTTP RESTful API only in OpenAPI. Not in protobuf.** |
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.
## **Only define HTTP RESTful API only in OpenAPI. Not in protobuf.** | |
## **Define HTTP RESTful API only in OpenAPI. Not in protobuf.** | |
## **Only define HTTP RESTful API only in OpenAPI. Not in protobuf.** | ||
|
||
1. Pros: | ||
1. We are not sure whether we can definitely generate OpenAPI specifications from protobuf. |
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.
- There are might be some complexity, edge case and extra tooling to make 3 step process (proto -> open API -> documentation to work
1. We can have gRPC and RESTful APIs at the same time. | ||
2. We have gRPC APIs like rules API. | ||
2. Cons: | ||
1. We don't know clearly how grpc-gateway works. |
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.
- We need run another sidecar (complexity of running the system)
- Semantics of gRPC and HTTP might be different and surprising for end user.
- We want to reuse in Prometheus and Prometheus does not support gRPC (gRPC dependency was removed from codebase)
- Same port library is not maintained. (cmux)
@Hangzhi |
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.
Looks good - the content is good, but I think our motivations can be better explained.
|
||
## **Motivations** | ||
|
||
In order to improve Thanos usage for users, we would like to define our HTTP APIs in protobuf/OpenAPI and expose those in the website. This would allow users to use tools for documentation, validation, type checking, and even code generation to use our APIs efficiently. |
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.
For readability it would be good to expand on the following parts:
In order to improve Thanos usage for users
- what do we mean by improve here? What positive benefit will this bring to users?protobuf/OpenAPI
- as far as I am aware these are two different & non-interchangeable things?
|
||
### **Pitfalls of the current solution** | ||
|
||
- Documentation needs to be written manually. |
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.
I would reword the final point to be something like
When modifying the API, it is very difficult to know if this breaks downstream users
Or similar :)
- Define all APIs in protobuf. | ||
- Be able to generate OpenAPI3 from protobuf. | ||
- Auto-generate documentation with OpenAPI3 specification. | ||
- Generate server code from API specification (OpenAPI3 or protobuf). | ||
- Define all configuration potentially in protobuf too: https://github.com/openproto/protoconfig. |
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.
IMO these are not goals per-se but the steps we take to satisfy the goals - in fact, they are very similar to the How
section below.
I think the goals here is to make the Thanos APIs easier to share, document and consume?
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.
@ianbillett Thank you for your great reviews. Yes, make the Thanos APIs easier to share, document and consume
seems like a better phrase. But in LFX mentorship program, I think we need a clear goal to decide whether this project is accepted. This goal seems to be vague and hard to quantify. 😃
- Define Thanos APIs in protobuf specification. | ||
- Generate OpenAPI from protobuf with gnostic extension. | ||
- Generate documentation from OpenAPI with [swagger](https://github.com/swagger-api/swagger-codegen). | ||
- Generate server API client and server stubs potentially from OpenAPI with [swagger](https://github.com/swagger-api/swagger-codegen) or [oapi-codegen](https://github.com/deepmap/oapi-codegen). |
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.
I'm not a big fan of having 'potentially' in proposals - we're either going to do it or not :)
Signed-off-by: Hangzhi <[email protected]>
Signed-off-by: Hangzhi <[email protected]>
Signed-off-by: Hangzhi <[email protected]>
574ff45
to
b4ce47b
Compare
Hello @ianbillett. The test shows that the file is not formatted, but it's not clear how |
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.
Looking good to me, just some small non-blocker nits.
Since you are not modifying the e2e tests we can safely conclude that failed due to a transient flake. You can trigger a re-test with an empty commit If you inspect the output of the failing test it shows you why the linter is failing. If you inspect the |
Signed-off-by: Hangzhi <[email protected]>
Signed-off-by: Hangzhi <[email protected]>
@ianbillett Thank you for your very helpful information! I finally got the error info in detail with |
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.
Amazing work!
Let's merge it, it has all details we want, problem and goals outlined well 💪🏽
On our 1:2 we acknowledged that this proposal has some risk - there are things we need to experiment with. This is fine though -we can iterate on it. Edit the "HOW" when we find new things or reject it at then end if needed. But current version shows the latest direction.
Signed-off-by: Hangzhi [email protected]
Related to : #4102
Changes
Verification