@@ -32,6 +32,7 @@ import (
32
32
"k8s.io/apimachinery/pkg/types"
33
33
"k8s.io/utils/ptr"
34
34
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
35
+ "sigs.k8s.io/cluster-api-provider-azure/azure"
35
36
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
36
37
"sigs.k8s.io/cluster-api/util/conditions"
37
38
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -165,6 +166,21 @@ func AKSMarketplaceExtensionSpec(ctx context.Context, inputGetter func() AKSMark
165
166
ensureAKSExtensionAdded (ctx , input , extensionName , "TraefikLabs.TraefikProxy" , extensionClient , amcp )
166
167
ensureAKSExtensionAdded (ctx , input , officialExtensionName , "microsoft.flux" , extensionClient , amcp )
167
168
169
+ By ("Deleting the AKS Marketplace Extension" )
170
+ Eventually (func (g Gomega ) {
171
+ err = mgmtClient .Get (ctx , client.ObjectKey {
172
+ Namespace : input .Cluster .Spec .ControlPlaneRef .Namespace ,
173
+ Name : input .Cluster .Spec .ControlPlaneRef .Name ,
174
+ }, infraControlPlane )
175
+ g .Expect (err ).NotTo (HaveOccurred ())
176
+ infraControlPlane .Spec .Extensions = []infrav1.AKSExtension {}
177
+ g .Expect (mgmtClient .Update (ctx , infraControlPlane )).To (Succeed ())
178
+ }, input .WaitIntervals ... ).Should (Succeed ())
179
+
180
+ By ("Ensuring the AKS Marketplace Extension is deleted from the AzureManagedControlPlane" )
181
+ ensureAKSExtensionDeleted (ctx , input , extensionName , extensionClient , amcp )
182
+ ensureAKSExtensionDeleted (ctx , input , officialExtensionName , extensionClient , amcp )
183
+
168
184
By ("Restoring initial taints for Windows machine pool" )
169
185
expectedTaints = initialTaints
170
186
Eventually (func (g Gomega ) {
@@ -187,3 +203,10 @@ func ensureAKSExtensionAdded(ctx context.Context, input AKSMarketplaceExtensionS
187
203
g .Expect (extension .Properties .ExtensionType ).To (Equal (ptr .To (extensionType )))
188
204
}, input .WaitIntervals ... ).Should (Succeed ())
189
205
}
206
+
207
+ func ensureAKSExtensionDeleted (ctx context.Context , input AKSMarketplaceExtensionSpecInput , extensionName string , extensionClient * armkubernetesconfiguration.ExtensionsClient , amcp * infrav1.AzureManagedControlPlane ) {
208
+ Eventually (func (g Gomega ) {
209
+ _ , err := extensionClient .Get (ctx , amcp .Spec .ResourceGroupName , "Microsoft.ContainerService" , "managedClusters" , input .Cluster .Name , extensionName , nil )
210
+ g .Expect (azure .ResourceNotFound (err )).To (BeTrue ())
211
+ }, input .WaitIntervals ... ).Should (Succeed ())
212
+ }
0 commit comments