Add PV.Name into names of generated GCE/AWS/OSP volumes.

Volume names have now format <cluster-name>-dynamic-<pv-name>.

pv-name is guaranteed to be unique in Kubernetes cluster, adding
<cluster-name> ensures we don't conflict with any running cluster
in the cloud project (kube-controller-manager --cluster-name=XXX).

'kubernetes' is the default cluster name.
This commit is contained in:
Jan Safranek 2016-02-12 09:46:59 +01:00
parent 739be635eb
commit 07fe742714
2 changed files with 8 additions and 3 deletions

View File

@ -1038,7 +1038,7 @@ func (os *OpenStack) getVolume(diskName string) (volumes.Volume, error) {
}
// Create a volume of given size (in GiB)
func (os *OpenStack) CreateVolume(size int, tags *map[string]string) (volumeName string, err error) {
func (os *OpenStack) CreateVolume(name string, size int, tags *map[string]string) (volumeName string, err error) {
sClient, err := openstack.NewBlockStorageV1(os.provider, gophercloud.EndpointOpts{
Region: os.region,
@ -1049,7 +1049,10 @@ func (os *OpenStack) CreateVolume(size int, tags *map[string]string) (volumeName
return "", err
}
opts := volumes.CreateOpts{Size: size}
opts := volumes.CreateOpts{
Name: name,
Size: size,
}
if tags != nil {
opts.Metadata = *tags
}

View File

@ -22,6 +22,8 @@ import (
"testing"
"time"
"k8s.io/kubernetes/pkg/util/rand"
"github.com/rackspace/gophercloud"
)
@ -213,7 +215,7 @@ func TestVolumes(t *testing.T) {
tags := map[string]string{
"test": "value",
}
vol, err := os.CreateVolume(1, &tags)
vol, err := os.CreateVolume("kubernetes-test-volume-"+rand.String(10), 1, &tags)
if err != nil {
t.Fatalf("Cannot create a new Cinder volume: %v", err)
}