-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trustyai-explainability:main' into main
- Loading branch information
Showing
18 changed files
with
430 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
trustyaiServiceImage=quay.io/trustyai/trustyai-service:latest | ||
trustyaiOperatorImage=quay.io/trustyai/trustyai-service-operator:latest | ||
oauthProxyImage=quay.io/openshift/origin-oauth-proxy:4.14.0 | ||
kServeServerless=disabled | ||
kServeServerless=disabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
trustyaiServiceImage=quay.io/trustyai/trustyai-service:v0.19.0 | ||
trustyaiOperatorImage=quay.io/trustyai/trustyai-service-operator:v1.25.0 | ||
trustyaiServiceImage=quay.io/trustyai/trustyai-service:latest | ||
trustyaiOperatorImage=quay.io/trustyai/trustyai-service-operator:latest | ||
oauthProxyImage=quay.io/openshift/origin-oauth-proxy:4.14.0 | ||
kServeServerless=enabled | ||
kServeServerless=enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package controllers | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/v1alpha1" | ||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/types" | ||
"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) | ||
if err != nil { | ||
if errors.IsNotFound(err) { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
|
||
for _, cond := range deployment.Status.Conditions { | ||
if cond.Type == appsv1.DeploymentAvailable && cond.Status == corev1.ConditionTrue { | ||
podList := &corev1.PodList{} | ||
listOpts := []client.ListOption{ | ||
client.InNamespace(instance.Namespace), | ||
client.MatchingLabels(deployment.Spec.Selector.MatchLabels), | ||
} | ||
if err := r.List(ctx, podList, listOpts...); err != nil { | ||
return false, err | ||
} | ||
|
||
for _, pod := range podList.Items { | ||
for _, cs := range pod.Status.ContainerStatuses { | ||
if cs.Name == "trustyai-service" { | ||
if cs.State.Running != nil { | ||
return true, nil | ||
} | ||
|
||
if cs.LastTerminationState.Terminated != nil { | ||
termination := cs.LastTerminationState.Terminated | ||
if termination.Reason == "Error" && termination.Message != "" { | ||
if strings.Contains(termination.Message, "Socket fail to connect to host:address") { | ||
return false, nil | ||
} | ||
} | ||
} | ||
|
||
if cs.State.Waiting != nil && cs.State.Waiting.Reason == StateReasonCrashLoopBackOff { | ||
return false, nil | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return false, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package controllers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"reflect" | ||
|
||
trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/v1alpha1" | ||
templateParser "github.com/trustyai-explainability/trustyai-service-operator/controllers/templates" | ||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/types" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
const ( | ||
destinationRuleTemplatePath = "service/destination-rule.tmpl.yaml" | ||
destinationRuleCDRName = "destinationrules.networking.istio.io" | ||
) | ||
|
||
// DestinationRuleConfig has the variables for the DestinationRule template | ||
type DestinationRuleConfig struct { | ||
Name string | ||
Namespace string | ||
DestinationRuleName string | ||
} | ||
|
||
// isDestinationRuleCRDPresent returns true if the DestinationRule CRD is present, false otherwise | ||
func (r *TrustyAIServiceReconciler) isDestinationRuleCRDPresent(ctx context.Context) (bool, error) { | ||
crd := &apiextensionsv1.CustomResourceDefinition{} | ||
|
||
err := r.Get(ctx, types.NamespacedName{Name: destinationRuleCDRName}, crd) | ||
if err != nil { | ||
if !errors.IsNotFound(err) { | ||
return false, fmt.Errorf("error getting "+destinationRuleCDRName+" CRD: %v", err) | ||
} | ||
// Not found | ||
return false, nil | ||
} | ||
|
||
// Found | ||
return true, nil | ||
} | ||
|
||
func (r *TrustyAIServiceReconciler) ensureDestinationRule(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService) error { | ||
|
||
destinationRuleName := instance.Name + "-internal" | ||
|
||
existingDestinationRule := &unstructured.Unstructured{} | ||
existingDestinationRule.SetKind("DestinationRule") | ||
existingDestinationRule.SetAPIVersion("networking.istio.io/v1beta1") | ||
|
||
// Check if the DestinationRule already exists | ||
err := r.Get(ctx, types.NamespacedName{Name: destinationRuleName, Namespace: instance.Namespace}, existingDestinationRule) | ||
if err == nil { | ||
// DestinationRule exists | ||
return nil | ||
} | ||
|
||
if !errors.IsNotFound(err) { | ||
return fmt.Errorf("failed to check for existing DestinationRule: %v", err) | ||
} | ||
|
||
destinationRuleConfig := DestinationRuleConfig{ | ||
Name: instance.Name, | ||
Namespace: instance.Namespace, | ||
DestinationRuleName: destinationRuleName, | ||
} | ||
|
||
var destinationRule *unstructured.Unstructured | ||
destinationRule, err = templateParser.ParseResource[unstructured.Unstructured](destinationRuleTemplatePath, destinationRuleConfig, reflect.TypeOf(&unstructured.Unstructured{})) | ||
if err != nil { | ||
log.FromContext(ctx).Error(err, "could not parse the DestinationRule template") | ||
return err | ||
} | ||
|
||
if err := ctrl.SetControllerReference(instance, destinationRule, r.Scheme); err != nil { | ||
return err | ||
} | ||
|
||
err = r.Create(ctx, destinationRule) | ||
if err != nil { | ||
return fmt.Errorf("failed to create DestinationRule: %v", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.