mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #46501 from sttts/sttts-crd-finalizer-sync
Automatic merge from submit-queue (batch tested with PRs 46501, 45944, 46473) apiextensions: fix missing storage on CRD delete without previous CR access Create CR storage on demand when needed from CRD finalizer controller. /cc @nikhita
This commit is contained in:
commit
97fd065251
@ -247,13 +247,9 @@ func (r *crdHandler) removeDeadStorage() {
|
|||||||
|
|
||||||
// GetCustomResourceListerCollectionDeleter returns the ListerCollectionDeleter for
|
// GetCustomResourceListerCollectionDeleter returns the ListerCollectionDeleter for
|
||||||
// the given uid, or nil if one does not exist.
|
// the given uid, or nil if one does not exist.
|
||||||
func (r *crdHandler) GetCustomResourceListerCollectionDeleter(uid types.UID) finalizer.ListerCollectionDeleter {
|
func (r *crdHandler) GetCustomResourceListerCollectionDeleter(crd *apiextensions.CustomResourceDefinition) finalizer.ListerCollectionDeleter {
|
||||||
storageMap := r.customStorage.Load().(crdStorageMap)
|
info := r.getServingInfoFor(crd)
|
||||||
ret, ok := storageMap[uid]
|
return info.storage
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return ret.storage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *crdHandler) getServingInfoFor(crd *apiextensions.CustomResourceDefinition) *crdInfo {
|
func (r *crdHandler) getServingInfoFor(crd *apiextensions.CustomResourceDefinition) *crdInfo {
|
||||||
|
@ -17,7 +17,6 @@ go_library(
|
|||||||
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/conversion"
|
"k8s.io/apimachinery/pkg/conversion"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
@ -69,7 +68,7 @@ type ListerCollectionDeleter interface {
|
|||||||
type CRClientGetter interface {
|
type CRClientGetter interface {
|
||||||
// GetCustomResourceListerCollectionDeleter gets the ListerCollectionDeleter for the given CRD
|
// GetCustomResourceListerCollectionDeleter gets the ListerCollectionDeleter for the given CRD
|
||||||
// UID.
|
// UID.
|
||||||
GetCustomResourceListerCollectionDeleter(uid types.UID) ListerCollectionDeleter
|
GetCustomResourceListerCollectionDeleter(crd *apiextensions.CustomResourceDefinition) ListerCollectionDeleter
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCRDFinalizer creates a new CRDFinalizer.
|
// NewCRDFinalizer creates a new CRDFinalizer.
|
||||||
@ -162,7 +161,7 @@ func (c *CRDFinalizer) deleteInstances(crd *apiextensions.CustomResourceDefiniti
|
|||||||
// Now we can start deleting items. While it would be ideal to use a REST API client, doing so
|
// Now we can start deleting items. While it would be ideal to use a REST API client, doing so
|
||||||
// could incorrectly delete a ThirdPartyResource with the same URL as the CustomResource, so we go
|
// could incorrectly delete a ThirdPartyResource with the same URL as the CustomResource, so we go
|
||||||
// directly to the storage instead. Since we control the storage, we know that delete collection works.
|
// directly to the storage instead. Since we control the storage, we know that delete collection works.
|
||||||
crClient := c.crClientGetter.GetCustomResourceListerCollectionDeleter(crd.UID)
|
crClient := c.crClientGetter.GetCustomResourceListerCollectionDeleter(crd)
|
||||||
if crClient == nil {
|
if crClient == nil {
|
||||||
err := fmt.Errorf("unable to find a custom resource client for %s.%s", crd.Status.AcceptedNames.Plural, crd.Spec.Group)
|
err := fmt.Errorf("unable to find a custom resource client for %s.%s", crd.Status.AcceptedNames.Plural, crd.Spec.Group)
|
||||||
return apiextensions.CustomResourceDefinitionCondition{
|
return apiextensions.CustomResourceDefinitionCondition{
|
||||||
|
Loading…
Reference in New Issue
Block a user