Skip to content

Commit 39734c3

Browse files
committed
publish v0.5.30 and fix rclone mount hang issue
Signed-off-by: Mayank Sachan <[email protected]>
1 parent 4a009fd commit 39734c3

File tree

4 files changed

+67
-41
lines changed

4 files changed

+67
-41
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
branches:
6-
- main
6+
- mount-goroutine
77

88
jobs:
99
release:
@@ -16,8 +16,8 @@ jobs:
1616
- cos-csi-mounter
1717

1818
env:
19-
IS_LATEST_RELEASE: 'true'
20-
APP_VERSION: 1.0.4
19+
IS_LATEST_RELEASE: 'false'
20+
APP_VERSION: 0.5.30
2121

2222
steps:
2323
- name: Checkout Code
@@ -63,15 +63,11 @@ jobs:
6363
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-${{ env.APP_VERSION }}.deb.tar.gz.sha256
6464
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-${{ env.APP_VERSION }}.rpm.tar.gz
6565
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-${{ env.APP_VERSION }}.rpm.tar.gz.sha256
66-
tag_name: v1.0.4
67-
name: v1.0.4
66+
tag_name: v0.5.30
67+
name: v0.5.30
6868
body: |
6969
## 🚀 What’s New
70-
- Enable --vfs-cache-mode flag for rclone mount to support random write
71-
- Update golang dependencies
72-
- Fetch IAM Endpoint Dynamically
73-
- Add TLS cipher suites in the mount options
74-
- Fix issue with s3fs mount randomly taking time using IAM credentials on Private VPC clusters
70+
- Fix for rclone mount hang issue
7571
prerelease: ${{ env.IS_LATEST_RELEASE != 'true' }}
7672

7773
- name: Perform CodeQL Analysis

cos-csi-mounter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NAME := cos-csi-mounter
2-
APP_VERSION := 1.0.4
2+
APP_VERSION := 0.5.30
33
BUILD_DIR := $(NAME)-$(APP_VERSION)
44
BIN_DIR := bin
55

