Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockOpts["size"] need to be converted to string #47

Open
datamattsson opened this issue Dec 7, 2018 · 1 comment
Open

dockOpts["size"] need to be converted to string #47

datamattsson opened this issue Dec 7, 2018 · 1 comment

Comments

@datamattsson
Copy link
Contributor

When a user specify a storage resources size in a PVC, the value gets treated as an integer internally and passed down to the Docker Volume API socket as an integer type in JSON.

Plugins that may be written using the official Go bindings from Docker will not work as the library only accepts strings in the value. https://github.com/docker/go-plugins-helpers/tree/master/volume (https://github.com/docker/go-plugins-helpers/blob/1e6269c305b8c75cfda1c8aa91349c38d7335814/volume/api.go#L26)

Since neither a StorageClass or PVC annotation accepts any other data types than strings. It would be more coherent to pass claimSizeInGiB as a string to the Docker Volume API socket.

I'm having trouble following the code that determines where size should be picked from (I tried setting "size" in the StorageClass, with no effect) so this crude patch solved my immediate problem:

diff --git a/common/k8s/provisioner/volume.go b/common/k8s/provisioner/volume.go
index 243c1b2..3041eac 100644
--- a/common/k8s/provisioner/volume.go
+++ b/common/k8s/provisioner/volume.go
@@ -28,6 +28,7 @@ import (
        "k8s.io/client-go/tools/cache"
        "k8s.io/client-go/tools/reference"
        "strings"
+       "strconv"
 )
 
 func (p *Provisioner) listAllVolumes(options meta_v1.ListOptions) (runtime.Object, error) {
@@ -152,7 +153,7 @@ func (p *Provisioner) getDockerOptions(params map[string]string, class *storage_
                        for _, option := range listOfOptions {
                                if key == option {
                                        util.LogInfo.Printf("storageclass option matched storage resource option:%s ,overriding the value to %d", key, claimSizeinGiB)
-                                       dockOpts[key] = claimSizeinGiB
+                                       dockOpts[key] = strconv.Itoa(claimSizeinGiB)
                                        break
                                }
                        }
@datamattsson datamattsson changed the title dockOpts["size"] need to be converted to integer dockOpts["size"] need to be converted to string Dec 7, 2018
@datamattsson
Copy link
Contributor Author

Found one more occasion in the same method where claimSizeInGiB needed to be converted. Accidentally trashed the VM I had it on... :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant