mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
hold namespaces briefly before processing deletion
This commit is contained in:
parent
545f749a0d
commit
79ec8ae654
@ -35,6 +35,16 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// namespaceDeletionGracePeriod is the time period to wait before processing a received namespace event.
|
||||||
|
// This allows time for the following to occur:
|
||||||
|
// * lifecycle admission plugins on HA apiservers to also observe a namespace
|
||||||
|
// deletion and prevent new objects from being created in the terminating namespace
|
||||||
|
// * non-leader etcd servers to observe last-minute object creations in a namespace
|
||||||
|
// so this controller's cleanup can actually clean up all objects
|
||||||
|
namespaceDeletionGracePeriod = 5 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
// NamespaceController is responsible for performing actions dependent upon a namespace phase
|
// NamespaceController is responsible for performing actions dependent upon a namespace phase
|
||||||
type NamespaceController struct {
|
type NamespaceController struct {
|
||||||
// client that purges namespace content, must have list/delete privileges on all content
|
// client that purges namespace content, must have list/delete privileges on all content
|
||||||
@ -132,7 +142,9 @@ func (nm *NamespaceController) enqueueNamespace(obj interface{}) {
|
|||||||
glog.Errorf("Couldn't get key for object %+v: %v", obj, err)
|
glog.Errorf("Couldn't get key for object %+v: %v", obj, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nm.queue.Add(key)
|
// delay processing namespace events to allow HA api servers to observe namespace deletion,
|
||||||
|
// and HA etcd servers to observe last minute object creations inside the namespace
|
||||||
|
nm.queue.AddAfter(key, namespaceDeletionGracePeriod)
|
||||||
}
|
}
|
||||||
|
|
||||||
// worker processes the queue of namespace objects.
|
// worker processes the queue of namespace objects.
|
||||||
|
Loading…
Reference in New Issue
Block a user