Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request kubernetes#109303 from wojtek-t/clean_storage_shut…
Browse files Browse the repository at this point in the history
…down

Cleanup rest storage resources on shutdown
  • Loading branch information
k8s-ci-robot authored May 4, 2022
2 parents 7539894 + 73da6d1 commit cc2807c
Show file tree
Hide file tree
Showing 55 changed files with 447 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cmd/kube-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func Run(completeOptions completedServerRunOptions, stopCh <-chan struct{}) erro

klog.InfoS("Golang settings", "GOGC", os.Getenv("GOGC"), "GOMAXPROCS", os.Getenv("GOMAXPROCS"), "GOTRACEBACK", os.Getenv("GOTRACEBACK"))

server, err := CreateServerChain(completeOptions, stopCh)
server, err := CreateServerChain(completeOptions)
if err != nil {
return err
}
Expand All @@ -173,7 +173,7 @@ func Run(completeOptions completedServerRunOptions, stopCh <-chan struct{}) erro
}

// CreateServerChain creates the apiservers connected via delegation.
func CreateServerChain(completedOptions completedServerRunOptions, stopCh <-chan struct{}) (*aggregatorapiserver.APIAggregator, error) {
func CreateServerChain(completedOptions completedServerRunOptions) (*aggregatorapiserver.APIAggregator, error) {
kubeAPIServerConfig, serviceResolver, pluginInitializer, err := CreateKubeAPIServerConfig(completedOptions)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/kube-apiserver/app/testing/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo

t.Logf("runtime-config=%v", completedOptions.APIEnablement.RuntimeConfig)
t.Logf("Starting kube-apiserver on port %d...", s.SecureServing.BindPort)
server, err := app.CreateServerChain(completedOptions, stopCh)
server, err := app.CreateServerChain(completedOptions)
if err != nil {
return result, fmt.Errorf("failed to create server chain: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/apps/daemonset/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions pkg/registry/apps/deployment/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions pkg/registry/apps/replicaset/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions pkg/registry/apps/statefulset/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/authentication/tokenreview/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/authorization/localsubjectaccessreview/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/authorization/selfsubjectaccessreview/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/authorization/selfsubjectrulesreview/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/authorization/subjectaccessreview/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/batch/cronjob/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/batch/job/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions pkg/registry/certificates/certificates/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/componentstatus/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/registry/core/namespace/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/node/rest/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/node/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/persistentvolume/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/persistentvolumeclaim/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/core/pod/rest/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit cc2807c

Please sign in to comment.