Make RESTMapper in client cluster-aware#57
Conversation
| var mu sync.RWMutex | ||
| cache := expirable.NewLRU[logicalcluster.Path, meta.RESTMapper](1000, nil, time.Minute) | ||
| return func(ctx context.Context) (meta.RESTMapper, error) { | ||
| c, _ := kontext.ClusterFrom(ctx) |
There was a problem hiding this comment.
The error from kontext.ClusterFrom(ctx) is ignored (c, _ := kontext.ClusterFrom(ctx)). We may consider it.
c, err := kontext.ClusterFrom(ctx)
if err != nil {
// Handle error appropriately, perhaps returning a nil mapper with the error
return nil, err
}
There was a problem hiding this comment.
Noticed that the second return value is a boolean, not an error. Will add a comment.
|
@soumyadip007: changing LGTM is restricted to collaborators DetailsIn response to this: Instructions 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/test-infra repository. |
0f36a17 to
be71e2c
Compare
61933e4 to
440ded2
Compare
0874689 to
afafb15
Compare
|
/retest |
1 similar comment
|
/retest |
afafb15 to
2272adc
Compare
c11bdf3 to
adffd80
Compare
adffd80 to
900a3c9
Compare
900a3c9 to
8a658d8
Compare
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
8a658d8 to
ef8fdeb
Compare
| scheme: options.Scheme, | ||
| mapper: options.Mapper, | ||
| } | ||
| mapperCache, err := lru.New[logicalcluster.Name, meta.RESTMapper](1000) |
There was a problem hiding this comment.
Would it make sense 1000 to create a global variable? If somebody wants to tune it, its possible this way?
|
LGTM label has been added. DetailsGit tree hash: 012e2b48af67a9a94da088abcc0ca6420e82eec7 |
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
000384b to
83ac60c
Compare
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
|
/lgtm |
|
LGTM label has been added. DetailsGit tree hash: e5fbb599c01580fe2f73c6de2763b38d309d80f3 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mjudeikis The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR makes discovery cluster-aware, i.e. the RESTMapper is instantiated per cluster and cached with an LRU cache.
This matters because currently the controller-runtime client is unusable on non-uniform virtual workspaces or even against kcp itself as a scoped client because the used REST mapper talks to the wildcard endpoint only.