1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-01 07:27:46 +00:00

Add garbage collection for events table (#664)

* Add ListOptionIndexerOptions to create ListOptionIndexer

* Remove unused function

* Implement configurable garbage collection on ListOptionIndexer

* Propagate Steve options from Server
This commit is contained in:
Tom Lebreux
2025-06-10 10:02:55 -06:00
committed by GitHub
parent 39fed09b2e
commit f258ebcf31
10 changed files with 469 additions and 116 deletions

View File

@@ -14,12 +14,9 @@ import (
"github.com/rancher/steve/pkg/attributes"
"github.com/rancher/steve/pkg/resources/common"
"github.com/rancher/steve/pkg/sqlcache/db"
"github.com/rancher/steve/pkg/sqlcache/encryption"
"github.com/rancher/steve/pkg/sqlcache/informer"
"github.com/rancher/steve/pkg/sqlcache/informer/factory"
"github.com/rancher/steve/pkg/sqlcache/partition"
"github.com/rancher/steve/pkg/sqlcache/store"
"github.com/rancher/steve/pkg/stores/sqlpartition/listprocessor"
"github.com/rancher/steve/pkg/stores/sqlproxy/tablelistconvert"
"go.uber.org/mock/gomock"
@@ -40,7 +37,6 @@ import (
"k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/rest"
clientgotesting "k8s.io/client-go/testing"
cache "k8s.io/client-go/tools/cache"
)
//go:generate mockgen --build_flags=--mod=mod -package sqlproxy -destination ./proxy_mocks_test.go github.com/rancher/steve/pkg/stores/sqlproxy Cache,ClientGetter,CacheFactory,SchemaColumnSetter,RelationshipNotifier,TransformBuilder
@@ -1522,35 +1518,3 @@ func TestUpdate(t *testing.T) {
})
}
}
func makeListOptionIndexer(ctx context.Context, fields [][]string) (*informer.ListOptionIndexer, error) {
gvk := schema2.GroupVersionKind{
Group: "",
Version: "",
Kind: "",
}
example := &unstructured.Unstructured{}
example.SetGroupVersionKind(gvk)
name := "theName"
m, err := encryption.NewManager()
if err != nil {
return nil, err
}
db, err := db.NewClient(nil, m, m)
if err != nil {
return nil, err
}
s, err := store.NewStore(ctx, example, cache.DeletionHandlingMetaNamespaceKeyFunc, db, false, name)
if err != nil {
return nil, err
}
listOptionIndexer, err := informer.NewListOptionIndexer(ctx, fields, s, true)
if err != nil {
return nil, err
}
return listOptionIndexer, nil
}