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

Fix issue with parsing implied volumes #2290

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions pkg/apis/internal.acorn.io/v1/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"

"github.com/acorn-io/aml/pkg/value"
"github.com/acorn-io/baaah/pkg/typed"
"github.com/google/shlex"
"k8s.io/apimachinery/pkg/api/resource"
)
Expand Down Expand Up @@ -310,7 +311,9 @@ func impliedSecretsForContainer(app *AppSpec, container Container) {
}

func impliedVolumesForContainer(app *AppSpec, containerName, sideCarName string, container Container) error {
for path, mount := range container.Dirs {
for _, entry := range typed.Sorted(container.Dirs) {
path, mount := entry.Key, entry.Value

if mount.ContextDir != "" || mount.Secret.Name != "" {
continue
}
Expand All @@ -325,8 +328,16 @@ func impliedVolumesForContainer(app *AppSpec, containerName, sideCarName string,
if existing, ok := app.Volumes[mount.Volume]; ok {
existingSize, err := resource.ParseQuantity((string)(existing.Size))
if err != nil {
// ignore error
continue
// If the existing.Size is empty, then the volume is handing off the defaulting logic
// to the the calling layer. If a volume is already defined and in this situation,
// then we should ignore the error and let any incoming volume mounts override it by
// setting the existingSize variable to 0.
if existing.Size == "" {
existingSize = *resource.NewQuantity(0, resource.BinarySI)
} else {
// ignore error
continue
}
}
if v.Size != "" {
vSize, err := resource.ParseQuantity((string)(v.Size))
Expand Down