From f62c14a9cc24fa7fc5711b0aa74c7534c8d6793b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Tue, 19 Apr 2022 11:18:39 +0200 Subject: [PATCH] Extend StandardStorage with Destroy to implement rbac storage destroy --- pkg/registry/core/pod/storage/eviction_test.go | 3 +++ pkg/registry/rbac/clusterrole/policybased/storage.go | 2 +- pkg/registry/rbac/clusterrolebinding/policybased/storage.go | 2 +- pkg/registry/rbac/role/policybased/storage.go | 2 +- pkg/registry/rbac/rolebinding/policybased/storage.go | 2 +- staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go | 5 +++++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/registry/core/pod/storage/eviction_test.go b/pkg/registry/core/pod/storage/eviction_test.go index 426029cd4d7..92cc0a3c082 100644 --- a/pkg/registry/core/pod/storage/eviction_test.go +++ b/pkg/registry/core/pod/storage/eviction_test.go @@ -689,3 +689,6 @@ func (ms *mockStore) NewList() runtime.Object { func (ms *mockStore) ConvertToTable(ctx context.Context, object runtime.Object, tableOptions runtime.Object) (*metav1.Table, error) { return nil, nil } + +func (ms *mockStore) Destroy() { +} diff --git a/pkg/registry/rbac/clusterrole/policybased/storage.go b/pkg/registry/rbac/clusterrole/policybased/storage.go index 13e40881f4f..047630732d9 100644 --- a/pkg/registry/rbac/clusterrole/policybased/storage.go +++ b/pkg/registry/rbac/clusterrole/policybased/storage.go @@ -48,7 +48,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe // Destroy cleans up resources on shutdown. func (r *Storage) Destroy() { - // FIXME: Do we have to anything to destroy here? + r.StandardStorage.Destroy() } func (r *Storage) NamespaceScoped() bool { diff --git a/pkg/registry/rbac/clusterrolebinding/policybased/storage.go b/pkg/registry/rbac/clusterrolebinding/policybased/storage.go index 8a48fe5a558..ad2de28e008 100644 --- a/pkg/registry/rbac/clusterrolebinding/policybased/storage.go +++ b/pkg/registry/rbac/clusterrolebinding/policybased/storage.go @@ -49,7 +49,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe // Destroy cleans up resources on shutdown. func (r *Storage) Destroy() { - // FIXME: Do we have to anything to destroy here? + r.StandardStorage.Destroy() } func (r *Storage) NamespaceScoped() bool { diff --git a/pkg/registry/rbac/role/policybased/storage.go b/pkg/registry/rbac/role/policybased/storage.go index 878627f3a28..c113e1d0f82 100644 --- a/pkg/registry/rbac/role/policybased/storage.go +++ b/pkg/registry/rbac/role/policybased/storage.go @@ -47,7 +47,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe // Destroy cleans up resources on shutdown. func (r *Storage) Destroy() { - // FIXME: Do we have to anything to destroy here? + r.StandardStorage.Destroy() } func (r *Storage) NamespaceScoped() bool { diff --git a/pkg/registry/rbac/rolebinding/policybased/storage.go b/pkg/registry/rbac/rolebinding/policybased/storage.go index ba13bc490fb..64883635516 100644 --- a/pkg/registry/rbac/rolebinding/policybased/storage.go +++ b/pkg/registry/rbac/rolebinding/policybased/storage.go @@ -50,7 +50,7 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe // Destroy cleans up resources on shutdown. func (r *Storage) Destroy() { - // FIXME: Do we have to anything to destroy here? + r.StandardStorage.Destroy() } func (r *Storage) NamespaceScoped() bool { diff --git a/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go b/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go index 0e9c5bf0352..6330ea8f531 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go @@ -283,6 +283,11 @@ type StandardStorage interface { GracefulDeleter CollectionDeleter Watcher + + // Destroy cleans up its resources on shutdown. + // Destroy has to be implemented in thread-safe way and be prepared + // for being called more than once. + Destroy() } // Redirector know how to return a remote resource's location.