Skip to content

Commit d3350a8

Browse files
committed
Fixed handling of tenant_id and configuration_name parameters
Besides above fixes this also removes underscores from variable names.
1 parent 79ec523 commit d3350a8

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $ systemctl status docker-quobyte-plugin
5151

5252
```
5353
$ bin/docker-quobyte-plugin -h
54-
Usage of docker-quobyte-plugin:
54+
Usage of bin/docker-quobyte-plugin:
5555
-api string
5656
URL to the API server(s) in the form http(s)://host[:port][,host:port] or SRV record name (default "http://localhost:7860")
5757
-configuration_name string
@@ -71,7 +71,7 @@ Usage of docker-quobyte-plugin:
7171
-registry string
7272
URL to the registry server(s) in the form of host[:port][,host:port] or SRV record name (default "localhost:7861")
7373
-tenant_id string
74-
Id of the Quobyte tenant in whose domain the operation takes place (default "default")
74+
Id of the Quobyte tenant in whose domain the operation takes place (default "no default")
7575
-user string
7676
User to connect to the Quobyte API server (default "root")
7777
-version

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424
quobyteConfigName := flag.String("configuration_name", "BASE", "Name of the volume configuration of new volumes")
2525
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")
2626
quobyteRegistry := flag.String("registry", "localhost:7861", "URL to the registry server(s) in the form of host[:port][,host:port] or SRV record name")
27-
quobyteTenantId := flag.String("tenant_id", "default", "Id of the Quobyte tenant in whose domain the operation takes place")
27+
quobyteTenantId := flag.String("tenant_id", "no default", "Id of the Quobyte tenant in whose domain the operation takes place")
2828

2929
group := flag.String("group", "root", "Group to create the unix socket")
3030
maxWaitTime := flag.Float64("max-wait-time", 30, "Maximimum wait time for filesystem checks to complete when a Volume is created before returning an error")

quobyte_driver.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ type quobyteDriver struct {
2020
m *sync.Mutex
2121
maxFSChecks int
2222
maxWaitTime float64
23+
tenantID string
24+
configName string
2325
}
2426

25-
func newQuobyteDriver(apiURL string, username string, password string, quobyteMount string, maxFSChecks int, maxWaitTime float64, configName string, tenantId string) quobyteDriver {
27+
func newQuobyteDriver(apiURL string, username string, password string, quobyteMount string, maxFSChecks int, maxWaitTime float64, fconfigName string, fTenantID string) quobyteDriver {
2628
driver := quobyteDriver{
2729
client: quobyte_api.NewQuobyteClient(apiURL, username, password),
2830
quobyteMount: quobyteMount,
2931
m: &sync.Mutex{},
3032
maxFSChecks: maxFSChecks,
3133
maxWaitTime: maxWaitTime,
34+
tenantID: fTenantID,
35+
configName: fconfigName,
3236
}
3337

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

4246
user, group := "root", "root"
43-
configuration_name := "BASE"
44-
retry_policy := "INTERACTIVE"
45-
tenant_id := "default"
47+
configurationName := "BASE"
48+
retryPolicy := "INTERACTIVE"
49+
tenantID := "default"
4650

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

5559
if conf, ok := request.Options["configuration_name"]; ok {
56-
configuration_name = conf
60+
configurationName = conf
5761
}
5862

5963
if tenant, ok := request.Options["tenant_id"]; ok {
60-
tenant_id = tenant
64+
tenantID = tenant
65+
} else {
66+
return volume.Response{Err: "No tenant_id given, cannot create a new volume."}
6167
}
6268

6369
if _, err := driver.client.CreateVolume(&quobyte_api.CreateVolumeRequest{
6470
Name: request.Name,
6571
RootUserID: user,
6672
RootGroupID: group,
67-
ConfigurationName: configuration_name,
68-
TenantID: tenant_id,
69-
Retry: retry_policy,
73+
ConfigurationName: configurationName,
74+
TenantID: tenantID,
75+
Retry: retryPolicy,
7076
}); err != nil {
7177
log.Println(err)
7278

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

9096
backoff := 1
9197
tries := 0
92-
var mount_error error
98+
var mountError error
9399
for tries <= driver.maxFSChecks {
94-
mount_error = nil
100+
mountError = nil
95101
if fi, err := os.Lstat(mPoint); err != nil || !fi.IsDir() {
96102
log.Printf("Unsuccessful Filesystem Check for %s after %d tries", mPoint, tries)
97-
mount_error = err
103+
mountError = err
98104
} else {
99105
return nil
100106
}
101107

102108
time.Sleep(time.Duration(backoff) * time.Second)
103109
if time.Since(start).Seconds() > driver.maxWaitTime {
104110
log.Printf("Abort checking mount point do to time out after %f\n", driver.maxWaitTime)
105-
return mount_error
111+
return mountError
106112
}
107113

108114
backoff *= 2
109115
}
110116

111-
return mount_error
117+
return mountError
112118
}
113119

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

0 commit comments

Comments
 (0)