diff --git a/README.md b/README.md index 7960d7a..dd9f034 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/main.go b/main.go index 4e3c9eb..6e94daa 100644 --- a/main.go +++ b/main.go @@ -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") diff --git a/quobyte_driver.go b/quobyte_driver.go index f6a8ca6..bf6553e 100644 --- a/quobyte_driver.go +++ b/quobyte_driver.go @@ -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 @@ -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 @@ -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) @@ -89,12 +95,12 @@ 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 } @@ -102,13 +108,13 @@ func (driver quobyteDriver) checkMountPoint(mPoint string) error { 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 {