feat: Expand plugin interface GetSegments()#2843
feat: Expand plugin interface GetSegments()#2843engedaam wants to merge 2 commits intokubernetes-sigs:masterfrom
Conversation
3f043e5 to
0959e9b
Compare
Code Coverage Diff
|
0959e9b to
e393546
Compare
e393546 to
1a3db16
Compare
|
/retest |
|
This PR has multiple commits, and the default merge method is: merge. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
6765ac5 to
926b09a
Compare
|
/retest |
pkg/driver/controller_test.go
Outdated
| AccessibleTopology: []*csi.Topology{ | ||
| { | ||
| Segments: map[string]string{WellKnownZoneTopologyKey: expZone}, | ||
| Segments: lo.Assign(map[string]string{ |
There was a problem hiding this comment.
GetNodeSegments() returns an empty map here since nothing calls SetNodeSegments with actual data, so this test passes whether or not the merge works. Can we add a test that sets some segments and checks they show up in the response?
There was a problem hiding this comment.
This is expected. Once a consumer has loaded the test with a plugin the segments will be updated to the correct value. This is how the remaining of the tests have been configured for the plugin
|
/assign @ConnorJC3 |
926b09a to
e62b106
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
edca3bb to
2b957c9
Compare
2b957c9 to
48384f8
Compare
| return driverName | ||
| } | ||
|
|
||
| func SetNodeSegments(segments map[string]string) { |
There was a problem hiding this comment.
SetDriverName is an unfortunate anti-pattern we adopted to get ourselves out of a bad situation with how the driver name was handled in a pre-plugin world, but I'd like to avoid expanding on that anti-pattern as it:
- Makes tracing the code path used harder
- Greatly increases the chance of bugs slipping in, for example this one related to SetDriverName: Initialize name-dependent variables in metadata-labaler node path #2827
- Increases the difficulty of testing changes
Because the same constraints that applied to the name don't apply to topology segments, can we just directly call the plugin in node.go and controller.go?
Something like:
plugin := plugin.GetPlugin()
if plugin != nil {
maps.Copy(segments, plugin.GetTopologySegments())
}
| // This function can be called before Init and should not depend on it | ||
| GetDriverName() string | ||
| // GetSegments provides additional segments to be added as part of the driver and controllers | ||
| GetNodeSegments() map[string]string |
There was a problem hiding this comment.
If we're also going to reuse this in the controller, can we call it something like GetTopologySegments or otherwise not reference Node?
What type of PR is this?
/kind feature
This change extends the EBS CSI driver plugin interface to support custom node topology segments that can be propagated to Kubernetes resources.
What is this PR about? / Why do we need it?
Dependencies:
How was this change tested?
make testDoes this PR introduce a user-facing change?