Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
fix: Use 'cur' ulimit in calculation, not 'max' (#399)
Browse files Browse the repository at this point in the history
The 'cur' ulimit is the actual limit on num-open-files enforced by the kernel.
  • Loading branch information
shimonp21 authored Jul 3, 2022
1 parent 8d178eb commit 1acc3de
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions helpers/limit/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ type Rlimit struct {
func GetMaxGoRoutines() uint64 {
limit := calculateGoRoutines(getMemory())
ulimit, err := GetUlimit()
if err != nil || ulimit.Max == 0 {
if err != nil || ulimit.Cur == 0 {
return limit
}
if ulimit.Max > limit {
if ulimit.Cur > limit {
return limit
}
return ulimit.Max
return ulimit.Cur
}

// DiagnoseLimits verifies if user should increase ulimit or max file descriptors to improve number of expected
Expand All @@ -48,11 +48,11 @@ func DiagnoseLimits() (diags diag.Diagnostics) {
diag.WithDetails("available descriptor capacity is %d want %d to run optimally, consider increasing max file descriptors on machine.", fds, want)))
}
ulimit, err := GetUlimit()
if err == nil && ulimit.Max < want {
if err == nil && ulimit.Cur < want {
diags = diags.Add(diag.NewBaseError(errors.New("ulimit available for CloudQuery process lower than expected"),
diag.USER,
diag.WithSeverity(diag.WARNING),
diag.WithDetails("set ulimit capacity is %d want %d to run optimally, consider increasing ulimit on this machine.", ulimit.Max, want)))
diag.WithDetails("set ulimit capacity is %d want %d to run optimally, consider increasing ulimit on this machine.", ulimit.Cur, want)))
}
return diags
}
Expand Down

0 comments on commit 1acc3de

Please sign in to comment.