Skip to content

Commit ca9bd86

Browse files
committed
refactor: simplify mount configuration by removing STORAGE_CLASS_DAEMONSET flag
- Remove separate STORAGE_CLASS_DAEMONSET environment variable - DaemonSet mode is now automatically available when STORAGE_CLASS_SHARE_MOUNT is enabled - Changed LoadDaemonSetNodeAffinity to assert mount sharing is enabled rather than conditionally check - Updated documentation to reflect the simplified configuration - Updated all tests to work without the removed flag This simplifies the configuration model - when mount sharing is enabled, users can choose between shared-pod (default) and daemonset modes via ConfigMap without needing a separate environment variable.
1 parent 4eba186 commit ca9bd86

File tree

11 files changed

+20
-96
lines changed

11 files changed

+20
-96
lines changed

cmd/controller.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ func parseControllerConfig() {
9494
if os.Getenv("STORAGE_CLASS_SHARE_MOUNT") == "true" {
9595
config.StorageClassShareMount = true
9696
}
97-
if os.Getenv("STORAGE_CLASS_DAEMONSET") == "true" {
98-
config.StorageClassDaemonSet = true
99-
}
10097
if !config.Webhook {
10198
// When not in sidecar mode, we should inherit attributes from CSI Node pod.
10299
k8sclient, err := k8s.NewClient()

cmd/node.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ func parseNodeConfig() {
104104
if os.Getenv("STORAGE_CLASS_SHARE_MOUNT") == "true" {
105105
config.StorageClassShareMount = true
106106
}
107-
if os.Getenv("STORAGE_CLASS_DAEMONSET") == "true" {
108-
config.StorageClassDaemonSet = true
109-
}
110107

111108
if config.PodName == "" || config.Namespace == "" {
112109
log.Info("Pod name & namespace can't be null.")

docs/en/guide/daemonset-mount.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ When `STORAGE_CLASS_SHARE_MOUNT` is enabled, JuiceFS CSI Driver shares Mount Pod
1616

1717
### Enable DaemonSet Mount
1818

19-
To enable DaemonSet mount for StorageClass, set these environment variables in the CSI Driver deployment:
19+
DaemonSet mount is automatically available when mount sharing is enabled. To enable mount sharing, set this environment variable in the CSI Driver deployment:
2020

2121
```yaml
2222
env:
2323
- name: STORAGE_CLASS_SHARE_MOUNT
2424
value: "true"
25-
- name: STORAGE_CLASS_DAEMONSET
26-
value: "true"
2725
```
2826
27+
Once enabled, you can configure specific StorageClasses to use DaemonSet mode via the ConfigMap (see below).
28+
2929
### Configure Node Affinity
3030
3131
There are two ways to configure node affinity for DaemonSet Mount Pods:
@@ -174,9 +174,9 @@ kubectl get pods -n kube-system -l juicefs.com/mount-by=juicefs-csi-driver
174174

175175
## Limitations
176176

177-
- Node affinity is only applied when both `STORAGE_CLASS_SHARE_MOUNT` and `STORAGE_CLASS_DAEMONSET` are enabled
177+
- Node affinity is only applied when `STORAGE_CLASS_SHARE_MOUNT` is enabled and DaemonSet mode is configured
178178
- All PVCs using the same StorageClass share the same DaemonSet and node affinity rules
179-
- Changing node affinity requires recreating the StorageClass and associated PVCs
179+
- Changing node affinity requires recreating the DaemonSet (happens automatically when all PVCs are deleted)
180180

181181
## Migration
182182

docs/en/guide/mount-pod-configuration.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@ Set default behavior for all StorageClasses via environment variables in the CSI
1818

1919
```yaml
2020
env:
21-
# For shared pod mode (default)
21+
# Enable mount sharing (defaults to shared-pod mode)
2222
- name: STORAGE_CLASS_SHARE_MOUNT
2323
value: "true"
24-
25-
# For DaemonSet mode
26-
- name: STORAGE_CLASS_SHARE_MOUNT
27-
value: "true"
28-
- name: STORAGE_CLASS_DAEMONSET
29-
value: "true"
3024
```
3125
26+
When `STORAGE_CLASS_SHARE_MOUNT` is enabled:
27+
- Default mode is `shared-pod`
28+
- DaemonSet mode can be configured per StorageClass via ConfigMap
29+
- Per-PVC mode can still be explicitly configured via ConfigMap
30+
3231
### Per-StorageClass Configuration (ConfigMap)
3332

3433
Override global defaults and configure individual StorageClasses using a ConfigMap:

pkg/config/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ var (
5050
Webhook = false // start webhook server, used in sidecar mode or validating/mutating webhook
5151
ValidatingWebhook = false // start validating webhook, applicable to ee only
5252
Immutable = false // csi driver is running in an immutable environment
53-
StorageClassShareMount = false // share mount pod for the same storage class
54-
StorageClassDaemonSet = false // deploy mount pods as DaemonSet for storage class
53+
StorageClassShareMount = false // share mount pod for the same storage class (enables shared-pod and daemonset modes)
5554
AccessToKubelet = false // access kubelet or not
5655

5756
DriverName = "csi.juicefs.com"

pkg/config/mount_config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,9 @@ func parseMountConfig(configData string) (*MountConfig, error) {
140140
// getDefaultMountMode returns the default mount mode based on environment variables
141141
func getDefaultMountMode() MountMode {
142142
// Check global environment variable settings
143+
// When StorageClassShareMount is enabled, default to shared-pod
144+
// DaemonSet mode is only used when explicitly configured via ConfigMap
143145
if StorageClassShareMount {
144-
if StorageClassDaemonSet {
145-
return MountModeDaemonSet
146-
}
147146
return MountModeSharedPod
148147
}
149148
return MountModePVC

pkg/config/mount_config_helper.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ func parseDaemonSetNodeAffinity(configData string) (*corev1.NodeAffinity, error)
8080
func LoadDaemonSetNodeAffinity(ctx context.Context, client *k8sclient.K8sClient, jfsSetting *JfsSetting) error {
8181
log := klog.NewKlogr().WithName("mount-config")
8282

83-
// Skip if not using DaemonSet deployment
84-
if !StorageClassShareMount || !StorageClassDaemonSet {
85-
return nil
83+
// This should only be called when mount sharing is enabled
84+
// If we're here without mount sharing, it's a programming error
85+
if !StorageClassShareMount {
86+
log.Error(nil, "LoadDaemonSetNodeAffinity called but StorageClassShareMount is false - this should not happen")
87+
return fmt.Errorf("LoadDaemonSetNodeAffinity called without mount sharing enabled")
8688
}
8789

8890
// Skip if node affinity already set (from StorageClass parameters)

pkg/config/mount_config_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func TestGetMountConfig(t *testing.T) {
9393
storageClassName string
9494
configMap *corev1.ConfigMap
9595
globalShareMount bool
96-
globalDaemonSet bool
9796
wantMode MountMode
9897
wantHasAffinity bool
9998
}{
@@ -102,25 +101,15 @@ func TestGetMountConfig(t *testing.T) {
102101
storageClassName: "test-sc",
103102
configMap: nil,
104103
globalShareMount: false,
105-
globalDaemonSet: false,
106104
wantMode: MountModePVC,
107105
},
108106
{
109107
name: "no configmap, use global shared-pod",
110108
storageClassName: "test-sc",
111109
configMap: nil,
112110
globalShareMount: true,
113-
globalDaemonSet: false,
114111
wantMode: MountModeSharedPod,
115112
},
116-
{
117-
name: "no configmap, use global daemonset",
118-
storageClassName: "test-sc",
119-
configMap: nil,
120-
globalShareMount: true,
121-
globalDaemonSet: true,
122-
wantMode: MountModeDaemonSet,
123-
},
124113
{
125114
name: "configmap with default",
126115
storageClassName: "test-sc",
@@ -179,7 +168,6 @@ nodeAffinity:
179168
t.Run(tt.name, func(t *testing.T) {
180169
// Set global variables
181170
StorageClassShareMount = tt.globalShareMount
182-
StorageClassDaemonSet = tt.globalDaemonSet
183171

184172
// Create fake k8s client
185173
var objects []runtime.Object

pkg/config/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func ParseSetting(ctx context.Context, secrets, volCtx map[string]string, option
300300

301301
// Parse node affinity for DaemonSet deployment
302302
// First check if it's in volCtx (for backward compatibility)
303-
if volCtx["nodeAffinity"] != "" && StorageClassShareMount && StorageClassDaemonSet {
303+
if volCtx["nodeAffinity"] != "" && StorageClassShareMount {
304304
nodeAffinity := &corev1.NodeAffinity{}
305305
if err := yaml.Unmarshal([]byte(volCtx["nodeAffinity"]), nodeAffinity); err != nil {
306306
log.Error(err, "Failed to parse nodeAffinity", "nodeAffinity", volCtx["nodeAffinity"])

pkg/juicefs/mount/daemonset_mount_simple_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,33 +243,22 @@ func TestMountSelector_ConfigFallback(t *testing.T) {
243243
configMap *corev1.ConfigMap
244244
storageClassName string
245245
globalShareMount bool
246-
globalDaemonSet bool
247246
wantMode jfsConfig.MountMode
248247
}{
249248
{
250249
name: "no configmap, fallback to global per-pvc",
251250
configMap: nil,
252251
storageClassName: "test-sc",
253252
globalShareMount: false,
254-
globalDaemonSet: false,
255253
wantMode: jfsConfig.MountModePVC,
256254
},
257255
{
258256
name: "no configmap, fallback to global shared-pod",
259257
configMap: nil,
260258
storageClassName: "test-sc",
261259
globalShareMount: true,
262-
globalDaemonSet: false,
263260
wantMode: jfsConfig.MountModeSharedPod,
264261
},
265-
{
266-
name: "no configmap, fallback to global daemonset",
267-
configMap: nil,
268-
storageClassName: "test-sc",
269-
globalShareMount: true,
270-
globalDaemonSet: true,
271-
wantMode: jfsConfig.MountModeDaemonSet,
272-
},
273262
{
274263
name: "invalid config in configmap, fallback to global",
275264
configMap: &corev1.ConfigMap{
@@ -283,7 +272,6 @@ func TestMountSelector_ConfigFallback(t *testing.T) {
283272
},
284273
storageClassName: "test-sc",
285274
globalShareMount: true,
286-
globalDaemonSet: false,
287275
wantMode: jfsConfig.MountModeSharedPod,
288276
},
289277
{
@@ -299,7 +287,6 @@ func TestMountSelector_ConfigFallback(t *testing.T) {
299287
},
300288
storageClassName: "test-sc",
301289
globalShareMount: true,
302-
globalDaemonSet: true,
303290
wantMode: jfsConfig.MountModePVC,
304291
},
305292
{
@@ -315,7 +302,6 @@ func TestMountSelector_ConfigFallback(t *testing.T) {
315302
},
316303
storageClassName: "unknown-sc",
317304
globalShareMount: false,
318-
globalDaemonSet: false,
319305
wantMode: jfsConfig.MountModeDaemonSet,
320306
},
321307
}
@@ -324,7 +310,6 @@ func TestMountSelector_ConfigFallback(t *testing.T) {
324310
t.Run(tt.name, func(t *testing.T) {
325311
// Set global variables
326312
jfsConfig.StorageClassShareMount = tt.globalShareMount
327-
jfsConfig.StorageClassDaemonSet = tt.globalDaemonSet
328313

329314
// Create fake k8s client
330315
var objects []runtime.Object

0 commit comments

Comments
 (0)