diff --git a/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator.go b/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator.go index 5119dd451..938c9bec9 100644 --- a/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator.go +++ b/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator.go @@ -178,6 +178,11 @@ func (h *RequestedCapacityHandler) HandleCreate(ctx *pkgctx.WebhookRequestContex return CapacityResponse{Response: webhook.Errored(http.StatusBadRequest, fmt.Errorf("unsupported image kind %s", vm.Spec.Image.Kind))} } + // Skip ISO images as they don't have boot disks. + if imageStatus.Type == "ISO" { + return CapacityResponse{Response: webhook.Allowed("")} + } + if len(imageStatus.Disks) < 1 || imageStatus.Disks[0].Capacity == nil { return CapacityResponse{Response: webhook.Errored(http.StatusNotFound, errors.New("boot disk not found in image status"))} } diff --git a/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator_unit_test.go b/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator_unit_test.go index 391fcad89..367473b10 100644 --- a/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator_unit_test.go +++ b/webhooks/unifiedstoragequota/validation/unifiedstoragequota_validator_unit_test.go @@ -682,6 +682,17 @@ func testRequestedCapacityHandlerHandleCreate() { }) }) + When("image type is ISO", func() { + BeforeEach(func() { + vmi.Status.Type = "ISO" + }) + + It("should write StatusOK code and an empty RequestedCapacity to the response", func() { + Expect(resp.Allowed).To(BeTrue()) + Expect(int(resp.Result.Code)).To(Equal(http.StatusOK)) + }) + }) + When("disks section is empty in image status", func() { It("should write StatusNotFound code and an empty RequestedCapacity to the response", func() { Expect(resp.Allowed).To(BeFalse())