Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Fix an issue with default VolmeStorage not being accounted for in Quo…
Browse files Browse the repository at this point in the history
…taRequests

Signed-off-by: tylerslaton <[email protected]>
  • Loading branch information
tylerslaton committed Oct 12, 2023
1 parent 08c68cf commit 72fbac2
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions pkg/controller/quota/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,28 @@ func addStorage(appInstance *v1.AppInstance, quotaRequest *adminv1.QuotaRequestI
size = boundSize
}

// No need to proceed if the size is empty
if size == "" || size == "0" {
// Handle three cases:
// 1. The volume's size is explicitly set to 0. This means there is nothing to count.
// 2. The volume's size is not set. This means we should assume the default size.
// 3. The volume's size is set to a specific value. This means we should use that value.
var sizeQuantity resource.Quantity
switch size {
case "0":
continue
case "":
sizeQuantity = *v1.DefaultSize // Safe to dereference because it is statically set in the v1 package.
if appInstance.Status.Defaults.VolumeSize != nil {
sizeQuantity = *appInstance.Status.Defaults.VolumeSize
}
default:
parsedQuantity, err := resource.ParseQuantity(string(size))
if err != nil {
return err
}
sizeQuantity = parsedQuantity
}

parsedSize, err := resource.ParseQuantity(string(size))
if err != nil {
return err
}
quotaRequest.Spec.Resources.VolumeStorage.Add(parsedSize)
quotaRequest.Spec.Resources.VolumeStorage.Add(sizeQuantity)
}

// Add the secrets needed to the quota request. We only parse net new secrets, not
Expand Down

0 comments on commit 72fbac2

Please sign in to comment.