Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supress warning for memory calculator #180

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
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