File tree Expand file tree Collapse file tree 9 files changed +76
-23
lines changed Expand file tree Collapse file tree 9 files changed +76
-23
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import (
34
34
"k8s.io/kubernetes/pkg/util/mount"
35
35
utilstrings "k8s.io/kubernetes/pkg/util/strings"
36
36
"k8s.io/kubernetes/pkg/volume"
37
+ "k8s.io/kubernetes/pkg/volume/util"
37
38
)
38
39
39
40
// This is the primary entrypoint for volume plugins.
@@ -316,6 +317,13 @@ func (c *azureDiskUnmounter) TearDown() error {
316
317
// Unmounts the bind mount, and detaches the disk only if the PD
317
318
// resource was the last reference to that disk on the kubelet.
318
319
func (c * azureDiskUnmounter ) TearDownAt (dir string ) error {
320
+ if pathExists , pathErr := util .PathExists (dir ); pathErr != nil {
321
+ return fmt .Errorf ("Error checking if path exists: %v" , pathErr )
322
+ } else if ! pathExists {
323
+ glog .Warningf ("Warning: Unmount skipped because path does not exist: %v" , dir )
324
+ return nil
325
+ }
326
+
319
327
notMnt , err := c .mounter .IsLikelyNotMountPoint (dir )
320
328
if err != nil {
321
329
glog .Errorf ("Error checking if mountpoint %s: %v" , dir , err )
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import (
34
34
"k8s.io/kubernetes/pkg/util/mount"
35
35
"k8s.io/kubernetes/pkg/util/strings"
36
36
"k8s.io/kubernetes/pkg/volume"
37
+ "k8s.io/kubernetes/pkg/volume/util"
37
38
)
38
39
39
40
// This is the primary entrypoint for volume plugins.
@@ -386,6 +387,13 @@ func (c *cinderVolumeUnmounter) TearDown() error {
386
387
// Unmounts the bind mount, and detaches the disk only if the PD
387
388
// resource was the last reference to that disk on the kubelet.
388
389
func (c * cinderVolumeUnmounter ) TearDownAt (dir string ) error {
390
+ if pathExists , pathErr := util .PathExists (dir ); pathErr != nil {
391
+ return fmt .Errorf ("Error checking if path exists: %v" , pathErr )
392
+ } else if ! pathExists {
393
+ glog .Warningf ("Warning: Unmount skipped because path does not exist: %v" , dir )
394
+ return nil
395
+ }
396
+
389
397
glog .V (5 ).Infof ("Cinder TearDown of %s" , dir )
390
398
notmnt , err := c .mounter .IsLikelyNotMountPoint (dir )
391
399
if err != nil {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ go_library(
23
23
"//pkg/util/mount:go_default_library" ,
24
24
"//pkg/util/strings:go_default_library" ,
25
25
"//pkg/volume:go_default_library" ,
26
+ "//pkg/volume/util:go_default_library" ,
26
27
"//vendor:github.com/golang/glog" ,
27
28
"//vendor:k8s.io/apimachinery/pkg/types" ,
28
29
],
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
27
27
"k8s.io/kubernetes/pkg/util/mount"
28
28
"k8s.io/kubernetes/pkg/util/strings"
29
29
"k8s.io/kubernetes/pkg/volume"
30
+ "k8s.io/kubernetes/pkg/volume/util"
30
31
)
31
32
32
33
// This is the primary entrypoint for volume plugins.
@@ -222,6 +223,12 @@ func (c *fcDiskUnmounter) TearDown() error {
222
223
}
223
224
224
225
func (c * fcDiskUnmounter ) TearDownAt (dir string ) error {
226
+ if pathExists , pathErr := util .PathExists (dir ); pathErr != nil {
227
+ return fmt .Errorf ("Error checking if path exists: %v" , pathErr )
228
+ } else if ! pathExists {
229
+ glog .Warningf ("Warning: Unmount skipped because path does not exist: %v" , dir )
230
+ return nil
231
+ }
225
232
return diskTearDown (c .manager , * c , dir , c .mounter )
226
233
}
227
234
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ go_library(
21
21
"//pkg/util/mount:go_default_library" ,
22
22
"//pkg/util/strings:go_default_library" ,
23
23
"//pkg/volume:go_default_library" ,
24
+ "//pkg/volume/util:go_default_library" ,
24
25
"//vendor:github.com/golang/glog" ,
25
26
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1" ,
26
27
"//vendor:k8s.io/apimachinery/pkg/types" ,
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import (
32
32
"k8s.io/kubernetes/pkg/util/mount"
33
33
utilstrings "k8s.io/kubernetes/pkg/util/strings"
34
34
"k8s.io/kubernetes/pkg/volume"
35
+ "k8s.io/kubernetes/pkg/volume/util"
35
36
)
36
37
37
38
// This is the primary entrypoint for volume plugins.
@@ -371,6 +372,12 @@ func (f *flexVolumeUnmounter) TearDown() error {
371
372
372
373
// TearDownAt simply deletes everything in the directory.
373
374
func (f * flexVolumeUnmounter ) TearDownAt (dir string ) error {
375
+ if pathExists , pathErr := util .PathExists (dir ); pathErr != nil {
376
+ return fmt .Errorf ("Error checking if path exists: %v" , pathErr )
377
+ } else if ! pathExists {
378
+ glog .Warningf ("Warning: Unmount skipped because path does not exist: %v" , dir )
379
+ return nil
380
+ }
374
381
375
382
notmnt , err := f .mounter .IsLikelyNotMountPoint (dir )
376
383
if err != nil {
Original file line number Diff line number Diff line change @@ -230,6 +230,12 @@ func (c *iscsiDiskUnmounter) TearDown() error {
230
230
}
231
231
232
232
func (c * iscsiDiskUnmounter ) TearDownAt (dir string ) error {
233
+ if pathExists , pathErr := ioutil .PathExists (dir ); pathErr != nil {
234
+ return fmt .Errorf ("Error checking if path exists: %v" , pathErr )
235
+ } else if ! pathExists {
236
+ glog .Warningf ("Warning: Unmount skipped because path does not exist: %v" , dir )
237
+ return nil
238
+ }
233
239
return diskTearDown (c .manager , * c , dir , c .mounter )
234
240
}
235
241
Original file line number Diff line number Diff line change @@ -413,6 +413,12 @@ func (c *rbdUnmounter) TearDown() error {
413
413
}
414
414
415
415
func (c * rbdUnmounter ) TearDownAt (dir string ) error {
416
+ if pathExists , pathErr := volutil .PathExists (dir ); pathErr != nil {
417
+ return fmt .Errorf ("Error checking if path exists: %v" , pathErr )
418
+ } else if ! pathExists {
419
+ glog .Warningf ("Warning: Unmount skipped because path does not exist: %v" , dir )
420
+ return nil
421
+ }
416
422
return diskTearDown (c .manager , * c , dir , c .mounter )
417
423
}
418
424
You can’t perform that action at this time.
0 commit comments