-
Notifications
You must be signed in to change notification settings - Fork 17
Make RESTMapper in client cluster-aware #57
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
Make RESTMapper in client cluster-aware #57
Conversation
pkg/kcp/wrappers.go
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that the second return value is a boolean, not an error. Will add a 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.
done
@soumyadip007: changing LGTM is restricted to collaborators In 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 <[email protected]>
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
8a658d8
to
ef8fdeb
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.
just nit hypotatical question. else - lgtm to me. Will wait for @embik cycle
pkg/client/client.go
Outdated
}, | ||
scheme: options.Scheme, | ||
mapper: options.Mapper, | ||
} | ||
mapperCache, err := lru.New[logicalcluster.Name, meta.RESTMapper](1000) |
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.
Would it make sense 1000 to create a global variable? If somebody wants to tune it, its possible this way?
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.
Addressed.
LGTM label has been added. Git tree hash: 012e2b48af67a9a94da088abcc0ca6420e82eec7
|
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
000384b
to
83ac60c
Compare
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
/lgtm |
LGTM label has been added. Git 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
Needs 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.