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

Commit 69b228e

Browse files
committed
Use appInstance.Status.Defaults.VolumeSize when defaulting pvc size
Signed-off-by: tylerslaton <mtslaton1@gmail.com>
1 parent 2ebe1d4 commit 69b228e

File tree

7 files changed

+20
-7
lines changed

7 files changed

+20
-7
lines changed

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func merge(oldConfig, newConfig *apiv1.Config) *apiv1.Config {
377377
if newConfig.IngressControllerNamespace != nil {
378378
mergedConfig.IngressControllerNamespace = newConfig.IngressControllerNamespace
379379
}
380-
if newConfig.VolumeSizeDefault == "" {
380+
if newConfig.VolumeSizeDefault != "" {
381381
mergedConfig.VolumeSizeDefault = newConfig.VolumeSizeDefault
382382
}
383383
if newConfig.AWSIdentityProviderARN != nil {

pkg/controller/appdefinition/testdata/deployspec/filter-user-labels/expected.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ status:
407407
status: "True"
408408
success: true
409409
type: defined
410-
defaults: {}
410+
defaults:
411+
volumeSize: 10G
411412
namespace: app-created-namespace
412413
staged:
413414
appImage:

pkg/controller/appdefinition/testdata/deployspec/labels/expected.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ status:
415415
status: "True"
416416
success: true
417417
type: defined
418-
defaults: {}
418+
defaults:
419+
volumeSize: 10G
419420
namespace: app-created-namespace
420421
staged:
421422
appImage:

pkg/controller/appdefinition/testdata/deployspec/no-user-labels/expected.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ status:
285285
status: "True"
286286
success: true
287287
type: defined
288-
defaults: {}
288+
defaults:
289+
volumeSize: 10G
289290
namespace: app-created-namespace
290291
staged:
291292
appImage:

pkg/controller/appdefinition/testdata/volumes/empty/expected.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ status:
166166
status: "True"
167167
success: true
168168
type: defined
169-
defaults: {}
169+
defaults:
170+
volumeSize: 10G
170171
namespace: app-created-namespace
171172
staged:
172173
appImage:

pkg/controller/appdefinition/testdata/volumes/no-default-class/expected.golden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ status:
166166
status: "True"
167167
success: true
168168
type: defined
169-
defaults: {}
169+
defaults:
170+
volumeSize: 10G
170171
namespace: app-created-namespace
171172
staged:
172173
appImage:

pkg/controller/appdefinition/volume.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/acorn-io/runtime/pkg/secrets"
1717
"github.com/acorn-io/runtime/pkg/volume"
1818
name2 "github.com/rancher/wrangler/pkg/name"
19+
"github.com/sirupsen/logrus"
1920
corev1 "k8s.io/api/core/v1"
2021
apierrors "k8s.io/apimachinery/pkg/api/errors"
2122
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -200,7 +201,14 @@ func toPVCs(req router.Request, appInstance *v1.AppInstance) (result []kclient.O
200201
pvc.Spec.VolumeName = pvName
201202

202203
if volumeRequest.Size == "" {
203-
pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *v1.DefaultSize
204+
// This shouldn't happen because we set a default in the status. However
205+
// if this situation does occur, we'll just use the default size for runtime
206+
// and log it at the debug level. As an example, our unit tests hit this case.
207+
if appInstance.Status.Defaults.VolumeSize == nil {
208+
logrus.Debugf("no default volume size found in status, using static default size of %v", v1.DefaultSize)
209+
appInstance.Status.Defaults.VolumeSize = v1.DefaultSize
210+
}
211+
pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *appInstance.Status.Defaults.VolumeSize
204212
} else {
205213
pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *v1.MustParseResourceQuantity(volumeRequest.Size)
206214
}

0 commit comments

Comments
 (0)