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: Implement OS specific mechanism to remove memory lock for plugins #791

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
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
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
}
Loading