Skip to content

Commit

Permalink
Skip ISO images in unified storage quota validator
Browse files Browse the repository at this point in the history
  • Loading branch information
dilyar85 committed Dec 20, 2024
1 parent cfbec22 commit 559b04c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"))}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 559b04c

Please sign in to comment.