Skip to content

Commit 5eff4bb

Browse files
fix: Implement OS specific mechanism to remove memory lock for plugins (#791)
# Description Add OS specific implementation for removing memory lock on Linux/Windows nodes. ## Related Issue Fixes #790 ## Checklist - [x] I have read the [contributing documentation](https://retina.sh/docs/contributing). - [x] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [x] I have correctly attributed the author(s) of the code. - [x] I have tested the changes locally. - [x] I have followed the project's style guidelines. - [x] I have updated the documentation, if necessary. - [x] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed - Can build/run manually - Pipelines ## Additional Notes Add any additional notes or context about the pull request here. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project. Signed-off-by: Anubhab Majumdar <[email protected]>
1 parent cbe28cf commit 5eff4bb

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

cmd/legacy/daemon.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
crmgr "sigs.k8s.io/controller-runtime/pkg/manager"
2626
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
2727

28-
"github.com/cilium/ebpf/rlimit"
2928
"github.com/go-logr/zapr"
3029
retinav1alpha1 "github.com/microsoft/retina/crd/api/v1alpha1"
3130
"github.com/microsoft/retina/internal/buildinfo"
@@ -134,7 +133,9 @@ func (d *Daemon) Start() error {
134133
mainLogger := zl.Named("main").Sugar()
135134

136135
// Allow the current process to lock memory for eBPF resources.
137-
if err = rlimit.RemoveMemlock(); err != nil {
136+
// OS specific implementation.
137+
// This is a no-op on Windows.
138+
if err = d.RemoveMemlock(); err != nil {
138139
mainLogger.Fatal("failed to remove memlock", zap.Error(err))
139140
}
140141

cmd/legacy/daemon_linux.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package legacy
2+
3+
import "github.com/cilium/ebpf/rlimit"
4+
5+
func (d *Daemon) RemoveMemlock() error {
6+
return rlimit.RemoveMemlock()
7+
}

cmd/legacy/daemon_windows.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package legacy
2+
3+
func (d *Daemon) RemoveMemlock() error {
4+
// This function is a no-op on Windows.
5+
return nil
6+
}

0 commit comments

Comments
 (0)