@@ -253,7 +253,7 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
253
253
return ctrl.Result {}, err
254
254
}
255
255
256
- err , conditions := r .GenerateStatus (ctx , dspa )
256
+ conditions , err := r .GenerateStatus (ctx , dspa )
257
257
if err != nil {
258
258
log .Info (err .Error ())
259
259
return ctrl.Result {}, err
@@ -278,15 +278,15 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
278
278
return ctrl.Result {}, nil
279
279
}
280
280
281
- // isDeploymentInCondition evaluates if condition with "name" is in condition of type "conditionType".
281
+ // handleReadyCondition evaluates if condition with "name" is in condition of type "conditionType".
282
282
// this procedure is valid only for conditions with bool status type, for conditions of non bool type
283
283
// results are undefined.
284
284
func (r * DSPAReconciler ) handleReadyCondition (
285
285
ctx context.Context ,
286
286
dspa * dspav1alpha1.DataSciencePipelinesApplication ,
287
287
name string ,
288
288
condition string ,
289
- ) (error , metav1.Condition ) {
289
+ ) (metav1.Condition , error ) {
290
290
readyCondition := r .buildCondition (condition , dspa , config .MinimumReplicasAvailable )
291
291
deployment := & appsv1.Deployment {}
292
292
@@ -295,15 +295,15 @@ func (r *DSPAReconciler) handleReadyCondition(
295
295
296
296
err := r .Get (ctx , types.NamespacedName {Name : component , Namespace : dspa .Namespace }, deployment )
297
297
if err != nil {
298
- return err , metav1.Condition {}
298
+ return metav1.Condition {}, err
299
299
}
300
300
301
301
// First check if deployment is scaled down, if it is, component is deemed not ready
302
302
if deployment .Spec .Replicas != nil && * deployment .Spec .Replicas == 0 {
303
303
readyCondition .Reason = config .MinimumReplicasAvailable
304
304
readyCondition .Status = metav1 .ConditionFalse
305
305
readyCondition .Message = fmt .Sprintf ("Deployment for component \" %s\" is scaled down." , component )
306
- return nil , readyCondition
306
+ return readyCondition , nil
307
307
}
308
308
309
309
// At this point component is not minimally available, possible scenarios:
@@ -320,7 +320,7 @@ func (r *DSPAReconciler) handleReadyCondition(
320
320
readyCondition .Reason = config .MinimumReplicasAvailable
321
321
readyCondition .Status = metav1 .ConditionTrue
322
322
readyCondition .Message = fmt .Sprintf ("Component [%s] is minimally available." , component )
323
- return nil , readyCondition
323
+ return readyCondition , nil
324
324
}
325
325
326
326
// There are two possible reasons for progress failing, deadline and replica create error:
@@ -332,15 +332,15 @@ func (r *DSPAReconciler) handleReadyCondition(
332
332
readyCondition .Status = metav1 .ConditionFalse
333
333
readyCondition .Message = fmt .Sprintf ("Component [%s] has failed to progress. Reason: [%s]. " +
334
334
"Message: [%s]" , component , progressingCond .Reason , progressingCond .Message )
335
- return nil , readyCondition
335
+ return readyCondition , nil
336
336
}
337
337
338
338
if replicaFailureCond != nil && replicaFailureCond .Status == corev1 .ConditionTrue {
339
339
readyCondition .Reason = config .FailingToDeploy
340
340
readyCondition .Status = metav1 .ConditionFalse
341
341
readyCondition .Message = fmt .Sprintf ("Component's replica [%s] has failed to create. Reason: [%s]. " +
342
342
"Message: [%s]" , component , replicaFailureCond .Reason , replicaFailureCond .Message )
343
- return nil , readyCondition
343
+ return readyCondition , nil
344
344
}
345
345
346
346
// Search through the pods associated with this deployment
@@ -352,7 +352,7 @@ func (r *DSPAReconciler) handleReadyCondition(
352
352
}
353
353
err = r .Client .List (ctx , podList , opts ... )
354
354
if err != nil {
355
- return err , metav1.Condition {}
355
+ return metav1.Condition {}, err
356
356
}
357
357
358
358
hasPodFailures := false
@@ -374,7 +374,7 @@ func (r *DSPAReconciler) handleReadyCondition(
374
374
// We concatenate messages from all failing containers.
375
375
readyCondition .Message = fmt .Sprintf ("Component [%s] is in CrashLoopBackOff. " +
376
376
"Message from pod: [%s]" , component , c .State .Waiting .Message )
377
- return nil , readyCondition
377
+ return readyCondition , nil
378
378
}
379
379
}
380
380
}
@@ -383,31 +383,31 @@ func (r *DSPAReconciler) handleReadyCondition(
383
383
readyCondition .Status = metav1 .ConditionFalse
384
384
readyCondition .Reason = config .FailingToDeploy
385
385
readyCondition .Message = podFailureMessage
386
- return nil , readyCondition
386
+ return readyCondition , nil
387
387
}
388
388
389
389
// No errors encountered, assume deployment is progressing successfully
390
390
// If this DSPA component is minimally available, we are done.
391
391
readyCondition .Reason = config .Deploying
392
392
readyCondition .Status = metav1 .ConditionFalse
393
393
readyCondition .Message = fmt .Sprintf ("Component [%s] is deploying." , component )
394
- return nil , readyCondition
394
+ return readyCondition , nil
395
395
396
396
}
397
397
398
- func (r * DSPAReconciler ) GenerateStatus (ctx context.Context , dspa * dspav1alpha1.DataSciencePipelinesApplication ) (error , []metav1.Condition ) {
398
+ func (r * DSPAReconciler ) GenerateStatus (ctx context.Context , dspa * dspav1alpha1.DataSciencePipelinesApplication ) ([]metav1.Condition , error ) {
399
399
400
- err , apiServerReady := r .handleReadyCondition (ctx , dspa , "ds-pipeline" , config .APIServerReady )
400
+ apiServerReady , err := r .handleReadyCondition (ctx , dspa , "ds-pipeline" , config .APIServerReady )
401
401
if err != nil {
402
- return err , []metav1.Condition {}
402
+ return []metav1.Condition {}, err
403
403
}
404
- err , persistenceAgentReady := r .handleReadyCondition (ctx , dspa , "ds-pipeline-persistenceagent" , config .PersistenceAgentReady )
404
+ persistenceAgentReady , err := r .handleReadyCondition (ctx , dspa , "ds-pipeline-persistenceagent" , config .PersistenceAgentReady )
405
405
if err != nil {
406
- return err , []metav1.Condition {}
406
+ return []metav1.Condition {}, err
407
407
}
408
- err , scheduledWorkflowReady := r .handleReadyCondition (ctx , dspa , "ds-pipeline-scheduledworkflow" , config .ScheduledWorkflowReady )
408
+ scheduledWorkflowReady , err := r .handleReadyCondition (ctx , dspa , "ds-pipeline-scheduledworkflow" , config .ScheduledWorkflowReady )
409
409
if err != nil {
410
- return err , []metav1.Condition {}
410
+ return []metav1.Condition {}, err
411
411
}
412
412
var conditions []metav1.Condition
413
413
conditions = append (conditions , apiServerReady )
@@ -443,7 +443,7 @@ func (r *DSPAReconciler) GenerateStatus(ctx context.Context, dspa *dspav1alpha1.
443
443
}
444
444
}
445
445
446
- return nil , conditions
446
+ return conditions , nil
447
447
}
448
448
449
449
func (r * DSPAReconciler ) PublishMetrics (dspa * dspav1alpha1.DataSciencePipelinesApplication ,
0 commit comments