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

Fix issue that GetVolumePath return a nil instead of error when can't get partition uuid #1078

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
40 changes: 12 additions & 28 deletions pkg/node/provisioners/utilwrappers/partition_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"os/exec"
"strings"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
Expand All @@ -31,13 +30,6 @@ import (
"github.com/dell/csi-baremetal/pkg/metrics"
)

const (
// NumberOfRetriesToObtainPartName how many retries to obtain partition name
NumberOfRetriesToObtainPartName = 5
// SleepBetweenRetriesToObtainPartName default timeout between retries to obtain partition name
SleepBetweenRetriesToObtainPartName = 3 * time.Second
)

// PartitionOperations is a high-level interface
// that encapsulates all low-level operations with partitions on node
type PartitionOperations interface {
Expand Down Expand Up @@ -173,31 +165,23 @@ func (d *PartitionOperationsImpl) SearchPartName(device, partUUID string) (strin
var (
partName string
err error
errStr string
)

// get partition name
for i := 0; i < NumberOfRetriesToObtainPartName; i++ {
// sync partition table
_, errStr, err := d.SyncPartitionTable(device)
if err != nil {
if _, ok := err.(*exec.ExitError); ok &&
strings.Contains(errStr, "Device or resource busy") {
ll.Warningf("Unable to sync partition table for device %s: %v due to device is busy", device, err)
} else {
// log and ignore error
ll.Errorf("Unable to sync partition table for device %s: %v", device, err)
return "", err
}
}
// sleep first to avoid issues with lsblk caching
time.Sleep(SleepBetweenRetriesToObtainPartName)
partName, err = d.GetPartitionNameByUUID(device, partUUID)
if err != nil {
ll.Warningf("Unable to find part name: %v. Sleep and retry...", err)
continue
// sync partition table
_, errStr, err = d.SyncPartitionTable(device)
if err != nil {
if _, ok := err.(*exec.ExitError); ok &&
strings.Contains(errStr, "Device or resource busy") {
ll.Warningf("Unable to sync partition table for device %s: %v due to device is busy", device, err)
} else {
// log and ignore error
ll.Errorf("Unable to sync partition table for device %s: %v", device, err)
return "", err
}
break
}
partName, err = d.GetPartitionNameByUUID(device, partUUID)

// partition not found
if partName == "" {
Expand Down
Loading