Skip to content

Commit 85d4210

Browse files
committed
Add no_cgroup configuration for containerized EFC
1 parent 0a6bdf5 commit 85d4210

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

pkg/mounter/proxy/server/alinas/driver.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ func addAutoFallbackNFSMountOptions(mountOptions []string) []string {
9292
}
9393
}
9494
}
95-
if isEFC && !isVSC {
96-
mountOptions = append(mountOptions, "auto_fallback_nfs")
95+
if isEFC {
96+
mountOptions = append(mountOptions, "no_add_cgroup")
97+
if !isVSC {
98+
mountOptions = append(mountOptions, "auto_fallback_nfs")
99+
}
97100
}
98101
return mountOptions
99102
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package alinas
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestAddAutoFallbackNFSMountOptions(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
inputOptions []string
13+
expected []string
14+
}{
15+
{
16+
name: "Empty options",
17+
inputOptions: []string{},
18+
expected: []string{},
19+
},
20+
{
21+
name: "EFC without VSC should add both no_add_cgroup and auto_fallback_nfs",
22+
inputOptions: []string{"efc"},
23+
expected: []string{"efc", "no_add_cgroup", "auto_fallback_nfs"},
24+
},
25+
{
26+
name: "EFC with VSC should only add no_add_cgroup",
27+
inputOptions: []string{"efc", "net=vsc"},
28+
expected: []string{"efc", "net=vsc", "no_add_cgroup"},
29+
},
30+
{
31+
name: "EFC with non-VSC net option should add both options",
32+
inputOptions: []string{"efc", "net=other"},
33+
expected: []string{"efc", "net=other", "no_add_cgroup", "auto_fallback_nfs"},
34+
},
35+
{
36+
name: "Multiple options with EFC but no VSC",
37+
inputOptions: []string{"rw", "efc", "hard"},
38+
expected: []string{"rw", "efc", "hard", "no_add_cgroup", "auto_fallback_nfs"},
39+
},
40+
{
41+
name: "Multiple options with EFC and VSC",
42+
inputOptions: []string{"rw", "efc", "net=vsc", "hard"},
43+
expected: []string{"rw", "efc", "net=vsc", "hard", "no_add_cgroup"},
44+
},
45+
{
46+
name: "No EFC should not add any options",
47+
inputOptions: []string{"rw", "hard"},
48+
expected: []string{"rw", "hard"},
49+
},
50+
{
51+
name: "Comma-separated options with EFC but no VSC",
52+
inputOptions: []string{"rw,efc,hard"},
53+
expected: []string{"rw,efc,hard", "no_add_cgroup", "auto_fallback_nfs"},
54+
},
55+
{
56+
name: "Comma-separated options with EFC and VSC",
57+
inputOptions: []string{"rw,efc,net=vsc,hard"},
58+
expected: []string{"rw,efc,net=vsc,hard", "no_add_cgroup"},
59+
},
60+
{
61+
name: "Empty option string in slice",
62+
inputOptions: []string{"", "efc"},
63+
expected: []string{"", "efc", "no_add_cgroup", "auto_fallback_nfs"},
64+
},
65+
}
66+
67+
for _, tt := range tests {
68+
t.Run(tt.name, func(t *testing.T) {
69+
result := addAutoFallbackNFSMountOptions(tt.inputOptions)
70+
assert.Equal(t, tt.expected, result)
71+
})
72+
}
73+
}

0 commit comments

Comments
 (0)