Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filter): add support to use unused partitions in os-disk #524

Merged
merged 5 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/524-akhilerm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add support for creating blockdevices for unused os-disk partitions
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
5 changes: 5 additions & 0 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,26 @@ const (
// blockdevice UUID algorithm mentioned in
// https://github.com/openebs/openebs/pull/2666
GPTBasedUUID Feature = "GPTBasedUUID"

// APIService feature flag starts the GRPC server which provides functionality to manage block devices
APIService Feature = "APIService"

UseOSDisk Feature = "UseOSDisk"
)

// supportedFeatures is the list of supported features. This is used while parsing the
// feature flag given via command line
var supportedFeatures = []Feature{
GPTBasedUUID,
APIService,
UseOSDisk,
}

// defaultFeatureGates is the default features that will be applied to the application
var defaultFeatureGates = map[Feature]bool{
GPTBasedUUID: false,
APIService: false,
UseOSDisk: false,
kmova marked this conversation as resolved.
Show resolved Hide resolved
}

// featureFlag is a map representing the flag and its state
Expand Down
20 changes: 16 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,22 @@ 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
akhilerm marked this conversation as resolved.
Show resolved Hide resolved
var ok bool
if features.FeatureGates.IsEnabled(features.UseOSDisk) {
// the last part will be used instead of the parent disk
// eg: /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda4 is the link
// and sda4 will be the device.
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