mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-19 04:26:45 +00:00
feat(ux): namespace oncrete hook to check namespace exsistence
Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>
This commit is contained in:
@@ -38,6 +38,14 @@ func (r *quotaHandler) OnCreate(client client.Client, decoder *admission.Decoder
|
||||
}
|
||||
|
||||
if tnt.IsFull() {
|
||||
// Checking if the Namespace already exists.
|
||||
// If this is the case, no need to return the quota exceeded error:
|
||||
// the Kubernetes API Server will return an AlreadyExists error,
|
||||
// adhering more to the native Kubernetes experience.
|
||||
if err := client.Get(ctx, types.NamespacedName{Name: ns.Name}, &corev1.Namespace{}); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
recorder.Eventf(tnt, corev1.EventTypeWarning, "NamespaceQuotaExceded", "Namespace %s cannot be attached, quota exceeded for the current Tenant", ns.GetName())
|
||||
|
||||
response := admission.Denied(NewNamespaceQuotaExceededError().Error())
|
||||
|
||||
Reference in New Issue
Block a user