Implement Destroy() method for all registries

This commit is contained in:
Wojciech Tyczyński 2022-04-05 12:26:22 +02:00
parent 0527a0dd45
commit 80060a502c
47 changed files with 356 additions and 5 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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)

View File

@ -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 {

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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{}
}

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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 {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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 {

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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)

View File

@ -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)

View File

@ -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
}

View File

@ -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.

View File

@ -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 {
}

View File

@ -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()
}
}
}

View File

@ -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",

View File

@ -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)

View File

@ -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)