Skip to content

Commit

Permalink
Calculate "volumeSize" values including SI units
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Dec 1, 2021
1 parent 04c76ad commit 3243f17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/controller/worker/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
mcmv1alpha1 "github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -188,12 +189,14 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error {
}

if nil != pool.Volume && "" != pool.Volume.Size {
volumeSize, err := worker.DiskSize(pool.Volume.Size)
volumeSizeQuantity, err := resource.ParseQuantity(pool.Volume.Size)
if err != nil {
return err
}

if volumeSize > 0 {
volumeSize, ok := volumeSizeQuantity.AsInt64()

if ok && volumeSize > 0 {
machineClassSpec["volumeSize"] = volumeSize
}
}
Expand Down

0 comments on commit 3243f17

Please sign in to comment.