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

Commit

Permalink
Undo unneeded changes
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville committed Dec 14, 2023
1 parent 6a98bca commit f375bd5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ spec:
computeClass:
left: sample-compute-class
status:
resolvedOfferings:
containers:
left:
memory: 1048576 # 1Mi
defaults:
memory:
left: 1048576 # 1Mi
namespace: app-created-namespace
appImage:
id: test
Expand All @@ -35,7 +34,7 @@ status:
dockerfile: "Dockerfile"
context: "."
conditions:
- type: resolved-offerings
- type: defaults
reason: Success
status: "True"
success: true
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/quota/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func addStorage(req router.Request, appInstance *v1.AppInstance, quotaRequest *a
case "0":
continue
case "":
sizeQuantity = resolvedVolumeSize(appInstance, name)
sizeQuantity = defaultVolumeSize(appInstance, name)
default:
parsedQuantity, err := resource.ParseQuantity(string(size))
if err != nil {
Expand All @@ -202,17 +202,17 @@ func addStorage(req router.Request, appInstance *v1.AppInstance, quotaRequest *a
return nil
}

// resolvedVolumeSize determines the size of the specified volume. If the volume has a resolved size set
// on the status.Defaults.Volumes, it uses that. Otherwise, it uses the default size in the v1 package.
func resolvedVolumeSize(appInstance *v1.AppInstance, name string) resource.Quantity {
// defaultVolumeSize determines the default size of the specified volume. If the volume has a default size set
// on the status.Defaults.Volumes, it uses that. Otherwise, it uses the default size set on the status.Defaults.VolumeSize.
func defaultVolumeSize(appInstance *v1.AppInstance, name string) resource.Quantity {
// Use the v1.DefaultSize if the appInstance doesn't have a default size set on the status.
result := *v1.DefaultSize // Safe to dereference because it is statically set in the v1 package.

// If the volume has a default size set on status.Defaults.Volumes, use that.
if resolvedVolume, set := appInstance.Status.Defaults.Volumes[name]; set {
if defaultVolume, set := appInstance.Status.Defaults.Volumes[name]; set {
// We do not expect this to ever fail because VolumeClasses have their sizes validated. However,
// if it does fail, we'll just use the default size instead.
if parsedQuantity, err := resource.ParseQuantity(string(resolvedVolume.Size)); err == nil {
if parsedQuantity, err := resource.ParseQuantity(string(defaultVolume.Size)); err == nil {
result = parsedQuantity
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ spec:
computeClass:
left: sample-compute-class
status:
resolvedOfferings:
containers:
left:
memory: 1048576 # 1Mi
defaults:
memory:
left: 1048576 # 1Mi
namespace: app-created-namespace
appImage:
id: test
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/registry/apigroups/acorn/apps/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestCannotChangeAppRegion(t *testing.T) {
name: "Cannot change region from calculated default",
oldApp: apiv1.App{
Status: internalv1.AppInstanceStatus{
ResolvedOfferings: internalv1.ResolvedOfferings{
Defaults: internalv1.Defaults{
Region: "old-acorn-test-region",
},
},
Expand Down

0 comments on commit f375bd5

Please sign in to comment.