Documentation ¶
Index ¶
- Constants
- type HRQ
- type HRQEnqueuer
- type HierarchicalResourceQuotaReconciler
- func (r *HierarchicalResourceQuotaReconciler) Enqueue(log logr.Logger, reason, ns, nm string)
- func (r *HierarchicalResourceQuotaReconciler) OnChangeNamespace(log logr.Logger, ns *forest.Namespace)
- func (r *HierarchicalResourceQuotaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *HierarchicalResourceQuotaReconciler) SetupWithManager(mgr ctrl.Manager) error
- type RQEnqueuer
- type ResourceQuotaReconciler
- func (r *ResourceQuotaReconciler) EnqueueSubtree(log logr.Logger, nsnm string)
- func (r *ResourceQuotaReconciler) OnChangeNamespace(log logr.Logger, ns *forest.Namespace)
- func (r *ResourceQuotaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *ResourceQuotaReconciler) SetupWithManager(mgr ctrl.Manager) error
- type ResourceQuotaStatus
Constants ¶
const ( // ResourceQuotasStatusServingPath is where the validator will run. Must be kept in sync with the // kubebuilder markers below. ResourceQuotasStatusServingPath = "/validate-hnc-x-k8s-io-v1alpha2-resourcequotasstatus" ResourceQuotaAdmissionControllerUsername = "system:apiserver" )
const ( // HRQServingPath is where the validator will run. Must be kept in sync with the // kubebuilder markers below. HRQServingPath = "/validate-hnc-x-k8s-io-v1alpha2-hrq" )
const ( // The name of the ResourceQuota object created by the // ResourceQuotaReconciler in a namespace. ResourceQuotaSingleton = "hrq." + api.MetaGroup )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HRQEnqueuer ¶
type HRQEnqueuer interface { // Enqueue enqueues HierarchicalResourceQuota objects of the given names in // the give namespaces. Enqueue(log logr.Logger, reason, nsnm, qnm string) }
HRQEnqueuer enqueues HierarchicalResourceQuota objects. HierarchicalResourceQuotaReconciler implements the interface so that it can be called to update HierarchicalResourceQuota objects.
type HierarchicalResourceQuotaReconciler ¶
type HierarchicalResourceQuotaReconciler struct { client.Client Log logr.Logger // Forest is the in-memory data structure that is shared with all other reconcilers. Forest *forest.Forest // RQEnqueuer enqueues ResourceQuota objects when HierarchicalResourceQuota // objects change. RQR RQEnqueuer // contains filtered or unexported fields }
HierarchicalResourceQuotaReconciler reconciles a HierarchicalResourceQuota object. It has three key purposes:
- Update the in-memory forest with all the limits defined in the HRQ spec, so that they can be used during admission control to reject requests.
- Write all the usages from the in-memory forest back to the HRQ status.
- Enqueue all relevant RQs when an HRQ changes.
func (*HierarchicalResourceQuotaReconciler) Enqueue ¶
func (r *HierarchicalResourceQuotaReconciler) Enqueue(log logr.Logger, reason, ns, nm string)
Enqueue enqueues a specific HierarchicalResourceQuota object to trigger the reconciliation of the object for a given reason. This occurs in a goroutine so the caller doesn't block; since the reconciler is never garbage-collected, this is safe.
It's called by the RQ reconciler when an RQ's status has changed, which might indicate that the HRQ's status (specifically its usage) needs to be changed as well.
func (*HierarchicalResourceQuotaReconciler) OnChangeNamespace ¶
func (r *HierarchicalResourceQuotaReconciler) OnChangeNamespace(log logr.Logger, ns *forest.Namespace)
OnChangeNamespace enqueues all HRQ objects in the subtree for later reconciliation. This is needed so that the HRQ objects are enqueued for reconciliation when there is a change in the tree hierarchy which affects the subtree usage of the HRQ objects. This occurs in a goroutine so the caller doesn't block; since the reconciler is never garbage-collected, this is safe.
func (*HierarchicalResourceQuotaReconciler) SetupWithManager ¶
func (r *HierarchicalResourceQuotaReconciler) SetupWithManager(mgr ctrl.Manager) error
type RQEnqueuer ¶
type RQEnqueuer interface { // EnqueueSubtree enqueues ResourceQuota objects in a namespace and its descendants. It's used by // the HRQ reconciler when an HRQ has been updated and all the RQs that implement it need to be // updated too. EnqueueSubtree(log logr.Logger, nsnm string) }
RQEnqueuer enqueues ResourceQuota objects in a namespace and its descendants. ResourceQuotaReconciler implements the interface so that it can be called by the HierarchicalResourceQuotaReconciler when HierarchicalResourceQuota objects change.
type ResourceQuotaReconciler ¶
type ResourceQuotaReconciler struct { client.Client Log logr.Logger // Forest is the in-memory data structure that is shared with all other reconcilers. Forest *forest.Forest HRQR HRQEnqueuer // contains filtered or unexported fields }
ResourceQuotaReconciler reconciles singleton RQ per namespace, which represents the HRQ in this and any ancestor namespaces. The reconciler is called on two occasions:
- The HRQ in this or an ancestor namespace has changed. This can either be because an HRQ has been modified (in which case, the HRQR will call EnqueueSubtree) or because the ancestors of this namespace have changed (in which case, the NSR will call OnChangeNamespace). Either way, this will typically result in the limits being updated.
- The K8s apiserver has modified the usage of this RQ, typically in response to a resource being _released_ but it's also possible to observe increasing usage here as well (see go/hnc-hrq for details). In such cases, we basically just need to enqueue the HRQs in all ancestor namespaces so that they can update their usages as well.
func (*ResourceQuotaReconciler) EnqueueSubtree ¶
func (r *ResourceQuotaReconciler) EnqueueSubtree(log logr.Logger, nsnm string)
EnqueueSubtree enqueues ResourceQuota objects of the given namespace and its descendants.
The method is robust against race conditions. The method holds the forest lock so that the in-memory forest (specifically the descendants of the namespace that we record in-memory) cannot be changed while enqueueing ResourceQuota objects in the namespace and its descendants.
If a new namespace becomes a descendant just after we acquire the lock, the ResourceQuota object in the new namespace will be enqueued by the NamespaceReconciler, instead of the ResourceQuotaReconciler. By contrast, if a namespace is *removed* as a descendant, we'll still call the reconciler but it will have no effect (reconcilers can safely be called multiple times, even if the object has been deleted).
func (*ResourceQuotaReconciler) OnChangeNamespace ¶
func (r *ResourceQuotaReconciler) OnChangeNamespace(log logr.Logger, ns *forest.Namespace)
OnChangeNamespace enqueues the singleton in a specific namespace to trigger the reconciliation of the singleton for a given reason . This occurs in a goroutine so the caller doesn't block; since the reconciler is never garbage-collected, this is safe.
func (*ResourceQuotaReconciler) SetupWithManager ¶
func (r *ResourceQuotaReconciler) SetupWithManager(mgr ctrl.Manager) error
type ResourceQuotaStatus ¶
type ResourceQuotaStatus struct { Log logr.Logger Forest *forest.Forest // contains filtered or unexported fields }
func (*ResourceQuotaStatus) InjectClient ¶
func (r *ResourceQuotaStatus) InjectClient(c client.Client) error
func (*ResourceQuotaStatus) InjectDecoder ¶
func (r *ResourceQuotaStatus) InjectDecoder(d *admission.Decoder) error