AWS: Tag created EBS volumes with our cluster tag

Fix #22792
This commit is contained in:
Justin Santa Barbara 2016-03-10 08:12:17 -05:00
parent d7a87c2285
commit 16730aba96
2 changed files with 13 additions and 4 deletions

View File

@ -161,7 +161,7 @@ type EC2Metadata interface {
type VolumeOptions struct {
CapacityGB int
Tags *map[string]string
Tags map[string]string
}
// Volumes is an interface for managing cloud-provisioned volumes
@ -1400,8 +1400,17 @@ func (s *AWSCloud) CreateDisk(volumeOptions *VolumeOptions) (string, error) {
volumeName := "aws://" + az + "/" + awsID
// apply tags
if volumeOptions.Tags != nil {
if err := s.createTags(awsID, *volumeOptions.Tags); err != nil {
tags := make(map[string]string)
for k, v := range volumeOptions.Tags {
tags[k] = v
}
if s.getClusterName() != "" {
tags[TagNameKubernetesCluster] = s.getClusterName()
}
if len(tags) != 0 {
if err := s.createTags(awsID, tags); err != nil {
// delete the volume and hope it succeeds
_, delerr := s.DeleteDisk(volumeName)
if delerr != nil {

View File

@ -146,7 +146,7 @@ func (util *AWSDiskUtil) CreateVolume(c *awsElasticBlockStoreProvisioner) (volum
requestGB := int(volume.RoundUpSize(requestBytes, 1024*1024*1024))
volumeOptions := &aws.VolumeOptions{
CapacityGB: requestGB,
Tags: &tags,
Tags: tags,
}
name, err := cloud.CreateDisk(volumeOptions)