Skip to content

Commit

Permalink
fix: Remove memory lock OS specific implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Anubhab Majumdar <[email protected]>
  • Loading branch information
anubhabMajumdar committed Sep 30, 2024
1 parent cbe28cf commit 782ac4e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/legacy/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
}

Expand Down
7 changes: 7 additions & 0 deletions cmd/legacy/daemon_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package legacy

import "github.com/cilium/ebpf/rlimit"

func (d *Daemon) RemoveMemlock() error {
return rlimit.RemoveMemlock()
}
6 changes: 6 additions & 0 deletions cmd/legacy/daemon_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package legacy

func (d *Daemon) RemoveMemlock() error {
// This function is a no-op on Windows.
return nil
}

0 comments on commit 782ac4e

Please sign in to comment.