Skip to content

Commit b9d6f3a

Browse files
committed
OCPBUGS-88035: Set cluster ownership tag on AWSCluster
Set the kubernetes.io/cluster/<infraID>=owned tag on the AWSCluster object via AdditionalTags so that CAPI-created AWS resources are visible to the installer's destroy logic. Also propagate user-defined resource tags from Infrastructure.Status.PlatformStatus.AWS.ResourceTags to match MAPI behaviour. Without this tag, openshift-install destroy cluster cannot identify CAPI-created resources (VMs, volumes, etc.) and they are leaked. Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
1 parent 05c113e commit b9d6f3a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • pkg/controllers/infracluster

pkg/controllers/infracluster/aws.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ func (r *InfraClusterController) newAWSCluster(providerSpec *mapiv1beta1.AWSMach
102102
return nil, fmt.Errorf("failed to extract control plane load balancer configuration: %w", err)
103103
}
104104

105+
tags := awsv1.Tags{}
106+
107+
if r.Infra.Status.PlatformStatus.AWS != nil {
108+
for _, t := range r.Infra.Status.PlatformStatus.AWS.ResourceTags {
109+
tags[t.Key] = t.Value
110+
}
111+
}
112+
113+
tags[fmt.Sprintf("kubernetes.io/cluster/%s", r.Infra.Status.InfrastructureName)] = "owned"
114+
105115
target := &awsv1.AWSCluster{
106116
ObjectMeta: metav1.ObjectMeta{
107117
Name: r.Infra.Status.InfrastructureName,
@@ -126,6 +136,7 @@ func (r *InfraClusterController) newAWSCluster(providerSpec *mapiv1beta1.AWSMach
126136
Kind: awsv1.ControllerIdentityKind,
127137
Name: "default",
128138
},
139+
AdditionalTags: tags,
129140
// Set control plane load balancer configuration extracted from MAPI machines
130141
ControlPlaneLoadBalancer: controlPlaneLoadBalancer,
131142
SecondaryControlPlaneLoadBalancer: secondaryControlPlaneLoadBalancer,

0 commit comments

Comments
 (0)