From 782ac4ec2a896a50b8895a764a14b21a8c0183f7 Mon Sep 17 00:00:00 2001 From: Anubhab Majumdar Date: Fri, 27 Sep 2024 19:46:15 +0000 Subject: [PATCH] fix: Remove memory lock OS specific implementation Signed-off-by: Anubhab Majumdar --- cmd/legacy/daemon.go | 5 +++-- cmd/legacy/daemon_linux.go | 7 +++++++ cmd/legacy/daemon_windows.go | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 cmd/legacy/daemon_linux.go create mode 100644 cmd/legacy/daemon_windows.go diff --git a/cmd/legacy/daemon.go b/cmd/legacy/daemon.go index 7be83edb008..491f57791ec 100644 --- a/cmd/legacy/daemon.go +++ b/cmd/legacy/daemon.go @@ -25,7 +25,6 @@ import ( crmgr "sigs.k8s.io/controller-runtime/pkg/manager" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" - "github.com/cilium/ebpf/rlimit" "github.com/go-logr/zapr" retinav1alpha1 "github.com/microsoft/retina/crd/api/v1alpha1" "github.com/microsoft/retina/internal/buildinfo" @@ -134,7 +133,9 @@ func (d *Daemon) Start() error { mainLogger := zl.Named("main").Sugar() // Allow the current process to lock memory for eBPF resources. - if err = rlimit.RemoveMemlock(); err != nil { + // OS specific implementation. + // This is a no-op on Windows. + if err = d.RemoveMemlock(); err != nil { mainLogger.Fatal("failed to remove memlock", zap.Error(err)) } diff --git a/cmd/legacy/daemon_linux.go b/cmd/legacy/daemon_linux.go new file mode 100644 index 00000000000..d565110d096 --- /dev/null +++ b/cmd/legacy/daemon_linux.go @@ -0,0 +1,7 @@ +package legacy + +import "github.com/cilium/ebpf/rlimit" + +func (d *Daemon) RemoveMemlock() error { + return rlimit.RemoveMemlock() +} diff --git a/cmd/legacy/daemon_windows.go b/cmd/legacy/daemon_windows.go new file mode 100644 index 00000000000..9e3d302bae6 --- /dev/null +++ b/cmd/legacy/daemon_windows.go @@ -0,0 +1,6 @@ +package legacy + +func (d *Daemon) RemoveMemlock() error { + // This function is a no-op on Windows. + return nil +}