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
Modularize API server (api/v1/server) #24016
Conversation
b4d3485
to
7532362
Compare
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 work!
Not too sure where handlers
should live, having them all under daemon
seems like a collection of mostly unrelated things again, but putting them closer to the modules the interface with doesn't encourage the clean separation as much.
Given they might share some handler code I'm in favour of collecting the handlers in one place, but I don't know how difficult it'll be to untangle them.
daemon/cmd/api_handlers.go
Outdated
type handlersOut struct { | ||
cell.Out | ||
|
||
DaemonGetCgroupDumpMetadataHandler daemon.GetCgroupDumpMetadataHandler `optional:"true"` |
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.
side note, I think optional:"true"
isn't described in the hive documentation, so had to read up on it in https://pkg.go.dev/go.uber.org/dig#hdr-Optional_Dependencies
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.
Right yeah this needs to be documented. Though I did just shoot myself in the foot with it.. I had the endpoint handler depend on ratelimiter that I hadn't provided and it just ignored it rather than complained about it (e.g. the optionality was infectious).. so might be better that it stays undocumented for now :D
I've removed the optional from this for now.
7532362
to
4d89ce0
Compare
44baaa4
to
d0ff2ac
Compare
b2da204
to
8a5b57a
Compare
8a5b57a
to
887aa16
Compare
/test |
/test-runtime |
4ce78d5
to
78bd797
Compare
/test Job 'Cilium-PR-K8s-1.16-kernel-4.19' failed: Click to show.Test Name
Failure Output
Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.16-kernel-4.19/867/ If it is a flake and a GitHub issue doesn't already exist to track it, comment |
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.
Is it possible to break this down into smaller chunks? 3K LoC for a review is too big.
(First two commits LGTM, I stopped after that)
There isn't that many changes. Most of the lines are regenerated code or documentation. |
5835434
to
076aae0
Compare
/test |
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 innocent enough 👍 Were you able to figure out the solution to the question Andrew asked about above? I don't see it in the current copy of the code.
076aae0
to
dbb792f
Compare
Oh no, I forgot to push! Could you please take another look? |
@@ -646,22 +584,3 @@ func (s *Server) TLSListener() (net.Listener, error) { | |||
return s.httpsServerL, nil | |||
} | |||
|
|||
func handleInterrupt(once *sync.Once, s *Server) { |
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've removed the signal handling as it's now done by hive in both the agent and the operator, and I checked that hubble-relay which uses the health server also does signal handling itself.
This implements server.Cell that takes in the API handlers individually rather than relying on some central place to construct "CiliumAPIAPI". Example use: import ( "github.com/cilium/cilium/api/v1/server "github.com/cilium/cilium/api/v1/server/restapi/endpoint" ) h := hive.New( endpointmanager.Cell, server.Cell, cell.Provide(newGetEndpointHandler), ) func newGetEndpointHandler(em endpointmanager.EndpointManager) endpoint.EndpointGetEndpointHandler { // Implement EndpointGetEndpointHandler with the endpoint manager. } Signed-off-by: Jussi Maki <jussi@isovalent.com>
Too many parameters in newDaemon, so just pass the daemonParams as-is. Signed-off-by: Jussi Maki <jussi@isovalent.com>
Refactor the server Stop() to respect the hook timeout and forcefully terminate active connections. Remove unused code from the template. Signed-off-by: Jussi Maki <jussi@isovalent.com>
dbb792f
to
edd7eaa
Compare
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.
lgtm in this slimmed down form
/test |
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! 🚀
Few failing tests due to transient apt install failures and temp VM provisioning failure. All relevant tests pass, so marking ready to merge. |
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.
Very nice!
This PR modularizes the cilium-agent's REST API server served over UNIX socket (cilium.sock) to
allow API handlers to be implemented from any module.
See #23882 for further motivation and individual commit messages for details.
The adaption to cilium-agent is left as follow-up PR.
After this a handler for Cilium API can be implemented thus: