Skip to content

Commit 6eed5dc

Browse files
dhananjay-ngGouthamML
authored andcommitted
OKE-34832 - Lustre CSI Node Driver enablement
1 parent e9efc2a commit 6eed5dc

File tree

14 files changed

+830
-103
lines changed

14 files changed

+830
-103
lines changed

cmd/oci-csi-node-driver/main.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ package main
1616

1717
import (
1818
"flag"
19+
"os"
20+
"runtime"
21+
"strings"
1922

2023
"github.com/spf13/viper"
2124
"go.uber.org/zap/zapcore"
@@ -37,17 +40,18 @@ func main() {
3740
flag.StringVar(&nodecsioptions.Kubeconfig, "kubeconfig", "", "cluster kubeconfig")
3841
flag.StringVar(&nodecsioptions.FssEndpoint, "fss-endpoint", "unix://tmp/fss/csi.sock", "FSS CSI endpoint")
3942
flag.BoolVar(&nodecsioptions.EnableFssDriver, "fss-csi-driver-enabled", true, "Handle flag to enable FSS CSI driver")
40-
flag.StringVar(&nodecsioptions.LustreEndpoint, "lustre-endpoint", "unix:///var/lib/kubelet/plugins/lustre.csi.oraclecloud.com/csi.sock", "Lustre CSI endpoint")
41-
flag.StringVar(&nodecsioptions.LustreCsiAddress, "lustre-csi-address", "/var/lib/kubelet/plugins/lustre.csi.oraclecloud.com/csi.sock", "Path of the Lustre CSI driver socket that the node-driver-registrar will connect to.")
43+
flag.StringVar(&nodecsioptions.LustreEndpoint, "lustre-endpoint", "unix:///lustre/csi.sock", "Lustre CSI endpoint")
44+
flag.StringVar(&nodecsioptions.LustreCsiAddress, "lustre-csi-address", "/lustre/csi.sock", "Path of the Lustre CSI driver socket that the node-driver-registrar will connect to.")
4245
flag.StringVar(&nodecsioptions.LustreKubeletRegistrationPath, "lustre-kubelet-registration-path", "/var/lib/kubelet/plugins/lustre.csi.oraclecloud.com/csi.sock", "Path of the Lustre CSI driver socket on the Kubernetes host machine.")
43-
flag.BoolVar(&nodecsioptions.OnlyEnableLustreDriver, "only-lustre-csi-driver-enabled", false, "Handle flag to enable Lustre CSI driver")
4446

4547
klog.InitFlags(nil)
4648
flag.Set("logtostderr", "true")
4749
flag.Parse()
4850

4951
viper.Set("log-level", getLevel(nodecsioptions.LogLevel))
5052

53+
enableLustreDriver := IsLustreDriverEnabled()
54+
5155
blockvolumeNodeOptions := nodedriveroptions.NodeOptions{
5256
Name: "BV",
5357
Endpoint: nodecsioptions.Endpoint,
@@ -82,17 +86,20 @@ func main() {
8286

8387
stopCh := signals.SetupSignalHandler()
8488

85-
if nodecsioptions.OnlyEnableLustreDriver {
89+
go nodedriver.RunNodeDriver(blockvolumeNodeOptions, stopCh)
90+
if nodecsioptions.EnableFssDriver {
91+
go nodedriver.RunNodeDriver(fssNodeOptions, stopCh)
92+
}
93+
if enableLustreDriver {
8694
go nodedriver.RunNodeDriver(lustreNodeOptions, stopCh)
87-
} else {
88-
go nodedriver.RunNodeDriver(blockvolumeNodeOptions, stopCh)
89-
if nodecsioptions.EnableFssDriver {
90-
go nodedriver.RunNodeDriver(fssNodeOptions, stopCh)
91-
}
9295
}
9396
<-stopCh
9497
}
9598

99+
func IsLustreDriverEnabled() bool {
100+
return strings.EqualFold(os.Getenv("LUSTRE_DRIVER_ENABLED"), "true")
101+
}
102+
96103
func getLevel(loglevel string) int8 {
97104
switch loglevel {
98105
case "debug":
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"testing"
6+
)
7+
8+
func Test_IsLustreDriverEnabled(t *testing.T) {
9+
tests := []struct {
10+
envValue string
11+
expected bool
12+
}{
13+
{"true", true},
14+
{"TRUE", true},
15+
{"TrUe", true},
16+
{"false", false},
17+
{"", false},
18+
{"random", false},
19+
}
20+
21+
for _, tc := range tests {
22+
// Set or unset the environment variable based on the test case.
23+
if tc.envValue == "" {
24+
os.Unsetenv("LUSTRE_DRIVER_ENABLED")
25+
} else {
26+
os.Setenv("LUSTRE_DRIVER_ENABLED", tc.envValue)
27+
}
28+
29+
// Our logic under test: compare the environment variable with "true" (case-insensitive).
30+
enableLustreDriver := IsLustreDriverEnabled()
31+
32+
if enableLustreDriver != tc.expected {
33+
t.Errorf("For LUSTRE_DRIVER_ENABLED=%q, expected %v but got %v",
34+
tc.envValue, tc.expected, enableLustreDriver)
35+
}
36+
}
37+
}

cmd/oci-csi-node-driver/nodedriveroptions/nodecsioptions.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type NodeCSIOptions struct {
2424

2525
EnableFssDriver bool
2626
FssEndpoint string
27-
OnlyEnableLustreDriver bool
2827
LustreCsiAddress string
2928
LustreKubeletRegistrationPath string
3029
LustreEndpoint string

0 commit comments

Comments
 (0)