Skip to content

Commit

Permalink
feat(filter): add support for using unused partition on os-disk
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil Mohan <[email protected]>
  • Loading branch information
akhilerm committed Dec 29, 2020
1 parent 1e0d692 commit b7f6911
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 0 additions & 2 deletions cmd/ndm_daemonset/filter/osdiskexcludefilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func (odf *oSDiskExcludeFilter) Start() {
mountPointUtil := mount.NewMountUtil(hostMountFilePath, "", mountPoint)
if devPath, err := mountPointUtil.GetDiskPath(); err != nil {
klog.Errorf("unable to configure os disk filter for mountpoint: %s, error: %v", mountPoint, err)
klog.Error(err)
} else {
odf.excludeDevPaths = append(odf.excludeDevPaths, devPath)
}
Expand All @@ -103,7 +102,6 @@ func (odf *oSDiskExcludeFilter) Start() {
mountPointUtil := mount.NewMountUtil(defaultMountFilePath, "", mountPoint)
if devPath, err := mountPointUtil.GetDiskPath(); err != nil {
klog.Errorf("unable to configure os disk filter for mountpoint: %s, error: %v", mountPoint, err)
klog.Error(err)
} else {
odf.excludeDevPaths = append(odf.excludeDevPaths, devPath)
}
Expand Down
18 changes: 14 additions & 4 deletions pkg/mount/mountutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package mount
import (
"bufio"
"fmt"
"github.com/openebs/node-disk-manager/pkg/features"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -116,11 +117,20 @@ func getDiskDevPath(partition string) (string, error) {
return "", err
}

parentDisk, ok := getParentBlockDevice(link)
if !ok {
return "", fmt.Errorf("could not find parent device for %s", link)
var disk string
var ok bool
if features.FeatureGates.IsEnabled(features.UseOSDisk) {
// the last part will be used instead of the parent disk
split := strings.Split(link, "/")
disk = split[len(split)-1]
} else {
disk, ok = getParentBlockDevice(link)
if !ok {
return "", fmt.Errorf("could not find parent device for %s", link)
}
}
return "/dev/" + parentDisk, nil

return "/dev/" + disk, nil
}

// getSoftLinkForPartition returns path to /sys/class/block/$partition
Expand Down

0 comments on commit b7f6911

Please sign in to comment.