fix: bypass resourepool limits (#1669)

* fix: bypass resourepool limits

Signed-off-by: Hristo Hristov <me@hhristov.info>

* fix: bypass resourepool limits

Signed-off-by: Hristo Hristov <me@hhristov.info>

---------

Signed-off-by: Hristo Hristov <me@hhristov.info>
This commit is contained in:
Hristo Hristov
2025-09-29 10:39:44 +03:00
committed by GitHub
parent 611a7eba8e
commit 4878e1ab1f
3 changed files with 25 additions and 2 deletions

View File

@@ -32,8 +32,20 @@ func (h *claimValidationHandler) OnCreate(client.Client, admission.Decoder, reco
}
}
func (h *claimValidationHandler) OnDelete(client.Client, admission.Decoder, record.EventRecorder) capsulewebhook.Func {
return func(context.Context, admission.Request) *admission.Response {
func (h *claimValidationHandler) OnDelete(_ client.Client, decoder admission.Decoder, _ record.EventRecorder) capsulewebhook.Func {
return func(_ context.Context, req admission.Request) *admission.Response {
claim := &capsulev1beta2.ResourcePoolClaim{}
if err := decoder.DecodeRaw(req.OldObject, claim); err != nil {
return utils.ErroredResponse(fmt.Errorf("failed to decode old object: %w", err))
}
if claim.IsBoundToResourcePool() {
response := admission.Denied(fmt.Sprintf("cannot delete the pool while claim is bound to a resourcepool %s", claim.Status.Pool.Name))
return &response
}
return nil
}
}