@@ -25,8 +25,6 @@ import (
25
25
26
26
certmgr "github.com/IBM/ibm-iam-operator/internal/api/certmanager/v1"
27
27
ctrlcommon "github.com/IBM/ibm-iam-operator/internal/controller/common"
28
- dbconn "github.com/IBM/ibm-iam-operator/internal/database/connectors"
29
- "github.com/IBM/ibm-iam-operator/internal/database/migration"
30
28
"github.com/IBM/ibm-iam-operator/internal/version"
31
29
routev1 "github.com/openshift/api/route/v1"
32
30
appsv1 "k8s.io/api/apps/v1"
@@ -36,9 +34,7 @@ import (
36
34
corev1 "k8s.io/api/core/v1"
37
35
netv1 "k8s.io/api/networking/v1"
38
36
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
39
- "k8s.io/apimachinery/pkg/api/meta"
40
37
"k8s.io/apimachinery/pkg/api/resource"
41
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
42
38
"k8s.io/apimachinery/pkg/runtime"
43
39
"k8s.io/apimachinery/pkg/types"
44
40
"k8s.io/client-go/discovery"
@@ -79,9 +75,6 @@ var memory550 = resource.NewQuantity(550*1024*1024, resource.BinarySI) // 550M
79
75
var memory650 = resource .NewQuantity (650 * 1024 * 1024 , resource .BinarySI ) // 650Mi
80
76
var memory1024 = resource .NewQuantity (1024 * 1024 * 1024 , resource .BinarySI ) // 1024Mi
81
77
82
- // migrationWait is used when still waiting on a result to be produced by the migration worker
83
- var migrationWait time.Duration = 10 * time .Second
84
-
85
78
// opreqWait is used for the resources that interact with and originate from OperandRequests
86
79
var opreqWait time.Duration = 100 * time .Millisecond
87
80
@@ -91,29 +84,6 @@ var defaultLowerWait time.Duration = 5 * time.Millisecond
91
84
// finalizerName is the finalizer appended to the Authentication CR
92
85
var finalizerName = "authentication.operator.ibm.com"
93
86
94
- func (r * AuthenticationReconciler ) loopUntilConditionsSet (ctx context.Context , req ctrl.Request , conditions ... * metav1.Condition ) {
95
- reqLogger := logf .FromContext (ctx )
96
- conditionsSet := false
97
- for ! conditionsSet {
98
- authCR := & operatorv1alpha1.Authentication {}
99
- if result , err := r .getLatestAuthentication (ctx , req , authCR ); subreconciler .ShouldHaltOrRequeue (result , err ) {
100
- reqLogger .Info ("Failed to retrieve Authentication CR for status update; retrying" )
101
- continue
102
- }
103
- for _ , condition := range conditions {
104
- if condition == nil {
105
- continue
106
- }
107
- meta .SetStatusCondition (& authCR .Status .Conditions , * condition )
108
- }
109
- if err := r .Client .Status ().Update (ctx , authCR ); err != nil {
110
- reqLogger .Error (err , "Failed to set conditions on Authentication; retrying" , "conditions" , conditions )
111
- continue
112
- }
113
- conditionsSet = true
114
- }
115
- }
116
-
117
87
func (r * AuthenticationReconciler ) getLatestAuthentication (ctx context.Context , req ctrl.Request , authentication * operatorv1alpha1.Authentication ) (result * ctrl.Result , err error ) {
118
88
reqLogger := logf .FromContext (ctx )
119
89
if err := r .Get (ctx , req .NamespacedName , authentication ); err != nil {
@@ -174,10 +144,7 @@ type AuthenticationReconciler struct {
174
144
DiscoveryClient discovery.DiscoveryClient
175
145
Mutex sync.Mutex
176
146
clusterType ctrlcommon.ClusterType
177
- dbSetupChan chan * migration.Result
178
147
needsRollout bool
179
- GetPostgresDB func (client.Client , context.Context , ctrl.Request ) (dbconn.DBConn , error )
180
- GetMongoDB func (client.Client , context.Context , ctrl.Request ) (dbconn.DBConn , error )
181
148
}
182
149
183
150
// Reconcile is part of the main kubernetes reconciliation loop which aims to
@@ -284,19 +251,6 @@ func (r *AuthenticationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
284
251
return subreconciler .Evaluate (subResult , err )
285
252
}
286
253
287
- // perform any migrations that may be needed before Deployments run
288
- if subResult , err := r .handleMigrations (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
289
- return subreconciler .Evaluate (subResult , err )
290
- }
291
-
292
- if subResult , err := r .setMigrationCompleteStatus (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
293
- return subreconciler .Evaluate (subResult , err )
294
- }
295
-
296
- if result , err := r .handleMongoDBCleanup (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (result , err ) {
297
- return subreconciler .Evaluate (result , err )
298
- }
299
-
300
254
reqLogger .Info ("Creating ibm-iam-operand-restricted serviceaccount" )
301
255
currentSA := & corev1.ServiceAccount {}
302
256
err = r .createSA (instance , currentSA , & needToRequeue )
@@ -307,6 +261,14 @@ func (r *AuthenticationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
307
261
r .createRole (instance )
308
262
r .createRoleBinding (instance )
309
263
264
+ if subResult , err := r .ensureMigrationJobRuns (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
265
+ return subreconciler .Evaluate (subResult , err )
266
+ }
267
+
268
+ if subResult , err := r .checkSAMLPresence (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
269
+ return subreconciler .Evaluate (subResult , err )
270
+ }
271
+
310
272
// Check if this Certificate already exists and create it if it doesn't
311
273
if subResult , err := r .handleCertificates (ctx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
312
274
return subreconciler .Evaluate (subResult , err )
@@ -319,6 +281,11 @@ func (r *AuthenticationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
319
281
return
320
282
}
321
283
284
+ // Check if this Job already exists and create it if it doesn't
285
+ if subResult , err := r .ensureOIDCClientRegistrationJobRuns (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
286
+ return subreconciler .Evaluate (subResult , err )
287
+ }
288
+
322
289
// Check if this Secret already exists and create it if it doesn't
323
290
if subResult , err = r .handleSecrets (ctx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
324
291
return subreconciler .Evaluate (subResult , err )
@@ -332,12 +299,6 @@ func (r *AuthenticationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
332
299
return subreconciler .Evaluate (subResult , err )
333
300
}
334
301
335
- // Check if this Job already exists and create it if it doesn't
336
- currentJob := & batchv1.Job {}
337
- err = r .handleJob (instance , currentJob , & needToRequeue )
338
- if err != nil {
339
- return
340
- }
341
302
// create clusterrole and clusterrolebinding
342
303
if subResult , err := r .handleClusterRoles (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
343
304
return subreconciler .Evaluate (subResult , err )
@@ -351,6 +312,10 @@ func (r *AuthenticationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
351
312
// updates redirecturi annotations to serviceaccount
352
313
r .handleServiceAccount (instance , & needToRequeue )
353
314
315
+ if subResult , err = r .ensureMigrationJobSucceeded (ctx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
316
+ return subreconciler .Evaluate (subResult , err )
317
+ }
318
+
354
319
if subResult , err := r .handleDeployments (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (subResult , err ) {
355
320
return subreconciler .Evaluate (subResult , err )
356
321
}
@@ -371,6 +336,10 @@ func (r *AuthenticationReconciler) Reconcile(ctx context.Context, req ctrl.Reque
371
336
return subreconciler .Evaluate (subResult , err )
372
337
}
373
338
339
+ if result , err := r .handleMongoDBCleanup (reconcileCtx , req ); subreconciler .ShouldHaltOrRequeue (result , err ) {
340
+ return subreconciler .Evaluate (result , err )
341
+ }
342
+
374
343
return subreconciler .Evaluate (subreconciler .DoNotRequeue ())
375
344
}
376
345
@@ -448,12 +417,6 @@ func (r *AuthenticationReconciler) SetupWithManager(mgr ctrl.Manager) error {
448
417
return o .GetLabels ()[ctrlcommon .ManagerVersionLabel ] == version .Version
449
418
})
450
419
451
- r .GetPostgresDB = func (c client.Client , ctx context.Context , req ctrl.Request ) (d dbconn.DBConn , err error ) {
452
- return GetPostgresDB (c , ctx , req )
453
- }
454
- r .GetMongoDB = func (c client.Client , ctx context.Context , req ctrl.Request ) (d dbconn.DBConn , err error ) {
455
- return GetMongoDB (c , ctx , req )
456
- }
457
420
authCtrl .Watches (& operatorv1alpha1.Authentication {}, & handler.EnqueueRequestForObject {}, builder .WithPredicates (bootstrappedPred ))
458
421
return authCtrl .Named ("controller_authentication" ).
459
422
Complete (r )
0 commit comments