diff --git a/pkg/registry/apiserverinternal/storageversion/storage/storage.go b/pkg/registry/apiserverinternal/storageversion/storage/storage.go index af97b70af18..7bb55c31ed8 100644 --- a/pkg/registry/apiserverinternal/storageversion/storage/storage.go +++ b/pkg/registry/apiserverinternal/storageversion/storage/storage.go @@ -73,6 +73,12 @@ func (r *StatusREST) New() runtime.Object { return &apiserverinternal.StorageVersion{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/apps/daemonset/storage/storage.go b/pkg/registry/apps/daemonset/storage/storage.go index 666b917f034..84df2450283 100644 --- a/pkg/registry/apps/daemonset/storage/storage.go +++ b/pkg/registry/apps/daemonset/storage/storage.go @@ -88,6 +88,12 @@ func (r *StatusREST) New() runtime.Object { return &apps.DaemonSet{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/apps/deployment/storage/storage.go b/pkg/registry/apps/deployment/storage/storage.go index a3155623946..8b05dd0b663 100644 --- a/pkg/registry/apps/deployment/storage/storage.go +++ b/pkg/registry/apps/deployment/storage/storage.go @@ -140,6 +140,12 @@ func (r *StatusREST) New() runtime.Object { return &apps.Deployment{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) @@ -185,6 +191,12 @@ func (r *RollbackREST) New() runtime.Object { return &apps.DeploymentRollback{} } +// Destroy cleans up resources on shutdown. +func (r *RollbackREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + var _ = rest.NamedCreater(&RollbackREST{}) // Create runs rollback for deployment @@ -283,6 +295,12 @@ func (r *ScaleREST) New() runtime.Object { return &autoscaling.Scale{} } +// Destroy cleans up resources on shutdown. +func (r *ScaleREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves object from Scale storage. func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { obj, err := r.store.Get(ctx, name, options) diff --git a/pkg/registry/apps/replicaset/storage/storage.go b/pkg/registry/apps/replicaset/storage/storage.go index ed0e37026e3..0c467d37327 100644 --- a/pkg/registry/apps/replicaset/storage/storage.go +++ b/pkg/registry/apps/replicaset/storage/storage.go @@ -136,6 +136,12 @@ func (r *StatusREST) New() runtime.Object { return &apps.ReplicaSet{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) @@ -185,6 +191,12 @@ func (r *ScaleREST) New() runtime.Object { return &autoscaling.Scale{} } +// Destroy cleans up resources on shutdown. +func (r *ScaleREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves object from Scale storage. func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { obj, err := r.store.Get(ctx, name, options) diff --git a/pkg/registry/apps/statefulset/storage/storage.go b/pkg/registry/apps/statefulset/storage/storage.go index ac399ad61cf..47558534cdd 100644 --- a/pkg/registry/apps/statefulset/storage/storage.go +++ b/pkg/registry/apps/statefulset/storage/storage.go @@ -124,6 +124,12 @@ func (r *StatusREST) New() runtime.Object { return &apps.StatefulSet{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) @@ -179,6 +185,12 @@ func (r *ScaleREST) New() runtime.Object { return &autoscaling.Scale{} } +// Destroy cleans up resources on shutdown. +func (r *ScaleREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves object from Scale storage. func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { obj, err := r.store.Get(ctx, name, options) diff --git a/pkg/registry/authentication/tokenreview/storage.go b/pkg/registry/authentication/tokenreview/storage.go index c9d24b40b53..46f3e00f1ac 100644 --- a/pkg/registry/authentication/tokenreview/storage.go +++ b/pkg/registry/authentication/tokenreview/storage.go @@ -54,6 +54,12 @@ func (r *REST) New() runtime.Object { return &authentication.TokenReview{} } +// Destroy cleans up resources on shutdown. +func (r *REST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { tokenReview, ok := obj.(*authentication.TokenReview) if !ok { diff --git a/pkg/registry/authorization/localsubjectaccessreview/rest.go b/pkg/registry/authorization/localsubjectaccessreview/rest.go index 8db3c1836f2..e28b03dc368 100644 --- a/pkg/registry/authorization/localsubjectaccessreview/rest.go +++ b/pkg/registry/authorization/localsubjectaccessreview/rest.go @@ -47,6 +47,12 @@ func (r *REST) New() runtime.Object { return &authorizationapi.LocalSubjectAccessReview{} } +// Destroy cleans up resources on shutdown. +func (r *REST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { localSubjectAccessReview, ok := obj.(*authorizationapi.LocalSubjectAccessReview) if !ok { diff --git a/pkg/registry/authorization/selfsubjectaccessreview/rest.go b/pkg/registry/authorization/selfsubjectaccessreview/rest.go index 5fc40fde360..f2c3a9a0b3c 100644 --- a/pkg/registry/authorization/selfsubjectaccessreview/rest.go +++ b/pkg/registry/authorization/selfsubjectaccessreview/rest.go @@ -47,6 +47,12 @@ func (r *REST) New() runtime.Object { return &authorizationapi.SelfSubjectAccessReview{} } +// Destroy cleans up resources on shutdown. +func (r *REST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { selfSAR, ok := obj.(*authorizationapi.SelfSubjectAccessReview) if !ok { diff --git a/pkg/registry/authorization/selfsubjectrulesreview/rest.go b/pkg/registry/authorization/selfsubjectrulesreview/rest.go index 82dc7a521b1..f1c3a9f86c7 100644 --- a/pkg/registry/authorization/selfsubjectrulesreview/rest.go +++ b/pkg/registry/authorization/selfsubjectrulesreview/rest.go @@ -49,6 +49,12 @@ func (r *REST) New() runtime.Object { return &authorizationapi.SelfSubjectRulesReview{} } +// Destroy cleans up resources on shutdown. +func (r *REST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + // Create attempts to get self subject rules in specific namespace. func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { selfSRR, ok := obj.(*authorizationapi.SelfSubjectRulesReview) diff --git a/pkg/registry/authorization/subjectaccessreview/rest.go b/pkg/registry/authorization/subjectaccessreview/rest.go index ae06324e8e6..4bb2072a5f7 100644 --- a/pkg/registry/authorization/subjectaccessreview/rest.go +++ b/pkg/registry/authorization/subjectaccessreview/rest.go @@ -46,6 +46,12 @@ func (r *REST) New() runtime.Object { return &authorizationapi.SubjectAccessReview{} } +// Destroy cleans up resources on shutdown. +func (r *REST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { subjectAccessReview, ok := obj.(*authorizationapi.SubjectAccessReview) if !ok { diff --git a/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go b/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go index 319d2e0ec6c..03171ed1ff0 100644 --- a/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go +++ b/pkg/registry/autoscaling/horizontalpodautoscaler/storage/storage.go @@ -88,6 +88,12 @@ func (r *StatusREST) New() runtime.Object { return &autoscaling.HorizontalPodAutoscaler{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/batch/cronjob/storage/storage.go b/pkg/registry/batch/cronjob/storage/storage.go index 5e36416332a..637dc8f3754 100644 --- a/pkg/registry/batch/cronjob/storage/storage.go +++ b/pkg/registry/batch/cronjob/storage/storage.go @@ -86,6 +86,12 @@ func (r *StatusREST) New() runtime.Object { return &batch.CronJob{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/batch/job/storage/storage.go b/pkg/registry/batch/job/storage/storage.go index 4b9ca99ea50..f6cfa679536 100644 --- a/pkg/registry/batch/job/storage/storage.go +++ b/pkg/registry/batch/job/storage/storage.go @@ -129,6 +129,12 @@ func (r *StatusREST) New() runtime.Object { return &batch.Job{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/certificates/certificates/storage/storage.go b/pkg/registry/certificates/certificates/storage/storage.go index 8e2da90b16d..8de7828efde 100644 --- a/pkg/registry/certificates/certificates/storage/storage.go +++ b/pkg/registry/certificates/certificates/storage/storage.go @@ -89,6 +89,12 @@ func (r *StatusREST) New() runtime.Object { return &certificates.CertificateSigningRequest{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) @@ -122,6 +128,12 @@ func (r *ApprovalREST) New() runtime.Object { return &certificates.CertificateSigningRequest{} } +// Destroy cleans up resources on shutdown. +func (r *ApprovalREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *ApprovalREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/core/componentstatus/rest.go b/pkg/registry/core/componentstatus/rest.go index 0cb8cad23a2..22fe41a0c84 100644 --- a/pkg/registry/core/componentstatus/rest.go +++ b/pkg/registry/core/componentstatus/rest.go @@ -58,6 +58,12 @@ func (rs *REST) New() runtime.Object { return &api.ComponentStatus{} } +// Destroy cleans up resources on shutdown. +func (r *REST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + func (rs *REST) NewList() runtime.Object { return &api.ComponentStatusList{} } diff --git a/pkg/registry/core/namespace/storage/storage.go b/pkg/registry/core/namespace/storage/storage.go index b910e30a20c..37b130092ca 100644 --- a/pkg/registry/core/namespace/storage/storage.go +++ b/pkg/registry/core/namespace/storage/storage.go @@ -98,6 +98,11 @@ func (r *REST) New() runtime.Object { return r.store.New() } +// Destroy cleans up resources on shutdown. +func (r *REST) Destroy() { + r.store.Destroy() +} + func (r *REST) NewList() runtime.Object { return r.store.NewList() } @@ -300,6 +305,12 @@ func (r *StatusREST) New() runtime.Object { return r.store.New() } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) @@ -325,6 +336,12 @@ func (r *FinalizeREST) New() runtime.Object { return r.store.New() } +// Destroy cleans up resources on shutdown. +func (r *FinalizeREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Update alters the status finalizers subset of an object. func (r *FinalizeREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { // We are explicitly setting forceAllowCreate to false in the call to the underlying storage because diff --git a/pkg/registry/core/node/rest/proxy.go b/pkg/registry/core/node/rest/proxy.go index 40b069978d1..40e6431b40b 100644 --- a/pkg/registry/core/node/rest/proxy.go +++ b/pkg/registry/core/node/rest/proxy.go @@ -50,6 +50,12 @@ func (r *ProxyREST) New() runtime.Object { return &api.NodeProxyOptions{} } +// Destroy cleans up resources on shutdown. +func (r *ProxyREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // ConnectMethods returns the list of HTTP methods that can be proxied func (r *ProxyREST) ConnectMethods() []string { return proxyMethods diff --git a/pkg/registry/core/node/storage/storage.go b/pkg/registry/core/node/storage/storage.go index 54057bfb886..56e806770f4 100644 --- a/pkg/registry/core/node/storage/storage.go +++ b/pkg/registry/core/node/storage/storage.go @@ -66,6 +66,12 @@ func (r *StatusREST) New() runtime.Object { return &api.Node{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/core/persistentvolume/storage/storage.go b/pkg/registry/core/persistentvolume/storage/storage.go index 03eaf682fe6..df65eabc879 100644 --- a/pkg/registry/core/persistentvolume/storage/storage.go +++ b/pkg/registry/core/persistentvolume/storage/storage.go @@ -83,6 +83,12 @@ func (r *StatusREST) New() runtime.Object { return &api.PersistentVolume{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/core/persistentvolumeclaim/storage/storage.go b/pkg/registry/core/persistentvolumeclaim/storage/storage.go index 6650606ac57..d472bbd8ef3 100644 --- a/pkg/registry/core/persistentvolumeclaim/storage/storage.go +++ b/pkg/registry/core/persistentvolumeclaim/storage/storage.go @@ -127,6 +127,12 @@ func (r *StatusREST) New() runtime.Object { return &api.PersistentVolumeClaim{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/core/pod/rest/log.go b/pkg/registry/core/pod/rest/log.go index 9d5f320978e..e6b02069b28 100644 --- a/pkg/registry/core/pod/rest/log.go +++ b/pkg/registry/core/pod/rest/log.go @@ -51,6 +51,12 @@ func (r *LogREST) New() runtime.Object { return &api.Pod{} } +// Destroy cleans up resources on shutdown. +func (r *LogREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // ProducesMIMETypes returns a list of the MIME types the specified HTTP verb (GET, POST, DELETE, // PATCH) can respond with. func (r *LogREST) ProducesMIMETypes(verb string) []string { diff --git a/pkg/registry/core/pod/rest/subresources.go b/pkg/registry/core/pod/rest/subresources.go index cb79deca431..76e0cdd4ffb 100644 --- a/pkg/registry/core/pod/rest/subresources.go +++ b/pkg/registry/core/pod/rest/subresources.go @@ -49,6 +49,12 @@ func (r *ProxyREST) New() runtime.Object { return &api.PodProxyOptions{} } +// Destroy cleans up resources on shutdown. +func (r *ProxyREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // ConnectMethods returns the list of HTTP methods that can be proxied func (r *ProxyREST) ConnectMethods() []string { return proxyMethods @@ -91,6 +97,12 @@ func (r *AttachREST) New() runtime.Object { return &api.PodAttachOptions{} } +// Destroy cleans up resources on shutdown. +func (r *AttachREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Connect returns a handler for the pod exec proxy func (r *AttachREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) { attachOpts, ok := opts.(*api.PodAttachOptions) @@ -128,6 +140,12 @@ func (r *ExecREST) New() runtime.Object { return &api.PodExecOptions{} } +// Destroy cleans up resources on shutdown. +func (r *ExecREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Connect returns a handler for the pod exec proxy func (r *ExecREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) { execOpts, ok := opts.(*api.PodExecOptions) @@ -165,6 +183,12 @@ func (r *PortForwardREST) New() runtime.Object { return &api.PodPortForwardOptions{} } +// Destroy cleans up resources on shutdown. +func (r *PortForwardREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // NewConnectOptions returns the versioned object that represents the // portforward parameters func (r *PortForwardREST) NewConnectOptions() (runtime.Object, bool, string) { diff --git a/pkg/registry/core/pod/storage/eviction.go b/pkg/registry/core/pod/storage/eviction.go index 39f2e041673..0fb7ac03eeb 100644 --- a/pkg/registry/core/pod/storage/eviction.go +++ b/pkg/registry/core/pod/storage/eviction.go @@ -95,6 +95,12 @@ func (r *EvictionREST) New() runtime.Object { return &policy.Eviction{} } +// Destroy cleans up resources on shutdown. +func (r *EvictionREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Propagate dry-run takes the dry-run option from the request and pushes it into the eviction object. // It returns an error if they have non-matching dry-run options. func propagateDryRun(eviction *policy.Eviction, options *metav1.CreateOptions) (*metav1.DeleteOptions, error) { diff --git a/pkg/registry/core/pod/storage/storage.go b/pkg/registry/core/pod/storage/storage.go index 7787dbdc0e4..c426b8727ed 100644 --- a/pkg/registry/core/pod/storage/storage.go +++ b/pkg/registry/core/pod/storage/storage.go @@ -157,6 +157,12 @@ func (r *BindingREST) New() runtime.Object { return &api.Binding{} } +// Destroy cleans up resources on shutdown. +func (r *BindingREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + var _ = rest.NamedCreater(&BindingREST{}) // Create ensures a pod is bound to a specific host. @@ -263,6 +269,12 @@ func (r *LegacyBindingREST) New() runtime.Object { return r.bindingRest.New() } +// Destroy cleans up resources on shutdown. +func (r *LegacyBindingREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Create ensures a pod is bound to a specific host. func (r *LegacyBindingREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (out runtime.Object, err error) { metadata, err := meta.Accessor(obj) @@ -282,6 +294,12 @@ func (r *StatusREST) New() runtime.Object { return &api.Pod{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) @@ -324,6 +342,12 @@ func (r *EphemeralContainersREST) New() runtime.Object { return &api.Pod{} } +// Destroy cleans up resources on shutdown. +func (r *EphemeralContainersREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Update alters the EphemeralContainers field in PodSpec func (r *EphemeralContainersREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { if !utilfeature.DefaultFeatureGate.Enabled(features.EphemeralContainers) { diff --git a/pkg/registry/core/replicationcontroller/storage/storage.go b/pkg/registry/core/replicationcontroller/storage/storage.go index 1325e719950..39a59f4a73e 100644 --- a/pkg/registry/core/replicationcontroller/storage/storage.go +++ b/pkg/registry/core/replicationcontroller/storage/storage.go @@ -131,6 +131,12 @@ func (r *StatusREST) New() runtime.Object { return &api.ReplicationController{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) @@ -174,6 +180,12 @@ func (r *ScaleREST) New() runtime.Object { return &autoscaling.Scale{} } +// Destroy cleans up resources on shutdown. +func (r *ScaleREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { obj, err := r.store.Get(ctx, name, options) if err != nil { diff --git a/pkg/registry/core/resourcequota/storage/storage.go b/pkg/registry/core/resourcequota/storage/storage.go index d302169e90e..d438ec792e2 100644 --- a/pkg/registry/core/resourcequota/storage/storage.go +++ b/pkg/registry/core/resourcequota/storage/storage.go @@ -82,6 +82,12 @@ func (r *StatusREST) New() runtime.Object { return &api.ResourceQuota{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/core/service/proxy.go b/pkg/registry/core/service/proxy.go index ced40db39dd..f0eb9d0788a 100644 --- a/pkg/registry/core/service/proxy.go +++ b/pkg/registry/core/service/proxy.go @@ -46,6 +46,12 @@ func (r *ProxyREST) New() runtime.Object { return &api.ServiceProxyOptions{} } +// Destroy cleans up resources on shutdown. +func (r *ProxyREST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + // ConnectMethods returns the list of HTTP methods that can be proxied func (r *ProxyREST) ConnectMethods() []string { return proxyMethods diff --git a/pkg/registry/core/service/storage/storage.go b/pkg/registry/core/service/storage/storage.go index eff83977fef..7565101c4cb 100644 --- a/pkg/registry/core/service/storage/storage.go +++ b/pkg/registry/core/service/storage/storage.go @@ -166,6 +166,12 @@ func (r *StatusREST) New() runtime.Object { return &api.Service{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/core/serviceaccount/storage/token.go b/pkg/registry/core/serviceaccount/storage/token.go index 8ba30ed8446..6f840e53154 100644 --- a/pkg/registry/core/serviceaccount/storage/token.go +++ b/pkg/registry/core/serviceaccount/storage/token.go @@ -43,6 +43,12 @@ func (r *TokenREST) New() runtime.Object { return &authenticationapi.TokenRequest{} } +// Destroy cleans up resources on shutdown. +func (r *TokenREST) Destroy() { + // Given no underlying store, we don't destroy anything + // here explicitly. +} + type TokenREST struct { svcaccts getter pods getter diff --git a/pkg/registry/flowcontrol/flowschema/storage/storage.go b/pkg/registry/flowcontrol/flowschema/storage/storage.go index 089b37fc46c..d1d287e735f 100644 --- a/pkg/registry/flowcontrol/flowschema/storage/storage.go +++ b/pkg/registry/flowcontrol/flowschema/storage/storage.go @@ -81,6 +81,12 @@ func (r *StatusREST) New() runtime.Object { return &flowcontrol.FlowSchema{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/flowcontrol/prioritylevelconfiguration/storage/storage.go b/pkg/registry/flowcontrol/prioritylevelconfiguration/storage/storage.go index 28d1f148963..defbd608b66 100644 --- a/pkg/registry/flowcontrol/prioritylevelconfiguration/storage/storage.go +++ b/pkg/registry/flowcontrol/prioritylevelconfiguration/storage/storage.go @@ -81,6 +81,12 @@ func (r *StatusREST) New() runtime.Object { return &flowcontrol.PriorityLevelConfiguration{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/networking/ingress/storage/storage.go b/pkg/registry/networking/ingress/storage/storage.go index 0f084232f15..71ab37c455e 100644 --- a/pkg/registry/networking/ingress/storage/storage.go +++ b/pkg/registry/networking/ingress/storage/storage.go @@ -80,6 +80,12 @@ func (r *StatusREST) New() runtime.Object { return &networking.Ingress{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/networking/networkpolicy/storage/storage.go b/pkg/registry/networking/networkpolicy/storage/storage.go index 574c0815116..0101077b662 100644 --- a/pkg/registry/networking/networkpolicy/storage/storage.go +++ b/pkg/registry/networking/networkpolicy/storage/storage.go @@ -82,6 +82,12 @@ func (r *StatusREST) New() runtime.Object { return &networkingapi.NetworkPolicy{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/policy/poddisruptionbudget/storage/storage.go b/pkg/registry/policy/poddisruptionbudget/storage/storage.go index 987c200d465..4af2ea2429f 100644 --- a/pkg/registry/policy/poddisruptionbudget/storage/storage.go +++ b/pkg/registry/policy/poddisruptionbudget/storage/storage.go @@ -77,6 +77,12 @@ func (r *StatusREST) New() runtime.Object { return &policyapi.PodDisruptionBudget{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/pkg/registry/rbac/clusterrole/policybased/storage.go b/pkg/registry/rbac/clusterrole/policybased/storage.go index e3a9dd6ff2b..13e40881f4f 100644 --- a/pkg/registry/rbac/clusterrole/policybased/storage.go +++ b/pkg/registry/rbac/clusterrole/policybased/storage.go @@ -46,6 +46,11 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe return &Storage{s, authorizer, ruleResolver} } +// Destroy cleans up resources on shutdown. +func (r *Storage) Destroy() { + // FIXME: Do we have to anything to destroy here? +} + func (r *Storage) NamespaceScoped() bool { return false } diff --git a/pkg/registry/rbac/clusterrolebinding/policybased/storage.go b/pkg/registry/rbac/clusterrolebinding/policybased/storage.go index 6a4b2c8f2e1..8a48fe5a558 100644 --- a/pkg/registry/rbac/clusterrolebinding/policybased/storage.go +++ b/pkg/registry/rbac/clusterrolebinding/policybased/storage.go @@ -47,6 +47,11 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe return &Storage{s, authorizer, ruleResolver} } +// Destroy cleans up resources on shutdown. +func (r *Storage) Destroy() { + // FIXME: Do we have to anything to destroy here? +} + func (r *Storage) NamespaceScoped() bool { return false } diff --git a/pkg/registry/rbac/role/policybased/storage.go b/pkg/registry/rbac/role/policybased/storage.go index 34281be9754..878627f3a28 100644 --- a/pkg/registry/rbac/role/policybased/storage.go +++ b/pkg/registry/rbac/role/policybased/storage.go @@ -45,6 +45,11 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe return &Storage{s, authorizer, ruleResolver} } +// Destroy cleans up resources on shutdown. +func (r *Storage) Destroy() { + // FIXME: Do we have to anything to destroy here? +} + func (r *Storage) NamespaceScoped() bool { return true } diff --git a/pkg/registry/rbac/rolebinding/policybased/storage.go b/pkg/registry/rbac/rolebinding/policybased/storage.go index d73a1e1f93a..ba13bc490fb 100644 --- a/pkg/registry/rbac/rolebinding/policybased/storage.go +++ b/pkg/registry/rbac/rolebinding/policybased/storage.go @@ -48,6 +48,11 @@ func NewStorage(s rest.StandardStorage, authorizer authorizer.Authorizer, ruleRe return &Storage{s, authorizer, ruleResolver} } +// Destroy cleans up resources on shutdown. +func (r *Storage) Destroy() { + // FIXME: Do we have to anything to destroy here? +} + func (r *Storage) NamespaceScoped() bool { return true } diff --git a/pkg/registry/storage/volumeattachment/storage/storage.go b/pkg/registry/storage/volumeattachment/storage/storage.go index cb1d0b25b53..91c1c2a1142 100644 --- a/pkg/registry/storage/volumeattachment/storage/storage.go +++ b/pkg/registry/storage/volumeattachment/storage/storage.go @@ -85,6 +85,12 @@ func (r *StatusREST) New() runtime.Object { return &storageapi.VolumeAttachment{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go index 2eb7a246399..2523076edf9 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/etcd.go @@ -195,6 +195,12 @@ func (r *StatusREST) New() runtime.Object { return &apiextensions.CustomResourceDefinition{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go index 6cb17dfdb03..e9659bb4783 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/apiserver_test.go @@ -462,6 +462,9 @@ func (storage *SimpleRESTStorage) NewList() runtime.Object { return &genericapitesting.SimpleList{} } +func (storage *SimpleRESTStorage) Destroy() { +} + func (storage *SimpleRESTStorage) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) { storage.checkContext(ctx) storage.created = obj.(*genericapitesting.Simple) @@ -547,6 +550,9 @@ func (s *ConnecterRESTStorage) New() runtime.Object { return &genericapitesting.Simple{} } +func (s *ConnecterRESTStorage) Destroy() { +} + func (s *ConnecterRESTStorage) Connect(ctx context.Context, id string, options runtime.Object, responder rest.Responder) (http.Handler, error) { s.receivedConnectOptions = options s.receivedID = id @@ -668,6 +674,9 @@ func (storage *SimpleTypedStorage) New() runtime.Object { return storage.baseType } +func (storage *SimpleTypedStorage) Destroy() { +} + func (storage *SimpleTypedStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) { storage.checkContext(ctx) return storage.item.DeepCopyObject(), storage.errors["get"] @@ -810,6 +819,9 @@ func (UnimplementedRESTStorage) New() runtime.Object { return &genericapitesting.Simple{} } +func (UnimplementedRESTStorage) Destroy() { +} + // TestUnimplementedRESTStorage ensures that if a rest.Storage does not implement a given // method, that it is literally not registered with the server. In the past, // we registered everything, and returned method not supported if it didn't support @@ -4322,6 +4334,9 @@ func (storage *SimpleXGSubresourceRESTStorage) New() runtime.Object { return &genericapitesting.SimpleXGSubresource{} } +func (storage *SimpleXGSubresourceRESTStorage) Destroy() { +} + func (storage *SimpleXGSubresourceRESTStorage) Get(ctx context.Context, id string, options *metav1.GetOptions) (runtime.Object, error) { return storage.item.DeepCopyObject(), nil } 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 a489095d6e0..0e9c5bf0352 100644 --- a/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go +++ b/staging/src/k8s.io/apiserver/pkg/registry/rest/rest.go @@ -56,6 +56,11 @@ type Storage interface { // New returns an empty object that can be used with Create and Update after request data has been put into it. // This object must be a pointer type for use with Codec.DecodeInto([]byte, runtime.Object) New() runtime.Object + + // 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() } // Scoper indicates what scope the resource is at. It must be specified. diff --git a/staging/src/k8s.io/apiserver/pkg/server/deleted_kinds_test.go b/staging/src/k8s.io/apiserver/pkg/server/deleted_kinds_test.go index 9d2f2d5f44a..12af7fadc3c 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/deleted_kinds_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/deleted_kinds_test.go @@ -110,6 +110,9 @@ func (r removedInStorage) New() runtime.Object { return removedInObj{major: r.major, minor: r.minor} } +func (r removedInStorage) Destroy() { +} + type neverRemovedObj struct { } diff --git a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go index 016278c02cf..1deb78252d8 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go +++ b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver.go @@ -92,9 +92,7 @@ type APIGroupInfo struct { func (a *APIGroupInfo) destroyStorage() { for _, stores := range a.VersionedResourcesStorageMap { for _, store := range stores { - // TODO(wojtek-t): Uncomment once all storage support it. - klog.Errorf("Destroying storage: %v", store) - // store.Destroy() + store.Destroy() } } } diff --git a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go index af452347c83..c6b07fc3fff 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/genericapiserver_test.go @@ -544,6 +544,9 @@ func (p *testGetterStorage) New() runtime.Object { } } +func (p *testGetterStorage) Destroy() { +} + func (p *testGetterStorage) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return nil, nil } @@ -565,6 +568,9 @@ func (p *testNoVerbsStorage) New() runtime.Object { } } +func (p *testNoVerbsStorage) Destroy() { +} + func fakeVersion() version.Info { return version.Info{ Major: "42", diff --git a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go index 662f1f058f3..d20573ed368 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd/etcd.go @@ -147,6 +147,12 @@ func (r *StatusREST) New() runtime.Object { return &apiregistration.APIService{} } +// Destroy cleans up resources on shutdown. +func (r *StatusREST) Destroy() { + // Given that underlying store is shared with REST, + // we don't destroy it here explicitly. +} + // Get retrieves the object from the storage. It is required to support Patch. func (r *StatusREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { return r.store.Get(ctx, name, options) diff --git a/staging/src/k8s.io/sample-apiserver/pkg/registry/registry.go b/staging/src/k8s.io/sample-apiserver/pkg/registry/registry.go index 32da2eda903..f5107aeed29 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/registry/registry.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/registry/registry.go @@ -20,7 +20,6 @@ import ( "fmt" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" - "k8s.io/apiserver/pkg/registry/rest" ) // REST implements a RESTStorage for API services against etcd @@ -31,7 +30,7 @@ type REST struct { // RESTInPeace is just a simple function that panics on error. // Otherwise returns the given storage object. It is meant to be // a wrapper for wardle registries. -func RESTInPeace(storage rest.StandardStorage, err error) rest.StandardStorage { +func RESTInPeace(storage *REST, err error) *REST { if err != nil { err = fmt.Errorf("unable to create REST storage for a resource due to %v, will die", err) panic(err)