diff options
| author | Viktor Kuzmin <kvaster@gmail.com> | 2023-08-06 23:23:54 +0300 |
|---|---|---|
| committer | Chris Lu <chrislusf@users.noreply.github.com> | 2023-08-07 10:22:05 -0700 |
| commit | 251eb9b4b8dc52ca55f3903b64f4f7027343fd5b (patch) | |
| tree | eb92e65f3dcea999d094bf5e446d57d0d407ec30 /pkg/driver/volume.go | |
| parent | d84db4bbebec5d8c0d0e20dbf9deffdd24ba1151 (diff) | |
| download | seaweedfs-csi-driver-251eb9b4b8dc52ca55f3903b64f4f7027343fd5b.tar.xz seaweedfs-csi-driver-251eb9b4b8dc52ca55f3903b64f4f7027343fd5b.zip | |
Graceful stop with mounts cleanup
Diffstat (limited to 'pkg/driver/volume.go')
| -rw-r--r-- | pkg/driver/volume.go | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/pkg/driver/volume.go b/pkg/driver/volume.go index 5358700..e4e2cf3 100644 --- a/pkg/driver/volume.go +++ b/pkg/driver/volume.go @@ -13,7 +13,8 @@ import ( ) type Volume struct { - VolumeId string + VolumeId string + StagedPath string mounter Mounter unmounter Unmounter @@ -40,7 +41,17 @@ func (vol *Volume) Stage(stagingTargetPath string) error { } if u, err := vol.mounter.Mount(stagingTargetPath); err == nil { + if vol.StagedPath != "" { + if vol.StagedPath == stagingTargetPath { + glog.Warningf("staged path is already set to %s for volume %s", vol.StagedPath, vol.VolumeId) + } else { + glog.Warningf("staged path is already set to %s and differs from %s for volume %s", vol.StagedPath, stagingTargetPath, vol.VolumeId) + } + } + + vol.StagedPath = stagingTargetPath vol.unmounter = u + return nil } else { return err @@ -99,15 +110,21 @@ func (vol *Volume) Unstage(stagingTargetPath string) error { glog.V(0).Infof("unmounting volume %s from %s", vol.VolumeId, stagingTargetPath) if vol.unmounter == nil { - glog.Errorf("volume is not mounted: %s, path", vol.VolumeId, stagingTargetPath) + glog.Errorf("volume is not mounted: %s, path: %s", vol.VolumeId, stagingTargetPath) return nil } + if stagingTargetPath != vol.StagedPath { + glog.Warningf("staging path %s differs for volume %s at %s", stagingTargetPath, vol.VolumeId, vol.StagedPath) + } + if err := vol.unmounter.Unmount(); err != nil { + glog.Errorf("error unmounting volume during unstage: %s, err: %v", err) return err } if err := os.Remove(stagingTargetPath); err != nil && !os.IsNotExist(err) { + glog.Errorf("error removing staging path for volume %s at %s, err: %v", vol.VolumeId, stagingTargetPath, err) return err } |
