@@ -1445,6 +1445,60 @@ var _ = Describe("KeycloakRealm controller", func() {
1445
1445
Expect (pod .Spec .Containers [0 ].Env ).Should (Equal (envs ))
1446
1446
Expect (reconciledInstance .Status .SubResourceCatalog ).Should (HaveLen (0 ))
1447
1447
})
1448
+
1449
+ It ("recreates the running reconciler pod if the spec changed" , func () {
1450
+ By ("waiting for the reconciliation" )
1451
+ instanceLookupKey := types.NamespacedName {Name : realmName , Namespace : "default" }
1452
+ reconciledInstance := & v1beta1.KeycloakRealm {}
1453
+ Expect (k8sClient .Get (ctx , instanceLookupKey , reconciledInstance )).Should (BeNil ())
1454
+
1455
+ beforeChangeStatus := reconciledInstance .Status
1456
+ reconciledInstance .Spec .ReconcilerTemplate .Spec .Containers [1 ].Image = "new-image:v1"
1457
+ Expect (k8sClient .Update (ctx , reconciledInstance )).Should (Succeed ())
1458
+
1459
+ Eventually (func () bool {
1460
+ err := k8sClient .Get (ctx , instanceLookupKey , reconciledInstance )
1461
+ if err != nil {
1462
+ return false
1463
+ }
1464
+
1465
+ return beforeChangeStatus .Reconciler != reconciledInstance .Status .Reconciler
1466
+ }, timeout , interval ).Should (BeTrue ())
1467
+
1468
+ By ("making sure there is a reconciler pod" )
1469
+ pod := & corev1.Pod {}
1470
+ Expect (k8sClient .Get (ctx , types.NamespacedName {
1471
+ Name : reconciledInstance .Status .Reconciler ,
1472
+ Namespace : reconciledInstance .Namespace ,
1473
+ }, pod )).Should (Succeed ())
1474
+
1475
+ Expect (pod .Spec .Containers [1 ].Image ).Should (Equal ("new-image:v1" ))
1476
+ })
1477
+
1478
+ It ("recreates the running reconciler pod if the spec annotation is not present" , func () {
1479
+ By ("waiting for the reconciliation" )
1480
+ instanceLookupKey := types.NamespacedName {Name : realmName , Namespace : "default" }
1481
+ reconciledInstance := & v1beta1.KeycloakRealm {}
1482
+ Expect (k8sClient .Get (ctx , instanceLookupKey , reconciledInstance )).Should (BeNil ())
1483
+ beforeChangeStatus := reconciledInstance .Status
1484
+
1485
+ pod := & corev1.Pod {}
1486
+ Expect (k8sClient .Get (ctx , types.NamespacedName {
1487
+ Name : reconciledInstance .Status .Reconciler ,
1488
+ Namespace : reconciledInstance .Namespace ,
1489
+ }, pod )).Should (Succeed ())
1490
+ pod .Annotations = nil
1491
+ Expect (k8sClient .Update (ctx , pod )).Should (Succeed ())
1492
+
1493
+ Eventually (func () bool {
1494
+ err := k8sClient .Get (ctx , instanceLookupKey , reconciledInstance )
1495
+ if err != nil {
1496
+ return false
1497
+ }
1498
+
1499
+ return beforeChangeStatus .Reconciler != reconciledInstance .Status .Reconciler
1500
+ }, timeout , interval ).Should (BeTrue ())
1501
+ })
1448
1502
})
1449
1503
1450
1504
When ("a realm without auth credentials is reconciled" , func () {
0 commit comments