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
EndpointManager and NodeManager Cells #21746
EndpointManager and NodeManager Cells #21746
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
f42c894
to
2dfcd74
Compare
2dfcd74
to
51c9973
Compare
a080b1e
to
27f95d3
Compare
2a8ace8
to
b20a9b6
Compare
b20a9b6
to
37d3916
Compare
37d3916
to
321948e
Compare
/test Job 'Cilium-PR-K8s-1.24-kernel-5.4' failed: Click to show.Test Name
Failure Output
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.
Very nice, like the separate interfaces. Can't find anything to complain about.
321948e
to
a2330d9
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.
Nice, thanks. One comment below about root context passing. Otherwise LGTM.
a2330d9
to
9b67c2e
Compare
9b67c2e
to
37e3c5f
Compare
/test |
@tommyp1ckles addressed your comments about the method comments. Your comments about the API itself were good, but I wouldn't want to change the existing API in this PR as this is only about wrapping the endpoint manager into a module and lifting it outside |
37e3c5f
to
68ff514
Compare
Sounds good, seeing the interface written for these is a good opportunity to see where we can improve things. Everything LGTM, thanks! |
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 assume we need to apply this pattern for other subsystems steadily ✔️
This moves the creation of the endpoint manager from daemon.go into pkg/endpointmanager/cell.go. Signed-off-by: Jussi Maki <jussi@isovalent.com>
Dropped the unused selector cache and policy triggerer from node manager and moved the node handler subscription out from the manager creation. NodeDiscovery no longer needs to Close() the NodeManager as this is now done by a stop hook in NodeManager. Signed-off-by: Jussi Maki <jussi@isovalent.com>
When printing the lifecycle hooks a left-over debug print appeared if a start function was not defined in a hook: "{<nil> 0x223af60} not defined". Signed-off-by: Jussi Maki <jussi@isovalent.com>
NodeManager's Stop() was earlier only used by tests so it's behavior was to clean up datapath state by calling NodeDelete for each node. This is not the desired behavior as we want to preserve the datapath state when shutting down in order to not disrupt connectivity. This cleanup behavior was never used in any tests and prior this was only triggered by control-plane tests via call to Daemon.Close(), so it's safe to remove this. In addition Stop() did not wait for the backgroundSync() goroutine to exit in Stop(). Fix this by using workerpool. Signed-off-by: Jussi Maki <jussi@isovalent.com>
68ff514
to
21cd454
Compare
/test |
test-runtime hit #19093, which is unrelated to changes. Marking ready. |
This PR adds cells for EndpointManager and NodeManager (cilium-agent objects snippet):
The endpoint manager is now exposed as 3 different APIs: EndpointsLookup (for read-only lookups of endpoints), EndpointsModify (for adding and removing endpoints), and EndpointManager (for initialization and operations on all endpoints). This division by functionality adds clarity ("ah this module only needs to look up endpoints") and makes integration testing of cells depending on e.g. endpoint lookup simpler.
Node manager's API is kept as in one chunk as it's relatively small. It is still exposed as an interface rather than as struct pointer, again for improved integration testing and for clarity. Providing interfaces at the cell-level does not go against the "return structs, accept interfaces" rule. That rule is all about loose coupling in public APIs, e.g. library functions should be flexible in what they accept (don't take
*os.File
, butio.Reader
). Here we're following the same spirit, but at the macro level. With interfaces in the object graph we can choose the implementation to provide to a cell or augment an existing one (cell.Decorate) if needed. This gives maximum flexibility and loose coupling that comes especially handy in integration testing.