Skip to content

Commit

Permalink
unify clusterid retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Oct 16, 2018
1 parent 2e21063 commit c6efff4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/cloud/aws/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,19 @@ func (a *Actuator) CreateMachine(cluster *clusterv1.Cluster, machine *clusterv1.
},
}

clusterID, ok := getClusterID(machine)
if !ok {
mLog.Errorf("unable to get cluster ID for machine: %q", machine.Name)
return nil, err
}
// Add tags to the created machine
tagList := []*ec2.Tag{}
for _, tag := range machineProviderConfig.Tags {
tagList = append(tagList, &ec2.Tag{Key: aws.String(tag.Name), Value: aws.String(tag.Value)})
}
tagList = append(tagList, []*ec2.Tag{
{Key: aws.String("clusterid"), Value: aws.String(cluster.Name)},
{Key: aws.String("kubernetes.io/cluster/" + cluster.Name), Value: aws.String("owned")},
{Key: aws.String("clusterid"), Value: aws.String(clusterID)},
{Key: aws.String("kubernetes.io/cluster/" + clusterID), Value: aws.String("owned")},
{Key: aws.String("Name"), Value: aws.String(machine.Name)},
}...)

Expand All @@ -350,7 +355,7 @@ func (a *Actuator) CreateMachine(cluster *clusterv1.Cluster, machine *clusterv1.
}
tagVolume := &ec2.TagSpecification{
ResourceType: aws.String("volume"),
Tags: []*ec2.Tag{{Key: aws.String("clusterid"), Value: aws.String(cluster.Name)}},
Tags: []*ec2.Tag{{Key: aws.String("clusterid"), Value: aws.String(clusterID)}},
}

userData := []byte{}
Expand Down

0 comments on commit c6efff4

Please sign in to comment.