Skip to content

Commit

Permalink
feat: Add Route status
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira committed Oct 16, 2023
1 parent 6365ffa commit de4b81b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions controllers/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
const (
StatusTypeInferenceServicesPresent = "InferenceServicesPresent"
StatusTypePVCAvailable = "PVCAvailable"
StatusTypeRouteAvailable = "RouteAvailable"
)

// Status reasons
Expand All @@ -27,4 +28,6 @@ const (
StatusReasonInferenceServicesFound = "InferenceServicesFound"
StatusReasonPVCNotFound = "PVCNotFound"
StatusReasonPVCFound = "PVCFound"
StatusReasonRouteNotFound = "RouteNotFound"
StatusReasonRouteFound = "RouteFound"
)
8 changes: 8 additions & 0 deletions controllers/statuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
11 changes: 9 additions & 2 deletions controllers/trustyaiservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit de4b81b

Please sign in to comment.