pkg/constants/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const (
3636
MounterConfigPathOnPodS3fs = "/var/lib/ibmc-s3fs"
3737
MounterConfigPathOnPodRclone = "/root/.config/rclone"
3838
// Interval to wait till next loop
39-
Interval = 500 * time.Millisecond
39+
Interval = 1 * time.Second
4040

4141
PVCNameKey = "csi.storage.k8s.io/pvc/name"
4242
PVCNamespaceKey = "csi.storage.k8s.io/pvc/namespace"

pkg/mounter/utils/mounter_utils.go

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package utils
55

66
import (
7+
"context"
78
"errors"
89
"fmt"
910
"os"
@@ -19,7 +20,6 @@ import (
1920
)
2021

2122
var unmount = syscall.Unmount
22-
var command = exec.Command
2323

2424
var ErrTimeoutWaitProcess = errors.New("timeout waiting for process to end")
2525

@@ -33,37 +33,59 @@ type MounterOptsUtils struct {
3333

3434
func (su *MounterOptsUtils) FuseMount(path string, comm string, args []string) error {
3535
klog.Info("-FuseMount-")
36-
klog.Infof("FuseMount params:\n\tpath: <%s>\n\tcommand: <%s>\n\targs: <%v>", path, comm, args)
37-
cmd := command(comm, args...)
36+
klog.Infof("FuseMount: params:\n\tpath: <%s>\n\tcommand: <%s>\n\targs: <%v>", path, comm, args)
37+
38+
ctx, cancel := context.WithCancel(context.Background())
39+
defer cancel()
40+
41+
cmd := exec.CommandContext(ctx, comm, args...)
3842
err := cmd.Start()
3943
if err != nil {
4044
klog.Errorf("FuseMount: command start failed: mounter=%s, args=%v, error=%v", comm, args, err)
4145
return fmt.Errorf("FuseMount: '%s' command start failed: %v", comm, err)
4246
}
4347
klog.Infof("FuseMount: command 'start' succeeded for '%s' mounter", comm)
4448

45-
err = cmd.Wait()
46-
if err != nil {
47-
klog.Warningf("FuseMount: command wait failed: mounter=%s, args=%v, error=%v", comm, args, err)
48-
klog.Infof("FuseMount: checking if path already exists and is a mountpoint. path=%s", path)
49-
if mounted, err1 := isMountpoint(path); err1 == nil && mounted { // check if bucket already got mounted
50-
klog.Infof("bucket is already mounted using '%s' mounter", comm)
51-
return nil
49+
waitCh := make(chan error, 1)
50+
mountCh := make(chan error, 1)
51+
52+
go func() {
53+
waitCh <- cmd.Wait()
54+
}()
55+
56+
go func() {
57+
mountCh <- waitForMount(ctx, path, 2*time.Second, 90*time.Second) // kubelet retries NodePublishVolume after 120 seconds
58+
}()
59+
60+
select {
61+
case err := <-waitCh:
62+
if err != nil {
63+
klog.Warningf("FuseMount: command 'wait' failed: mounter=%s, args=%v, error=%v", comm, args, err)
64+
klog.Infof("FuseMount: checking if path already exists and is a mountpoint: path=%s", path)
65+
if mounted, err1 := isMountpoint(path); err1 == nil && mounted { // check if bucket already got mounted
66+
klog.Infof("bucket is already mounted using '%s' mounter", comm)
67+
return nil
68+
}
69+
return fmt.Errorf("'%s' mount failed: %v", comm, err)
70+
}
71+
klog.Infof("FuseMount: command 'wait' succeeded for '%s' mounter", comm)
72+
if err := waitForMount(ctx, path, 0, 30*time.Second); err != nil {
73+
return err
5274
}
53-
klog.Errorf("FuseMount: path is not mountpoint. Mount failed: mounter=%s, path=%s", comm, path)
54-
return fmt.Errorf("'%s' mount failed: %v", comm, err)
55-
}
5675

57-
klog.Infof("FuseMount: command 'wait' succeeded for '%s' mounter", comm)
58-
if err := waitForMount(path, 10*time.Second); err != nil {
59-
return err
76+
case err := <-mountCh:
77+
if err != nil {
78+
klog.Errorf("FuseMount: path is not mountpoint. Mount failed: mounter=%s, path=%s", comm, path)
79+
return fmt.Errorf("'%s' mount failed: %v", comm, err)
80+
}
6081
}
82+
6183
klog.Infof("bucket mounted successfully using '%s' mounter", comm)
6284
return nil
6385
}
6486

6587
func (su *MounterOptsUtils) FuseUnmount(path string) error {
66-
klog.Info("-fuseUnmount-")
88+
klog.Info("-FuseUnmount-")
6789
// check if mountpoint exists
6890
isMount, checkMountErr := isMountpoint(path)
6991
if isMount || checkMountErr != nil {
@@ -136,23 +158,31 @@ func isMountpoint(pathname string) (bool, error) {
136158
return false, nil
137159
}
138160

139-
func waitForMount(path string, timeout time.Duration) error {
161+
func waitForMount(ctx context.Context, path string, initialDelaySeconds, timeout time.Duration) error {
162+
if initialDelaySeconds > 0 {
163+
time.Sleep(initialDelaySeconds)
164+
}
140165
var elapsed time.Duration
141166
attempt := 1
142167
for {
143-
isMount, err := k8sMountUtils.New("").IsMountPoint(path)
144-
if err == nil && isMount {
145-
klog.Infof("Path is a mountpoint: pathname: %s", path)
146-
return nil
147-
}
168+
select {
169+
case <-ctx.Done():
170+
return ctx.Err()
171+
default:
172+
isMount, err := k8sMountUtils.New("").IsMountPoint(path)
173+
if err == nil && isMount {
174+
klog.Infof("Path is a mountpoint: pathname: %s", path)
175+
return nil
176+
}
148177

149-
klog.Infof("Mountpoint check in progress: attempt=%d, path=%s, isMount=%v, err=%v", attempt, path, isMount, err)
150-
time.Sleep(constants.Interval)
151-
elapsed += constants.Interval
152-
if elapsed >= timeout {
153-
return fmt.Errorf("timeout waiting for mount. Last check response: isMount=%v, err=%v", isMount, err)
178+
klog.Infof("Mountpoint check in progress: attempt=%d, path=%s, isMount=%v, err=%v, timeout=%v", attempt, path, isMount, err, timeout)
179+
time.Sleep(constants.Interval)
180+
elapsed += constants.Interval
181+
if elapsed >= timeout {
182+
return fmt.Errorf("timeout waiting for mount. Last check response: isMount=%v, err=%v, timeout=%v", isMount, err, constants.Timeout)
183+
}
184+
attempt++
154185
}
155-
attempt++
156186
}
157187
}
158188

0 commit comments

Comments
 (0)