Skip to content

Commit

Permalink
Added configuration_name, tenant_id and retry RPC parameters
Browse files Browse the repository at this point in the history
This fixes rpc issues by adding configuration_name and tenant_id
parameters to the createVolume rpc. Furthermore the retry parameter is
set in all rpc calls for improved robustness.
This also updates the Readme file to the current state.
  • Loading branch information
casusbelli committed Dec 14, 2017
1 parent 6e930e3 commit 79ec523
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tar xfz docker-quobyte-plugin.tar.gz

### Create a user in Quobyte for the plug-in:

This step is optional.
This step is optional and should only be used if Quobytes build-in user database is used.

```
$ qmgmt -u <api-url> user config add docker <email>
Expand All @@ -51,21 +51,31 @@ $ systemctl status docker-quobyte-plugin

```
$ bin/docker-quobyte-plugin -h
Usage of /opt/bin/docker-quobyte-plugin:
Usage of 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")
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
Name of the volume configuration of new volumes (default "BASE")
-group string
Group to create the unix socket (default "root")
Group to create the unix socket (default "root")
-max-fs-checks int
Maximimum number of filesystem checks when a Volume is created before returning an error (default 5)
-max-wait-time float
Maximimum wait time for filesystem checks to complete when a Volume is created before returning an error (default 30)
-options string
Fuse options to be used when Quobyte is mounted (default "-o user_xattr")
Fuse options to be used when Quobyte is mounted (default "-o user_xattr")
-password string
Password for the user to connect to the Quobyte API server (default "quobyte")
Password for the user to connect to the Quobyte API server (default "quobyte")
-path string
Path where Quobyte is mounted on the host (default "/run/docker/quobyte/mnt")
Path where Quobyte is mounted on the host (default "/run/docker/quobyte/mnt")
-registry string
URL to the registry server(s) in the form of host[:port][,host:port] or SRV record name (default "localhost:7861")
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")
-user string
User to connect to the Quobyte API server (default "root")
User to connect to the Quobyte API server (default "root")
-version
Shows version string
```

## Examples
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ func main() {

quobyteUser := flag.String("user", "root", "User to connect to the Quobyte API server")
quobytePassword := flag.String("password", "quobyte", "Password for the user to connect to the Quobyte API server")
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")

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 All @@ -48,7 +50,7 @@ func main() {
mountAll(*quobyteMountOptions, *quobyteRegistry, *quobyteMountPath)
}

qDriver := newQuobyteDriver(*quobyteAPIURL, *quobyteUser, *quobytePassword, *quobyteMountPath, *maxFSChecks, *maxWaitTime)
qDriver := newQuobyteDriver(*quobyteAPIURL, *quobyteUser, *quobytePassword, *quobyteMountPath, *maxFSChecks, *maxWaitTime, *quobyteConfigName, *quobyteTenantId)
handler := volume.NewHandler(qDriver)

log.Println(handler.ServeUnix(*group, quobyteID))
Expand Down
22 changes: 18 additions & 4 deletions quobyte_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type quobyteDriver struct {
maxWaitTime float64
}

func newQuobyteDriver(apiURL string, username string, password string, quobyteMount string, maxFSChecks int, maxWaitTime float64) quobyteDriver {
func newQuobyteDriver(apiURL string, username string, password string, quobyteMount string, maxFSChecks int, maxWaitTime float64, configName string, tenantId string) quobyteDriver {
driver := quobyteDriver{
client: quobyte_api.NewQuobyteClient(apiURL, username, password),
quobyteMount: quobyteMount,
Expand All @@ -40,6 +40,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"

if usr, ok := request.Options["user"]; ok {
user = usr
Expand All @@ -49,10 +52,21 @@ func (driver quobyteDriver) Create(request volume.Request) volume.Response {
group = grp
}

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

if tenant, ok := request.Options["tenant_id"]; ok {
tenant_id = tenant
}

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

Expand Down
6 changes: 3 additions & 3 deletions systemd/docker-quobyte-plugin.service
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Unit]
Description=Docker Quobyte Plugin
Documentation=https://github.com/johscheuer/go-quobyte-docker
Before=docker.service
Documentation=https://github.com/quobyte/docker-volume

After=network.target docker.service
Requires=docker.service

[Service]
EnvironmentFile=/etc/quobyte/docker-quobyte.env
ExecStart=/usr/local/bin/docker-quobyte-plugin --user ${QUOBYTE_API_USER} --password ${QUOBYTE_API_PASSWORD} --api ${QUOBYTE_API_URL} --registry ${QUOBYTE_REGISTRY}
ExecStart=/usr/local/bin/docker-quobyte-plugin --user ${QUOBYTE_API_USER} --password ${QUOBYTE_API_PASSWORD} --api ${QUOBYTE_API_URL} --registry ${QUOBYTE_REGISTRY} --configuration_name ${QUOBYTE_CONFIGURATION_NAME}

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions vendor/github.com/quobyte/api/rpc_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/quobyte/api/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 79ec523

Please sign in to comment.