Skip to content

Commit

Permalink
Add readiness probes (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira authored Oct 14, 2024
1 parent 91237c5 commit 7979767
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion controllers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

// checkDatabaseAccessible checks if the TrustyAI service pod failed with database issues.
func (r *TrustyAIServiceReconciler) checkDatabaseAccessible(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) (bool, error) {
deployment := &appsv1.Deployment{}
err := r.Get(ctx, types.NamespacedName{Name: instance.Name, Namespace: instance.Namespace}, deployment)
Expand Down
7 changes: 6 additions & 1 deletion controllers/statuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ func (r *TrustyAIServiceReconciler) reconcileStatuses(ctx context.Context, insta
UpdateRouteAvailable(saved)

if instance.Spec.Storage.IsStorageDatabase() || instance.IsMigration() {
UpdateDBAvailable(saved)
if status.DBReady {
UpdateDBAvailable(saved)
} else {
UpdateDBConnectionError(saved)
return
}
}

UpdateTrustyAIServiceAvailable(saved)
Expand Down
14 changes: 14 additions & 0 deletions controllers/templates/service/deployment.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ spec:
- name: STORAGE_MIGRATION_CONFIG_FROM_FILENAME
value: {{ .Instance.Spec.Data.Filename }}
{{ end }}
readinessProbe:
httpGet:
path: /q/health/ready
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 2
livenessProbe:
httpGet:
path: /q/health/live
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 2
volumeMounts:
- name: {{ .Instance.Name }}-internal
readOnly: false
Expand Down

0 comments on commit 7979767

Please sign in to comment.