Skip to content

First revision of raw block volume #464

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions pkg/csi-util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -70,6 +71,9 @@ const (
FINDMNT_COMMAND = "findmnt"
CAT_COMMAND = "cat"
RPM_COMMAND = "rpm-host"

// For Raw Block Volumes, the name of the bind-mounted file inside StagingTargetPath
RawBlockStagingFile = "mountfile"
)

// Util interface
Expand Down Expand Up @@ -450,3 +454,36 @@ func ValidateFssId(id string) *FSSVolumeHandler {
}
return volumeHandler
}

func GetStagingTargetPathForFile(stagingTargetPath string) string {
stagingTargetPathFile := filepath.Join(stagingTargetPath, RawBlockStagingFile)
return stagingTargetPathFile
}

// Creates a file on the specified path after creating the containing directory
func CreateFilePath(logger *zap.SugaredLogger, path string) error {
pathDir := filepath.Dir(path)

logger.Infof("trying to create surrounding directory %s", pathDir)
err := os.MkdirAll(pathDir, 0750)
if err != nil {
logger.Infof("failed to create surrounding directory %s", pathDir)
return err
}

logger.Infof("created surrounding directory, trying to create the target file %s", path)
file, fileErr := os.OpenFile(path, os.O_CREATE, 0640)
if fileErr != nil && !os.IsExist(fileErr) {
logger.Infof("failed to create/open the target file at %s", path)
return fileErr
}

fileErr = file.Close()
if fileErr != nil {
logger.Infof("failed to close %s", path)
return fileErr
}

logger.Infof("ensured file at %s", path)
return nil
}
8 changes: 4 additions & 4 deletions pkg/csi/driver/bv_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,10 +949,10 @@ func (d *BlockVolumeControllerDriver) validateCapabilities(caps []*csi.VolumeCap
}

for _, cap := range caps {
if blk := cap.GetBlock(); blk != nil {
d.logger.Error("volumeMode is set to Block which is not supported.")
return fmt.Errorf("driver does not support Block volumeMode. Please use Filesystem mode")
}
// if blk := cap.GetBlock(); blk != nil {
// d.logger.Error("volumeMode is set to Block which is not supported.")
// return fmt.Errorf("driver does not support Block volumeMode. Please use Filesystem mode")
// }
if hasSupport(cap.AccessMode.Mode) {
continue
} else {
Expand Down
Loading
Loading