Skip to content

Commit

Permalink
Merge pull request #2133 from travisn/backport-format-status
Browse files Browse the repository at this point in the history
Backport: Log the output of blkid to see if device should be formatted
  • Loading branch information
travisn committed Sep 18, 2018
2 parents 931fbd9 + 3e4ea7f commit 736f10a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/rookflex/cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"

"github.com/rook/rook/pkg/daemon/ceph/agent/flexvolume"
"github.com/rook/rook/pkg/util/exec"
"github.com/spf13/cobra"
k8smount "k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/version"
Expand Down Expand Up @@ -134,6 +135,22 @@ func mountDevice(client *rpc.Client, mounter *k8smount.SafeFormatAndMount, devic
return fmt.Errorf("Rook: Mount volume failed. Error checking if %s is a mount point: %v", globalVolumeMountPath, err)
}
}

// Testing to see if the device is formatted. There has been observed an issue on slow systems where k8s believes there is no filesystem
// formatted even though one does exist. K8s then proceeds to format the volume which would result in data loss. This logging is an attempt
// to understand why k8s believes the volume is not formatted. See https://github.com/rook/rook/issues/1553
log(client, fmt.Sprintf("Testing to see if device %s needs formatting...", devicePath), false)
executor := &exec.CommandExecutor{}
output, err := executor.ExecuteCommandWithOutput(false, "", "blkid", "-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", devicePath)
if err != nil {
log(client, fmt.Sprintf("Formatting test (blkid -p -s TYPE -s PTTYPE -o export %s). Device may not be formatted. err: %+v", devicePath, err), false)
} else {
log(client, fmt.Sprintf("Formatting test (blkid -p -s TYPE -s PTTYPE -o export %s). Device is already formatted", devicePath), false)
}
if len(output) > 0 {
log(client, fmt.Sprintf("Output: %s", output), false)
}

options := []string{opts.RW}
if notMnt {
err = redirectStdout(
Expand Down

0 comments on commit 736f10a

Please sign in to comment.