mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #18959 from jsafrane/devel/cinder-tags
Auto commit by PR queue bot
This commit is contained in:
commit
0f6f521beb
@ -1033,7 +1033,7 @@ func (os *OpenStack) getVolume(diskName string) (volumes.Volume, error) {
|
||||
}
|
||||
|
||||
// Create a volume of given size (in GiB)
|
||||
func (os *OpenStack) CreateVolume(size int) (volumeName string, err error) {
|
||||
func (os *OpenStack) CreateVolume(size int, tags *map[string]string) (volumeName string, err error) {
|
||||
|
||||
sClient, err := openstack.NewBlockStorageV1(os.provider, gophercloud.EndpointOpts{
|
||||
Region: os.region,
|
||||
@ -1045,6 +1045,9 @@ func (os *OpenStack) CreateVolume(size int) (volumeName string, err error) {
|
||||
}
|
||||
|
||||
opts := volumes.CreateOpts{Size: size}
|
||||
if tags != nil {
|
||||
opts.Metadata = *tags
|
||||
}
|
||||
vol, err := volumes.Create(sClient, opts).Extract()
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to create a %d GB volume: %v", size, err)
|
||||
|
@ -210,7 +210,10 @@ func TestVolumes(t *testing.T) {
|
||||
t.Fatalf("Failed to construct/authenticate OpenStack: %s", err)
|
||||
}
|
||||
|
||||
vol, err := os.CreateVolume(1)
|
||||
tags := map[string]string{
|
||||
"test": "value",
|
||||
}
|
||||
vol, err := os.CreateVolume(1, &tags)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot create a new Cinder volume: %v", err)
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ func (util *CinderDiskUtil) CreateVolume(c *cinderVolumeProvisioner) (volumeID s
|
||||
volSizeBytes := c.options.Capacity.Value()
|
||||
// Cinder works with gigabytes, convert to GiB with rounding up
|
||||
volSizeGB := int(volume.RoundUpSize(volSizeBytes, 1024*1024*1024))
|
||||
name, err := cloud.CreateVolume(volSizeGB)
|
||||
name, err := cloud.CreateVolume(volSizeGB, c.options.CloudTags)
|
||||
if err != nil {
|
||||
glog.V(2).Infof("Error creating cinder volume: %v", err)
|
||||
return "", 0, err
|
||||
|
Loading…
Reference in New Issue
Block a user