@@ -19,6 +19,7 @@ package controllers
19
19
import (
20
20
"context"
21
21
"fmt"
22
+
22
23
"github.com/go-logr/logr"
23
24
mf "github.com/manifestival/manifestival"
24
25
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
@@ -217,34 +218,42 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
217
218
return ctrl.Result {}, err
218
219
}
219
220
220
- err = r . ReconcileCommon ( dspa , params )
221
- if err != nil {
222
- return ctrl. Result {}, err
223
- }
221
+ // Get Prereq Status (DB and ObjStore Ready )
222
+ dbAvailable := r . isDatabaseAccessible ( ctx , dspa , params )
223
+ objStoreAvailable := r . isObjectStorageAccessible ( ctx , dspa , params )
224
+ dspa_prereqs_ready := ( dbAvailable && objStoreAvailable )
224
225
225
- err = r .ReconcileAPIServer (ctx , dspa , params )
226
- if err != nil {
227
- return ctrl.Result {}, err
228
- }
226
+ if dspa_prereqs_ready {
227
+ // Manage Common Manifests
228
+ err = r .ReconcileCommon (dspa , params )
229
+ if err != nil {
230
+ return ctrl.Result {}, err
231
+ }
229
232
230
- err = r .ReconcilePersistenceAgent ( dspa , params )
231
- if err != nil {
232
- return ctrl.Result {}, err
233
- }
233
+ err = r .ReconcileAPIServer ( ctx , dspa , params )
234
+ if err != nil {
235
+ return ctrl.Result {}, err
236
+ }
234
237
235
- err = r .ReconcileScheduledWorkflow (dspa , params )
236
- if err != nil {
237
- return ctrl.Result {}, err
238
- }
238
+ err = r .ReconcilePersistenceAgent (dspa , params )
239
+ if err != nil {
240
+ return ctrl.Result {}, err
241
+ }
239
242
240
- err = r .ReconcileUI (dspa , params )
241
- if err != nil {
242
- return ctrl.Result {}, err
243
- }
243
+ err = r .ReconcileScheduledWorkflow (dspa , params )
244
+ if err != nil {
245
+ return ctrl.Result {}, err
246
+ }
244
247
245
- err = r .ReconcileMLMD (dspa , params )
246
- if err != nil {
247
- return ctrl.Result {}, err
248
+ err = r .ReconcileUI (dspa , params )
249
+ if err != nil {
250
+ return ctrl.Result {}, err
251
+ }
252
+
253
+ err = r .ReconcileMLMD (dspa , params )
254
+ if err != nil {
255
+ return ctrl.Result {}, err
256
+ }
248
257
}
249
258
250
259
log .Info ("Updating CR status" )
@@ -255,7 +264,7 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
255
264
return ctrl.Result {}, err
256
265
}
257
266
258
- conditions , err := r .GenerateStatus (ctx , dspa )
267
+ conditions , err := r .GenerateStatus (ctx , dspa , params )
259
268
if err != nil {
260
269
log .Info (err .Error ())
261
270
return ctrl.Result {}, err
@@ -271,24 +280,20 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
271
280
272
281
r .PublishMetrics (
273
282
dspa ,
283
+ util .GetConditionByType (config .DatabaseAvailable , conditions ),
284
+ util .GetConditionByType (config .ObjectStoreAvailable , conditions ),
274
285
util .GetConditionByType (config .APIServerReady , conditions ),
275
286
util .GetConditionByType (config .PersistenceAgentReady , conditions ),
276
287
util .GetConditionByType (config .ScheduledWorkflowReady , conditions ),
277
288
util .GetConditionByType (config .CrReady , conditions ),
278
289
)
279
-
280
290
return ctrl.Result {}, nil
281
291
}
282
292
283
293
// handleReadyCondition evaluates if condition with "name" is in condition of type "conditionType".
284
294
// this procedure is valid only for conditions with bool status type, for conditions of non bool type
285
295
// results are undefined.
286
- func (r * DSPAReconciler ) handleReadyCondition (
287
- ctx context.Context ,
288
- dspa * dspav1alpha1.DataSciencePipelinesApplication ,
289
- name string ,
290
- condition string ,
291
- ) (metav1.Condition , error ) {
296
+ func (r * DSPAReconciler ) handleReadyCondition (ctx context.Context , dspa * dspav1alpha1.DataSciencePipelinesApplication , name string , condition string ) (metav1.Condition , error ) {
292
297
readyCondition := r .buildCondition (condition , dspa , config .MinimumReplicasAvailable )
293
298
deployment := & appsv1.Deployment {}
294
299
@@ -297,7 +302,14 @@ func (r *DSPAReconciler) handleReadyCondition(
297
302
298
303
err := r .Get (ctx , types.NamespacedName {Name : component , Namespace : dspa .Namespace }, deployment )
299
304
if err != nil {
300
- return metav1.Condition {}, err
305
+ if apierrs .IsNotFound (err ) {
306
+ readyCondition .Reason = config .ComponentDeploymentNotFound
307
+ readyCondition .Status = metav1 .ConditionFalse
308
+ readyCondition .Message = fmt .Sprintf ("Deployment for component \" %s\" is missing" , component )
309
+ return readyCondition , nil
310
+ } else {
311
+ return metav1.Condition {}, err
312
+ }
301
313
}
302
314
303
315
// First check if deployment is scaled down, if it is, component is deemed not ready
@@ -397,7 +409,16 @@ func (r *DSPAReconciler) handleReadyCondition(
397
409
398
410
}
399
411
400
- func (r * DSPAReconciler ) GenerateStatus (ctx context.Context , dspa * dspav1alpha1.DataSciencePipelinesApplication ) ([]metav1.Condition , error ) {
412
+ func (r * DSPAReconciler ) GenerateStatus (ctx context.Context , dspa * dspav1alpha1.DataSciencePipelinesApplication , params * DSPAParams ) ([]metav1.Condition , error ) {
413
+ databaseAvailable := r .buildCondition (config .DatabaseAvailable , dspa , config .DatabaseAvailable )
414
+ if r .isDatabaseAccessible (ctx , dspa , params ) {
415
+ databaseAvailable .Status = metav1 .ConditionTrue
416
+ }
417
+
418
+ objStoreAvailable := r .buildCondition (config .ObjectStoreAvailable , dspa , config .ObjectStoreAvailable )
419
+ if r .isObjectStorageAccessible (ctx , dspa , params ) {
420
+ objStoreAvailable .Status = metav1 .ConditionTrue
421
+ }
401
422
402
423
apiServerReady , err := r .handleReadyCondition (ctx , dspa , "ds-pipeline" , config .APIServerReady )
403
424
if err != nil {
@@ -411,7 +432,10 @@ func (r *DSPAReconciler) GenerateStatus(ctx context.Context, dspa *dspav1alpha1.
411
432
if err != nil {
412
433
return []metav1.Condition {}, err
413
434
}
435
+
414
436
var conditions []metav1.Condition
437
+ conditions = append (conditions , databaseAvailable )
438
+ conditions = append (conditions , objStoreAvailable )
415
439
conditions = append (conditions , apiServerReady )
416
440
conditions = append (conditions , persistenceAgentReady )
417
441
conditions = append (conditions , scheduledWorkflowReady )
@@ -420,7 +444,7 @@ func (r *DSPAReconciler) GenerateStatus(ctx context.Context, dspa *dspav1alpha1.
420
444
crReady := r .buildCondition (config .CrReady , dspa , config .MinimumReplicasAvailable )
421
445
crReady .Type = config .CrReady
422
446
423
- componentConditions := []metav1.Condition {apiServerReady , persistenceAgentReady , scheduledWorkflowReady }
447
+ componentConditions := []metav1.Condition {databaseAvailable , objStoreAvailable , apiServerReady , persistenceAgentReady , scheduledWorkflowReady }
424
448
allReady := true
425
449
failureMessages := ""
426
450
for _ , c := range componentConditions {
@@ -449,16 +473,24 @@ func (r *DSPAReconciler) GenerateStatus(ctx context.Context, dspa *dspav1alpha1.
449
473
}
450
474
451
475
func (r * DSPAReconciler ) PublishMetrics (dspa * dspav1alpha1.DataSciencePipelinesApplication ,
452
- apiServerReady , persistenceAgentReady , scheduledWorkflowReady ,
476
+ dbAvailable , objStoreAvailable , apiServerReady , persistenceAgentReady , scheduledWorkflowReady ,
453
477
crReady metav1.Condition ) {
454
478
log := r .Log .WithValues ("namespace" , dspa .Namespace ).WithValues ("dspa_name" , dspa .Name )
455
479
log .Info ("Publishing Ready Metrics" )
456
- if apiServerReady .Status == metav1 .ConditionTrue {
457
- log .Info ("APIServer Ready" )
458
- APIServerReadyMetric .WithLabelValues (dspa .Name , dspa .Namespace ).Set (1 )
480
+ if dbAvailable .Status == metav1 .ConditionTrue {
481
+ log .Info ("Database Accessible" )
482
+ DBAvailableMetric .WithLabelValues (dspa .Name , dspa .Namespace ).Set (1 )
483
+ } else {
484
+ log .Info ("Database Not Yet Accessible" )
485
+ DBAvailableMetric .WithLabelValues (dspa .Name , dspa .Namespace ).Set (0 )
486
+ }
487
+
488
+ if objStoreAvailable .Status == metav1 .ConditionTrue {
489
+ log .Info ("Object Store Accessible" )
490
+ ObjectStoreAvailableMetric .WithLabelValues (dspa .Name , dspa .Namespace ).Set (1 )
459
491
} else {
460
- log .Info ("APIServer Not Ready " )
461
- APIServerReadyMetric .WithLabelValues (dspa .Name , dspa .Namespace ).Set (0 )
492
+ log .Info ("Object Store Not Yet Accessible " )
493
+ ObjectStoreAvailableMetric .WithLabelValues (dspa .Name , dspa .Namespace ).Set (0 )
462
494
}
463
495
464
496
if persistenceAgentReady .Status == metav1 .ConditionTrue {
0 commit comments