-
Notifications
You must be signed in to change notification settings - Fork 338
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
feat(kuma-cp) provide total
field when listing resources in the HTTP API
#723
Conversation
I've got this working in the GUI. It can be tested in this PR. |
93fa7a2
to
5eab14e
Compare
5eab14e
to
3dc20ab
Compare
pkg/plugins/resources/k8s/store.go
Outdated
return nil | ||
} | ||
|
||
func (s *KubernetesStore) countK8sResources(ctx context.Context, rs core_model.ResourceList) (int, error) { |
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.
Can you check if total elements counting works with different meshes?
Create 2 meshes: "default" and "demo"
Create 2 traffic permissions in "default" mesh and in 2 in demo
List traffic permissions by "demo" and see if the total is 2 or 4.
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.
Right, so I need additional filtering when counting the resources here.
da4bf11
to
9bff2b9
Compare
Add GetItemsCount and SetItemsCount to facilitate the overall items of that kind. This is expanidn on the pagination ideas so that one can have the total items available for pagination. Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
This makes setting values inside actually work. Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Now we use GetPagination and use the accessors to the Total and NextOffset fields. Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
9bff2b9
to
2bcaf2e
Compare
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
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.
Please add a test in store_test_template.go
it's a test that checks the contract for all the stores, so you will write the test once for all stores.
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Add a specific test in the K8s List() verification to account for multi mesh resource filtering. Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Summary
When we fetch entities via the HTTP API (and therefore via the GUI and
kumactl
) we don't know what is the total number of sites for a particular resource stored in the Kuma control plane. Return a total count of items for each resource that works on both Universal and Kubernetes.Adds a new
total
top-level property in the HTTP API responses, so they look likeThe implementation in all supported resource store mechanisms (memory, PostgreSQL and Kubernetes) is based on naive resource counting each time a List requests gets in. That can be optimized (cached?) for better scalability once Kuma has to handle huge amount of resources with multiple concurrent API requests happening. This optimisation is left for a follow-up PR.
Full changelog
Issues resolved
None