fix(secrets): Make "insufficient lockable memory" warning work on BSDs (#16682)

Co-authored-by: Stephan Gabert <stepga@nirgendwo.eu>
This commit is contained in:
stepga 2025-03-24 15:08:01 +01:00 committed by GitHub
parent 5caa5f6791
commit 55f471aa32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 2 deletions

View File

@ -4,6 +4,7 @@ package main
import (
"log"
"runtime"
"syscall"
)
@ -20,8 +21,16 @@ func (t *Telegraf) Run() error {
}
func getLockedMemoryLimit() uint64 {
var rLimitMemlock int
switch runtime.GOOS {
case "dragonfly", "freebsd", "netbsd", "openbsd":
// From https://cgit.freebsd.org/src/tree/sys/sys/resource.h#n107
rLimitMemlock = 6
default:
// From https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/resource.h#L35
const rLimitMemlock = 8
rLimitMemlock = 8
}
var limit syscall.Rlimit
if err := syscall.Getrlimit(rLimitMemlock, &limit); err != nil {