diff --git a/controllers/constants.go b/controllers/constants.go index ff680244..72a5533e 100644 --- a/controllers/constants.go +++ b/controllers/constants.go @@ -19,6 +19,7 @@ const ( const ( StatusTypeInferenceServicesPresent = "InferenceServicesPresent" StatusTypePVCAvailable = "PVCAvailable" + StatusTypeRouteAvailable = "RouteAvailable" ) // Status reasons @@ -27,4 +28,6 @@ const ( StatusReasonInferenceServicesFound = "InferenceServicesFound" StatusReasonPVCNotFound = "PVCNotFound" StatusReasonPVCFound = "PVCFound" + StatusReasonRouteNotFound = "RouteNotFound" + StatusReasonRouteFound = "RouteFound" ) diff --git a/controllers/statuses.go b/controllers/statuses.go index 10954237..79f4ad49 100644 --- a/controllers/statuses.go +++ b/controllers/statuses.go @@ -50,3 +50,11 @@ func UpdatePVCNotAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) func UpdatePVCAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { saved.SetStatus(StatusTypePVCAvailable, StatusReasonPVCFound, "PersistentVolumeClaim found", v1.ConditionTrue) } + +func UpdateRouteAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { + saved.SetStatus(StatusTypeRouteAvailable, StatusReasonRouteFound, "Route found", v1.ConditionTrue) +} + +func UpdateRouteNotAvailable(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { + saved.SetStatus(StatusTypeRouteAvailable, StatusReasonRouteNotFound, "Route not found", v1.ConditionFalse) +} diff --git a/controllers/trustyaiservice_controller.go b/controllers/trustyaiservice_controller.go index 2a41c2f2..73cb5ee2 100644 --- a/controllers/trustyaiservice_controller.go +++ b/controllers/trustyaiservice_controller.go @@ -198,10 +198,17 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ // Create route err = r.reconcileRoute(instance, ctx) if err != nil { - return RequeueWithError(err) + // Could not create Route object, update status and return. + _, updateErr := r.updateStatus(ctx, instance, UpdateRouteNotAvailable) + if updateErr != nil { + return RequeueWithErrorMessage(ctx, err, "Failed to update status") + } + return RequeueWithErrorMessage(ctx, err, "Failed to get or create Route") } - + _, updateErr := r.updateStatus(ctx, instance, func(saved *trustyaiopendatahubiov1alpha1.TrustyAIService) { + // Set Route has available + UpdateRouteAvailable(saved) // At the end of reconcile, update the instance status to Ready saved.Status.Phase = "Ready" saved.Status.Ready = corev1.ConditionTrue