Check mountpoint is healthy before trimming the volume
Longhorn 836
@@ -921,10 +921,18 @@ func TrimFilesystem(volumeName string) error {
var mountpoint string
for _, m := range mountList {
+ _, err = nsExec.Execute("stat", []string{m})
+ if err == nil {
mountpoint = m
break
}
+ logrus.WithError(err).Warnf("failed to get volume %v mountpoint %v info", volumeName, m)
+ }
+ if mountpoint == "" {
+ return fmt.Errorf("cannot find a valid mountpoint for volume %v", volumeName)
+ }
+
_, err = nsExec.Execute("fstrim", []string{mountpoint})
if err != nil {
return fmt.Errorf("cannot find volume %v mount info on host: %v", volumeName, err)
