File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,7 @@ func (a *HostAgent) Run(ctx context.Context) error {
288
288
}
289
289
a .emitEvent (ctx , exitingEv )
290
290
}()
291
+ adjustNofileRlimit ()
291
292
292
293
firstUsernetIndex := limayaml .FirstUsernetIndex (a .y )
293
294
if firstUsernetIndex == - 1 && * a .y .HostResolver .Enabled {
Original file line number Diff line number Diff line change
1
+ //go:build !windows
2
+
3
+ package hostagent
4
+
5
+ import (
6
+ "syscall"
7
+
8
+ "github.com/sirupsen/logrus"
9
+ )
10
+
11
+ // Default nofile limit is too low on some system.
12
+ // For example in the macOS standard terminal is 256.
13
+ // It means that there are only ~240 connections available from the host to the vm.
14
+ // That function increases the nofile limit for child processes, especially the ssh process
15
+ //
16
+ // More about limits in go: https://go.dev/issue/46279
17
+ func adjustNofileRlimit () {
18
+ var limit syscall.Rlimit
19
+ if err := syscall .Getrlimit (syscall .RLIMIT_NOFILE , & limit ); err != nil {
20
+ logrus .WithError (err ).Debug ("failed to get RLIMIT_NOFILE" )
21
+ } else if limit .Cur != limit .Max {
22
+ limit .Cur = limit .Max
23
+ err = syscall .Setrlimit (syscall .RLIMIT_NOFILE , & limit )
24
+ if err != nil {
25
+ logrus .WithError (err ).Debugf ("failed to set RLIMIT_NOFILE (%+v)" , limit )
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ //go:build windows
2
+
3
+ package hostagent
4
+
5
+ func adjustNofileRlimit () {}
You can’t perform that action at this time.
0 commit comments