Skip to content

Commit

Permalink
Merge pull request #180 from sap-contributions/memory-calculator-supp…
Browse files Browse the repository at this point in the history
…ress-warning

supress warning for memory calculator
  • Loading branch information
Daniel Mikusa authored Jun 29, 2022
2 parents dfd63a6 + 7acc3d9 commit 08e1016
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions helper/memory_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ package helper

import (
"fmt"
"github.com/mattn/go-shellwords"
"io/ioutil"
"os"
"regexp"
"strconv"
"strings"

"github.com/mattn/go-shellwords"

"github.com/paketo-buildpacks/libpak/bard"

"github.com/paketo-buildpacks/libjvm/calc"
Expand Down Expand Up @@ -199,8 +200,12 @@ func (m MemoryCalculator) getMemoryLimitFromPath(memoryLimitPath string) int64 {
if b, err := ioutil.ReadFile(memoryLimitPath); err != nil && !os.IsNotExist(err) {
m.Logger.Infof("WARNING: Unable to read %s: %s", memoryLimitPath, err)
} else if err == nil {
if size, err := calc.ParseSize(strings.TrimSpace(string(b))); err != nil {
m.Logger.Infof("WARNING: Unable to convert memory limit %q from path %q as int: %s", strings.TrimSpace(string(b)), memoryLimitPath, err)
limit := strings.TrimSpace(string(b))
if size, err := calc.ParseSize(limit); err != nil {
if limit == "max" {
return UnsetTotalMemory
}
m.Logger.Infof("WARNING: Unable to convert memory limit %q from path %q as int: %s", limit, memoryLimitPath, err)
} else {
return size.Value
}
Expand Down

0 comments on commit 08e1016

Please sign in to comment.