@@ -23,6 +23,7 @@ import (
23
23
mf "github.com/manifestival/manifestival"
24
24
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
25
25
"github.com/opendatahub-io/data-science-pipelines-operator/controllers/config"
26
+ "github.com/opendatahub-io/data-science-pipelines-operator/controllers/util"
26
27
routev1 "github.com/openshift/api/route/v1"
27
28
appsv1 "k8s.io/api/apps/v1"
28
29
corev1 "k8s.io/api/core/v1"
@@ -121,16 +122,6 @@ func (r *DSPAReconciler) buildCondition(conditionType string, dspa *dspav1alpha1
121
122
return condition
122
123
}
123
124
124
- func GetDeploymentCondition (status appsv1.DeploymentStatus , condType appsv1.DeploymentConditionType ) * appsv1.DeploymentCondition {
125
- for i := range status .Conditions {
126
- c := status .Conditions [i ]
127
- if c .Type == condType {
128
- return & c
129
- }
130
- }
131
- return nil
132
- }
133
-
134
125
//+kubebuilder:rbac:groups=datasciencepipelinesapplications.opendatahub.io,resources=datasciencepipelinesapplications,verbs=get;list;watch;create;update;patch;delete
135
126
//+kubebuilder:rbac:groups=datasciencepipelinesapplications.opendatahub.io,resources=datasciencepipelinesapplications/status,verbs=get;update;patch
136
127
//+kubebuilder:rbac:groups=datasciencepipelinesapplications.opendatahub.io,resources=datasciencepipelinesapplications/finalizers,verbs=update
@@ -278,26 +269,15 @@ func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
278
269
279
270
r .PublishMetrics (
280
271
dspa ,
281
- GetConditionByType (config .APIServerReady , conditions ),
282
- GetConditionByType (config .PersistenceAgentReady , conditions ),
283
- GetConditionByType (config .ScheduledWorkflowReady , conditions ),
284
- GetConditionByType (config .CrReady , conditions ),
272
+ util . GetConditionByType (config .APIServerReady , conditions ),
273
+ util . GetConditionByType (config .PersistenceAgentReady , conditions ),
274
+ util . GetConditionByType (config .ScheduledWorkflowReady , conditions ),
275
+ util . GetConditionByType (config .CrReady , conditions ),
285
276
)
286
277
287
278
return ctrl.Result {}, nil
288
279
}
289
280
290
- // GetConditionByType returns condition of type T if it exists in conditions, otherwise
291
- // return empty condition struct.
292
- func GetConditionByType (t string , conditions []metav1.Condition ) metav1.Condition {
293
- for _ , c := range conditions {
294
- if c .Type == t {
295
- return c
296
- }
297
- }
298
- return metav1.Condition {}
299
- }
300
-
301
281
// isDeploymentInCondition evaluates if condition with "name" is in condition of type "conditionType".
302
282
// this procedure is valid only for conditions with bool status type, for conditions of non bool type
303
283
// results are undefined.
@@ -331,9 +311,9 @@ func (r *DSPAReconciler) handleReadyCondition(
331
311
// 2. Component is still deploying
332
312
// We check for (1), and if no errors are found we presume (2)
333
313
334
- progressingCond := GetDeploymentCondition (deployment .Status , appsv1 .DeploymentProgressing )
335
- availableCond := GetDeploymentCondition (deployment .Status , appsv1 .DeploymentAvailable )
336
- replicaFailureCond := GetDeploymentCondition (deployment .Status , appsv1 .DeploymentReplicaFailure )
314
+ progressingCond := util . GetDeploymentCondition (deployment .Status , appsv1 .DeploymentProgressing )
315
+ availableCond := util . GetDeploymentCondition (deployment .Status , appsv1 .DeploymentAvailable )
316
+ replicaFailureCond := util . GetDeploymentCondition (deployment .Status , appsv1 .DeploymentReplicaFailure )
337
317
338
318
if availableCond != nil && availableCond .Status == corev1 .ConditionTrue {
339
319
// If this DSPA component is minimally available, we are done.
0 commit comments