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

fix: address nolint contextcheck #1826

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 6 additions & 9 deletions mem/mem_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
result := &VirtualMemoryStat{}

zoneName, err := zoneName() //nolint:contextcheck //FIXME
zoneName, err := zoneName(ctx)
if err != nil {
return nil, err
}

if zoneName == "global" {
capacity, err := globalZoneMemoryCapacity() //nolint:contextcheck //FIXME
capacity, err := globalZoneMemoryCapacity(ctx)
if err != nil {
return nil, err
}
Expand All @@ -44,7 +44,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
result.Free = freemem
result.Used = result.Total - result.Free
} else {
capacity, err := nonGlobalZoneMemoryCapacity() //nolint:contextcheck //FIXME
capacity, err := nonGlobalZoneMemoryCapacity(ctx)
if err != nil {
return nil, err
}
Expand All @@ -62,8 +62,7 @@ func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
return nil, common.ErrNotImplementedError
}

func zoneName() (string, error) {
ctx := context.Background()
func zoneName(ctx context.Context) (string, error) {
out, err := invoke.CommandWithContext(ctx, "zonename")
if err != nil {
return "", err
Expand All @@ -74,8 +73,7 @@ func zoneName() (string, error) {

var globalZoneMemoryCapacityMatch = regexp.MustCompile(`[Mm]emory size: (\d+) Megabytes`)

func globalZoneMemoryCapacity() (uint64, error) {
ctx := context.Background()
func globalZoneMemoryCapacity(ctx context.Context) (uint64, error) {
out, err := invoke.CommandWithContext(ctx, "prtconf")
if err != nil {
return 0, err
Expand Down Expand Up @@ -115,8 +113,7 @@ func globalZoneFreeMemory(ctx context.Context) (uint64, error) {

var kstatMatch = regexp.MustCompile(`(\S+)\s+(\S*)`)

func nonGlobalZoneMemoryCapacity() (uint64, error) {
ctx := context.Background()
func nonGlobalZoneMemoryCapacity(ctx context.Context) (uint64, error) {
out, err := invoke.CommandWithContext(ctx, "kstat", "-p", "-c", "zone_memory_cap", "memory_cap:*:*:physcap")
if err != nil {
return 0, err
Expand Down