Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding logic to apply trustyai prometheus #173

Merged
merged 3 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions components/trustyai/trustyai.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package trustyai

import (
"context"
"fmt"
"path/filepath"

operatorv1 "github.com/openshift/api/operator/v1"
Expand All @@ -13,6 +14,7 @@ import (
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/monitoring"
)

var (
Expand Down Expand Up @@ -50,12 +52,13 @@ func (t *TrustyAI) GetComponentName() string {
return ComponentName
}

func (t *TrustyAI) ReconcileComponent(_ context.Context, cli client.Client, _ *rest.Config, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, _ bool) error {
func (t *TrustyAI) ReconcileComponent(ctx context.Context, cli client.Client, resConf *rest.Config, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, _ bool) error {
var imageParamMap = map[string]string{
"trustyaiServiceImage": "RELATED_IMAGE_ODH_TRUSTYAI_SERVICE_IMAGE",
"trustyaiOperatorImage": "RELATED_IMAGE_ODH_TRUSTYAI_SERVICE_OPERATOR_IMAGE",
}
enabled := t.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

platform, err := deploy.GetPlatform(cli)
if err != nil {
Expand All @@ -76,6 +79,27 @@ func (t *TrustyAI) ReconcileComponent(_ context.Context, cli client.Client, _ *r
}
}
// Deploy TrustyAI Operator
err = deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, t.GetComponentName(), enabled)
return err
if err := deploy.DeployManifestsFromPath(cli, owner, Path, dscispec.ApplicationsNamespace, t.GetComponentName(), enabled); err != nil {
return err
}

// CloudService Monitoring handling
if platform == deploy.ManagedRhods {
if enabled {
if err := monitoring.WaitForDeploymentAvailable(ctx, resConf, ComponentName, dscispec.ApplicationsNamespace, 10, 1); err != nil {
return fmt.Errorf("deployment for %s is not ready to server: %w", ComponentName, err)
}
fmt.Printf("deployment for %s is done, updating monitoring rules\n", ComponentName)
}
if err := t.UpdatePrometheusConfig(cli, enabled && monitoringEnabled, ComponentName); err != nil {
return err
}
if err = deploy.DeployManifestsFromPath(cli, owner,
filepath.Join(deploy.DefaultManifestPath, "monitoring", "prometheus", "apps"),
dscispec.Monitoring.Namespace,
"prometheus", true); err != nil {
return err
}
}
return nil
}
18 changes: 12 additions & 6 deletions config/monitoring/prometheus/apps/prometheus-configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,19 +314,22 @@ data:
metrics_path: /metrics
scheme: http
kubernetes_sd_configs:
- role: endpoints
- role: pod
namespaces:
names:
- <odh_application_namespace>
selectors:
- role: pod
label: 'app.opendatahub.io/trustyai=true'
relabel_configs:
- source_labels: [__meta_kubernetes_service_name]
regex: ^(trustyai-service-operator-controller-manager)$
- source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_part_of]
regex: ^(trustyai)$
target_label: kubernetes_name
action: keep
- source_labels: [__address__]
regex: (.+):(\d+)
target_label: __address__
replacement: ${1}:8080
replacement: ${1}:8080

- job_name: 'RHODS Metrics'
honor_labels: true
Expand Down Expand Up @@ -1184,7 +1187,7 @@ data:

kserve-alerting.rules: |
groups:
- name: SLOs-probe_success
- name: SLOs-probe_success_kserve
rules:
- alert: Kserve Controller Probe Success Burn Rate
annotations:
Expand Down Expand Up @@ -1464,7 +1467,7 @@ data:
record: probe_success:burnrate6h
trustyai-alerting.rules: |
groups:
- name: SLOs-probe_success
- name: SLOs-probe_success_trustyai
rules:
- alert: TrustyAI Controller Probe Success Burn Rate
annotations:
Expand All @@ -1478,6 +1481,7 @@ data:
for: 2m
labels:
severity: critical
instance: trustyai-service-operator-controller-manager
- alert: TrustyAI Controller Probe Success Burn Rate
annotations:
message: 'High error budget burn for {{ $labels.instance }} (current value: {{ $value }}).'
Expand All @@ -1490,6 +1494,7 @@ data:
for: 15m
labels:
severity: critical
instance: trustyai-service-operator-controller-manager
- alert: TrustyAI Controller Probe Success Burn Rate
annotations:
message: 'High error budget burn for {{ $labels.instance }} (current value: {{ $value }}).'
Expand All @@ -1502,3 +1507,4 @@ data:
for: 1h
labels:
severity: warning
instance: trustyai-service-operator-controller-manager
Loading