Updating ByNames to not return nil, nil #132
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ByNames could previously return a nil value and a nil error. This caused issues when other parts of the application
(pkg/stores/partition/parallel.go) tried to use the result. Now this will return an empty list on the error condition, instead of nil.
Related to rancher/rancher#43030.
Overview
Steve's partion lister makes in internal call to a
Lister
, which is (in turn) a proxy/rbac store. After making this call, it attempts to set several values from the result of that call, including the ResourceVersion of the list (which is useful for future calls to these resources, potentially including paginated use cases). In the case where the user has a permission granting permissions on specific resourceNames in the entire cluster (see below for a production use-case) this will result in a panic - since the proxy store returnsnil
for both the err and the list in this case.This results in a panic in steve and the binary using steve (in this case, the cluster agent), which causes the linked issue above.
This case is triggered in (at least) the monitoring v2 use case - the monitoring-ui-view cluster role grants permissions on specific resource names, and can be assigned to users at the cluster level using a cluster role binding (see rancher/dashboard#9792 for an example).
Solution
Change the proxy store to return a valid value in the identified use case (user has permissions on all resources of a specific name at the cluster scope). Long term, we may want this to return valid values, but given the explicit warnings in the code I think this needs more investigation before we go that route.