@@ -45,6 +45,7 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
45
45
var hubWorkWebhookDeployment = fmt .Sprintf ("%s-work-webhook" , clusterManagerName )
46
46
var hubAddOnManagerDeployment = fmt .Sprintf ("%s-addon-manager-controller" , clusterManagerName )
47
47
var hubWorkControllerDeployment = fmt .Sprintf ("%s-work-controller" , clusterManagerName )
48
+ var hubAddonManagerDeployment = fmt .Sprintf ("%s-addon-manager-controller" , clusterManagerName )
48
49
var hubRegistrationClusterRole = fmt .Sprintf ("open-cluster-management:%s-registration:controller" , clusterManagerName )
49
50
var hubRegistrationWebhookClusterRole = fmt .Sprintf ("open-cluster-management:%s-registration:webhook" , clusterManagerName )
50
51
var hubWorkWebhookClusterRole = fmt .Sprintf ("open-cluster-management:%s-registration:webhook" , clusterManagerName )
@@ -200,6 +201,13 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
200
201
return nil
201
202
}, eventuallyTimeout , eventuallyInterval ).Should (gomega .BeNil ())
202
203
204
+ gomega .Eventually (func () error {
205
+ if _ , err := hostedKubeClient .AppsV1 ().Deployments (hubNamespaceHosted ).Get (hostedCtx , hubAddonManagerDeployment , metav1.GetOptions {}); err != nil {
206
+ return err
207
+ }
208
+ return nil
209
+ }, eventuallyTimeout , eventuallyInterval ).Should (gomega .BeNil ())
210
+
203
211
// Check service
204
212
gomega .Eventually (func () error {
205
213
if _ , err := hostedKubeClient .CoreV1 ().Services (hubNamespaceHosted ).Get (hostedCtx , "cluster-manager-registration-webhook" , metav1.GetOptions {}); err != nil {
@@ -252,55 +260,37 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
252
260
registrationValidtingWebhook := "managedclustervalidators.admission.cluster.open-cluster-management.io"
253
261
254
262
// Should not apply the webhook config if the replica and observed is not set
255
- _ , err := hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (hostedCtx , registrationValidtingWebhook , metav1.GetOptions {})
263
+ _ , err := hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (
264
+ hostedCtx , registrationValidtingWebhook , metav1.GetOptions {})
256
265
gomega .Expect (err ).To (gomega .HaveOccurred ())
257
266
258
267
workValidtingWebhook := "manifestworkvalidators.admission.work.open-cluster-management.io"
259
268
// Should not apply the webhook config if the replica and observed is not set
260
- _ , err = hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (hostedCtx , workValidtingWebhook , metav1.GetOptions {})
269
+ _ , err = hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (
270
+ hostedCtx , workValidtingWebhook , metav1.GetOptions {})
261
271
gomega .Expect (err ).To (gomega .HaveOccurred ())
262
272
263
273
updateDeploymentStatus (hostedKubeClient , hubNamespaceHosted , hubRegistrationWebhookDeployment )
264
274
updateDeploymentStatus (hostedKubeClient , hubNamespaceHosted , hubWorkWebhookDeployment )
265
275
updateDeploymentStatus (hostedKubeClient , hubNamespaceHosted , hubWorkControllerDeployment )
276
+ updateDeploymentStatus (hostedKubeClient , hubNamespaceHosted , hubAddonManagerDeployment )
266
277
267
278
gomega .Eventually (func () error {
268
- if _ , err := hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (hostedCtx , registrationValidtingWebhook , metav1.GetOptions {}); err != nil {
269
- return err
270
- }
271
- return nil
279
+ _ , err := hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (
280
+ hostedCtx , registrationValidtingWebhook , metav1.GetOptions {})
281
+ return err
272
282
}, eventuallyTimeout , eventuallyInterval ).Should (gomega .BeNil ())
273
283
274
- gomega .Expect (err ).To (gomega .HaveOccurred ())
275
-
276
284
gomega .Eventually (func () error {
277
- if _ , err := hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (hostedCtx , workValidtingWebhook , metav1.GetOptions {}); err != nil {
278
- return err
279
- }
280
- return nil
285
+ _ , err := hostedKubeClient .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Get (
286
+ hostedCtx , workValidtingWebhook , metav1.GetOptions {})
287
+ return err
281
288
}, eventuallyTimeout , eventuallyInterval ).Should (gomega .BeNil ())
282
289
283
290
util .AssertClusterManagerCondition (clusterManagerName , hostedOperatorClient , "Applied" , "ClusterManagerApplied" , metav1 .ConditionTrue )
284
291
})
285
292
286
293
ginkgo .It ("should have expected resource created/deleted successfully when feature gates AddOnManager enabled/disabled" , func () {
287
- // Check addon manager default mode
288
- gomega .Eventually (func () error {
289
- clusterManager , err := hostedOperatorClient .OperatorV1 ().ClusterManagers ().Get (context .Background (), clusterManagerName , metav1.GetOptions {})
290
- if err != nil {
291
- return err
292
- }
293
-
294
- // Check addon manager enabled mode
295
- clusterManager .Spec .AddOnManagerConfiguration = & operatorapiv1.AddOnManagerConfiguration {
296
- FeatureGates : []operatorapiv1.FeatureGate {
297
- {Feature : "AddonManagement" , Mode : operatorapiv1 .FeatureGateModeTypeEnable },
298
- },
299
- }
300
- _ , err = hostedOperatorClient .OperatorV1 ().ClusterManagers ().Update (context .Background (), clusterManager , metav1.UpdateOptions {})
301
- return err
302
- }, eventuallyTimeout , eventuallyInterval ).Should (gomega .BeNil ())
303
-
304
294
// Check clusterrole/clusterrolebinding
305
295
gomega .Eventually (func () error {
306
296
if _ , err := hostedKubeClient .RbacV1 ().ClusterRoles ().Get (context .Background (), hubAddOnManagerClusterRole , metav1.GetOptions {}); err != nil {
@@ -350,8 +340,15 @@ var _ = ginkgo.Describe("ClusterManager Hosted Mode", func() {
350
340
return err
351
341
}
352
342
353
- clusterManager .Spec .AddOnManagerConfiguration .FeatureGates = []operatorapiv1.FeatureGate {}
354
- clusterManager , err = hostedOperatorClient .OperatorV1 ().ClusterManagers ().Update (context .Background (), clusterManager , metav1.UpdateOptions {})
343
+ clusterManager .Spec .AddOnManagerConfiguration = & operatorapiv1.AddOnManagerConfiguration {
344
+ FeatureGates : []operatorapiv1.FeatureGate {
345
+ {
346
+ Feature : "AddonManagement" ,
347
+ Mode : operatorapiv1 .FeatureGateModeTypeDisable ,
348
+ },
349
+ },
350
+ }
351
+ _ , err = hostedOperatorClient .OperatorV1 ().ClusterManagers ().Update (context .Background (), clusterManager , metav1.UpdateOptions {})
355
352
return err
356
353
}, eventuallyTimeout , eventuallyInterval ).Should (gomega .BeNil ())
357
354
0 commit comments