Skip to content

Commit

Permalink
Fixed handling of tenant_id and configuration_name parameters
Browse files Browse the repository at this point in the history
Besides above fixes this also removes underscores from variable names.
  • Loading branch information
casusbelli committed Dec 14, 2017
1 parent 79ec523 commit d3350a8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $ systemctl status docker-quobyte-plugin

```
$ bin/docker-quobyte-plugin -h
Usage of docker-quobyte-plugin:
Usage of bin/docker-quobyte-plugin:
-api string
URL to the API server(s) in the form http(s)://host[:port][,host:port] or SRV record name (default "http://localhost:7860")
-configuration_name string
Expand All @@ -71,7 +71,7 @@ Usage of docker-quobyte-plugin:
-registry string
URL to the registry server(s) in the form of host[:port][,host:port] or SRV record name (default "localhost:7861")
-tenant_id string
Id of the Quobyte tenant in whose domain the operation takes place (default "default")
Id of the Quobyte tenant in whose domain the operation takes place (default "no default")
-user string
User to connect to the Quobyte API server (default "root")
-version
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
quobyteConfigName := flag.String("configuration_name", "BASE", "Name of the volume configuration of new volumes")
quobyteAPIURL := flag.String("api", "http://localhost:7860", "URL to the API server(s) in the form http(s)://host[:port][,host:port] or SRV record name")
quobyteRegistry := flag.String("registry", "localhost:7861", "URL to the registry server(s) in the form of host[:port][,host:port] or SRV record name")
quobyteTenantId := flag.String("tenant_id", "default", "Id of the Quobyte tenant in whose domain the operation takes place")
quobyteTenantId := flag.String("tenant_id", "no default", "Id of the Quobyte tenant in whose domain the operation takes place")

group := flag.String("group", "root", "Group to create the unix socket")
maxWaitTime := flag.Float64("max-wait-time", 30, "Maximimum wait time for filesystem checks to complete when a Volume is created before returning an error")
Expand Down
34 changes: 20 additions & 14 deletions quobyte_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ type quobyteDriver struct {
m *sync.Mutex
maxFSChecks int
maxWaitTime float64
tenantID string
configName string
}

func newQuobyteDriver(apiURL string, username string, password string, quobyteMount string, maxFSChecks int, maxWaitTime float64, configName string, tenantId string) quobyteDriver {
func newQuobyteDriver(apiURL string, username string, password string, quobyteMount string, maxFSChecks int, maxWaitTime float64, fconfigName string, fTenantID string) quobyteDriver {
driver := quobyteDriver{
client: quobyte_api.NewQuobyteClient(apiURL, username, password),
quobyteMount: quobyteMount,
m: &sync.Mutex{},
maxFSChecks: maxFSChecks,
maxWaitTime: maxWaitTime,
tenantID: fTenantID,
configName: fconfigName,
}

return driver
Expand All @@ -40,9 +44,9 @@ func (driver quobyteDriver) Create(request volume.Request) volume.Response {
defer driver.m.Unlock()

user, group := "root", "root"
configuration_name := "BASE"
retry_policy := "INTERACTIVE"
tenant_id := "default"
configurationName := "BASE"
retryPolicy := "INTERACTIVE"
tenantID := "default"

if usr, ok := request.Options["user"]; ok {
user = usr
Expand All @@ -53,20 +57,22 @@ func (driver quobyteDriver) Create(request volume.Request) volume.Response {
}

if conf, ok := request.Options["configuration_name"]; ok {
configuration_name = conf
configurationName = conf
}

if tenant, ok := request.Options["tenant_id"]; ok {
tenant_id = tenant
tenantID = tenant
} else {
return volume.Response{Err: "No tenant_id given, cannot create a new volume."}
}

if _, err := driver.client.CreateVolume(&quobyte_api.CreateVolumeRequest{
Name: request.Name,
RootUserID: user,
RootGroupID: group,
ConfigurationName: configuration_name,
TenantID: tenant_id,
Retry: retry_policy,
ConfigurationName: configurationName,
TenantID: tenantID,
Retry: retryPolicy,
}); err != nil {
log.Println(err)

Expand All @@ -89,26 +95,26 @@ func (driver quobyteDriver) checkMountPoint(mPoint string) error {

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

backoff *= 2
}

return mount_error
return mountError
}

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

0 comments on commit d3350a8

Please sign in to comment.