Skip to content

Commit d1ef0de

Browse files
authored
fix set quota (#1261)
Signed-off-by: Xuhui zhang <xuhui@juicedata.io>
1 parent 316f0d1 commit d1ef0de

File tree

7 files changed

+15
-19
lines changed

7 files changed

+15
-19
lines changed

deploy/k8s.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ spec:
629629
name: socket-dir
630630
- args:
631631
- --csi-address=$(ADDRESS)
632+
- --timeout=20s
632633
- --leader-election
633634
- --v=2
634635
env:

deploy/k8s_before_v1_18.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ spec:
629629
name: socket-dir
630630
- args:
631631
- --csi-address=$(ADDRESS)
632+
- --timeout=20s
632633
- --leader-election
633634
- --v=2
634635
env:

deploy/kubernetes/base/resources.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ spec:
477477
image: registry.k8s.io/sig-storage/csi-resizer:v1.9.0
478478
args:
479479
- --csi-address=$(ADDRESS)
480+
- --timeout=20s
480481
- --leader-election
481482
- --v=2
482483
env:

deploy/webhook-with-certmanager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ spec:
538538
name: socket-dir
539539
- args:
540540
- --csi-address=$(ADDRESS)
541+
- --timeout=20s
541542
- --leader-election
542543
- --v=2
543544
env:

deploy/webhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ spec:
566566
name: socket-dir
567567
- args:
568568
- --csi-address=$(ADDRESS)
569+
- --timeout=20s
569570
- --leader-election
570571
- --v=2
571572
env:

pkg/juicefs/juicefs.go

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ func (j *juicefs) SetQuota(ctx context.Context, secrets map[string]string, jfsSe
621621
cmdArgs = []string{config.CliPath, "quota", "set", secrets["name"], "--path", quotaPath, "--capacity", strconv.FormatInt(cap, 10)}
622622
}
623623
log.Info("quota cmd", "command", strings.Join(cmdArgs, " "))
624-
cmdCtx, cmdCancel := context.WithTimeout(ctx, 5*defaultCheckTimeout)
624+
cmdCtx, cmdCancel := context.WithTimeout(ctx, 10*defaultCheckTimeout)
625625
defer cmdCancel()
626626
envs := syscall.Environ()
627627
for key, val := range jfsSetting.Envs {
@@ -644,25 +644,14 @@ func (j *juicefs) SetQuota(ctx context.Context, secrets map[string]string, jfsSe
644644
return wrapSetQuotaErr(string(res), err)
645645
}
646646

647-
done := make(chan error, 1)
648-
go func() {
649-
// ce cli will block until quota is set
650-
quotaCmd := j.Exec.CommandContext(context.Background(), config.CeCliPath, args...)
651-
quotaCmd.SetEnv(envs)
652-
res, err := quotaCmd.CombinedOutput()
653-
if err == nil {
654-
log.Info("quota set success", "output", string(res))
655-
}
656-
done <- wrapSetQuotaErr(string(res), err)
657-
close(done)
658-
}()
659-
select {
660-
case <-cmdCtx.Done():
661-
log.Info("quota set timeout, runs in background")
662-
return nil
663-
case err = <-done:
664-
return err
647+
quotaCmd := j.Exec.CommandContext(ctx, config.CeCliPath, args...)
648+
quotaCmd.SetEnv(envs)
649+
res, err := quotaCmd.CombinedOutput()
650+
if err == nil {
651+
log.Info("quota set success", "output", string(res))
665652
}
653+
654+
return wrapSetQuotaErr(string(res), err)
666655
}
667656

668657
func wrapSetQuotaErr(res string, err error) error {

scripts/juicefs-csi-webhook-install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ spec:
637637
name: socket-dir
638638
- args:
639639
- --csi-address=$(ADDRESS)
640+
- --timeout=20s
640641
- --leader-election
641642
- --v=2
642643
env:
@@ -1374,6 +1375,7 @@ spec:
13741375
name: socket-dir
13751376
- args:
13761377
- --csi-address=$(ADDRESS)
1378+
- --timeout=20s
13771379
- --leader-election
13781380
- --v=2
13791381
env:

0 commit comments

Comments
 (0)