Skip to content

Commit

Permalink
Use forced refresh instead of waiting for new volume in validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
casusbelli committed Jun 5, 2018
1 parent 9c6b457 commit b2030cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ $ docker run --rm -v "$GOPATH":/work -e "GOPATH=/work" -w /work/src/github.com/q

Common issues or pitfalls.

#### Plugin creates volumes but shows 'no such file or directory' error
#### Plugin creates volumes but shows 'no such file or directory' or 'operation not permitted' error

##### Reason
The Docker Quobyte plugin can successfully access the backend and create the volume but the new volume is not shown in the plugins mount point.
Expand Down
36 changes: 12 additions & 24 deletions quobyte_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"
"strings"
"sync"
"time"

"github.com/docker/go-plugins-helpers/volume"
quobyte_api "github.com/quobyte/api"
Expand Down Expand Up @@ -86,30 +85,19 @@ func (driver quobyteDriver) Create(request volume.Request) volume.Response {
}

func (driver quobyteDriver) checkMountPoint(mPoint string) error {
start := time.Now()

backoff := 1
tries := 0
var mountError error
for tries <= driver.maxFSChecks {
mountError = nil
if fi, err := os.Lstat(mPoint); err != nil || !fi.IsDir() {
log.Printf("Unsuccessful Filesystem Check for %s after %d tries", mPoint, tries)
mountError = err
} else {
return nil
}

time.Sleep(time.Duration(backoff) * time.Second)
if time.Since(start).Seconds() > driver.maxWaitTime {
log.Printf("Abort checking mount point do to time out after %f\n", driver.maxWaitTime)
return mountError
}

backoff *= 2
// Trigger volume list refresh
mkdErr := os.Mkdir(mPoint, 0755)
if !os.IsExist(mkdErr) {
// we expected ErrExist, everything else is an error
return mkdErr
}

return mountError
// Verify volume is available
_, statErr := os.Stat(mPoint)
if statErr != nil {
return statErr
}
log.Printf("Validated new volume ok: %s\n", mPoint)
return nil
}

func (driver quobyteDriver) Remove(request volume.Request) volume.Response {
Expand Down

0 comments on commit b2030cd

Please sign in to comment.