From c71c1f554dac580103916c85a1426596e7a814af Mon Sep 17 00:00:00 2001 From: Mike Beaumont Date: Tue, 23 Jul 2024 21:54:47 -0400 Subject: [PATCH] fix(kuma-cp): paginate Secrets correctly in universal (#10954) We were wrapping a store that already had a pagination store with another pagination store. This led to inconsistent results like: ``` % kumactl get secrets --mesh nonprod --size 1000 | grep -v MESH | wc -l 450 % kumactl get secrets --mesh nonprod --offset 100 | grep -v MESH | wc -l 0 ``` Only k8s stores needs to be wrapped with a pagination store, the default store for universal is already paginated: https://github.com/kumahq/kuma/blob/7075f0e17466c73ec82aa95649124edad6cafe8d/pkg/core/bootstrap/bootstrap.go#L295-L301 https://github.com/kumahq/kuma/blob/7075f0e17466c73ec82aa95649124edad6cafe8d/pkg/plugins/secrets/universal/plugin.go#L17 Signed-off-by: Mike Beaumont --- pkg/core/bootstrap/bootstrap.go | 2 +- pkg/plugins/secrets/k8s/plugin.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/core/bootstrap/bootstrap.go b/pkg/core/bootstrap/bootstrap.go index ac6a07e721aa..99b61482ed6a 100644 --- a/pkg/core/bootstrap/bootstrap.go +++ b/pkg/core/bootstrap/bootstrap.go @@ -320,7 +320,7 @@ func initializeSecretStore(cfg kuma_cp.Config, builder *core_runtime.Builder) er if ss, err := plugin.NewSecretStore(builder, pluginConfig); err != nil { return err } else { - builder.WithSecretStore(core_store.NewPaginationStore(ss)) + builder.WithSecretStore(ss) return nil } } diff --git a/pkg/plugins/secrets/k8s/plugin.go b/pkg/plugins/secrets/k8s/plugin.go index ea5a42ee12fc..05c2f9909c3c 100644 --- a/pkg/plugins/secrets/k8s/plugin.go +++ b/pkg/plugins/secrets/k8s/plugin.go @@ -4,6 +4,7 @@ import ( "github.com/pkg/errors" core_plugins "github.com/kumahq/kuma/pkg/core/plugins" + core_store "github.com/kumahq/kuma/pkg/core/resources/store" secret_store "github.com/kumahq/kuma/pkg/core/secrets/store" k8s_extensions "github.com/kumahq/kuma/pkg/plugins/extensions/k8s" ) @@ -25,5 +26,9 @@ func (p *plugin) NewSecretStore(pc core_plugins.PluginContext, _ core_plugins.Pl if !ok { return nil, errors.Errorf("secret client hasn't been configured") } - return NewStore(client, client, mgr.GetScheme(), pc.Config().Store.Kubernetes.SystemNamespace) + coreStore, err := NewStore(client, client, mgr.GetScheme(), pc.Config().Store.Kubernetes.SystemNamespace) + if err != nil { + return nil, errors.Wrap(err, "couldn't create k8s secret store") + } + return core_store.NewPaginationStore(coreStore), nil }