Skip to content

Commit

Permalink
fix(kuma-cp): paginate Secrets correctly in universal (#10954)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
michaelbeaumont authored Jul 24, 2024
1 parent 7075f0e commit c71c1f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/core/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/plugins/secrets/k8s/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
}

0 comments on commit c71c1f5

Please sign in to comment.