Skip to content

Commit f528a75

Browse files
committed
fix: propagate AdditionalTags from AWSCluster to storage volumes
* see #4511
1 parent b90c18c commit f528a75

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

controllers/awsmachine_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
589589
}
590590

591591
if instance != nil {
592-
r.ensureStorageTags(ec2svc, instance, machineScope.AWSMachine)
592+
r.ensureStorageTags(ec2svc, instance, machineScope.AWSMachine, machineScope.AdditionalTags())
593593
}
594594

595595
if err := r.reconcileLBAttachment(machineScope, elbScope, instance); err != nil {
@@ -1111,20 +1111,20 @@ func (r *AWSMachineReconciler) indexAWSMachineByInstanceID(o client.Object) []st
11111111
return nil
11121112
}
11131113

1114-
func (r *AWSMachineReconciler) ensureStorageTags(ec2svc services.EC2Interface, instance *infrav1.Instance, machine *infrav1.AWSMachine) {
1114+
func (r *AWSMachineReconciler) ensureStorageTags(ec2svc services.EC2Interface, instance *infrav1.Instance, machine *infrav1.AWSMachine, additionalTags map[string]string) {
11151115
annotations, err := r.machineAnnotationJSON(machine, VolumeTagsLastAppliedAnnotation)
11161116
if err != nil {
11171117
r.Log.Error(err, "Failed to fetch the annotations for volume tags")
11181118
}
11191119
for _, volumeID := range instance.VolumeIDs {
11201120
if subAnnotation, ok := annotations[volumeID].(map[string]interface{}); ok {
1121-
newAnnotation, err := r.ensureVolumeTags(ec2svc, aws.String(volumeID), subAnnotation, machine.Spec.AdditionalTags)
1121+
newAnnotation, err := r.ensureVolumeTags(ec2svc, aws.String(volumeID), subAnnotation, additionalTags)
11221122
if err != nil {
11231123
r.Log.Error(err, "Failed to fetch the changed volume tags in EC2 instance")
11241124
}
11251125
annotations[volumeID] = newAnnotation
11261126
} else {
1127-
newAnnotation, err := r.ensureVolumeTags(ec2svc, aws.String(volumeID), make(map[string]interface{}), machine.Spec.AdditionalTags)
1127+
newAnnotation, err := r.ensureVolumeTags(ec2svc, aws.String(volumeID), make(map[string]interface{}), additionalTags)
11281128
if err != nil {
11291129
r.Log.Error(err, "Failed to fetch the changed volume tags in EC2 instance")
11301130
}

0 commit comments

Comments
 (0)