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

Weekly sync up of dev/lm-eval branch #278

Merged
merged 12 commits into from
Aug 23, 2024
Merged
2 changes: 1 addition & 1 deletion controllers/tas/config_maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (r *TrustyAIServiceReconciler) getKServeServerlessConfig(ctx context.Contex
// Define the key for the ConfigMap
configMapKey := types.NamespacedName{
Namespace: r.Namespace,
Name: constants.ConfigMap,
Name: imageConfigMap,
}

// Create an empty ConfigMap object
Expand Down
1 change: 1 addition & 0 deletions controllers/tas/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (

// Configuration constants
const (
imageConfigMap = "trustyai-service-operator-config"
configMapOAuthProxyImageKey = "oauthProxyImage"
configMapServiceImageKey = "trustyaiServiceImage"
configMapkServeServerlessKey = "kServeServerless"
Expand Down
1 change: 1 addition & 0 deletions controllers/tas/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (r *TrustyAIServiceReconciler) createDeploymentObject(ctx context.Context,
PVCClaimName: pvcName,
CustomCertificatesBundle: caBunble,
Version: constants.Version,
BatchSize: batchSize,
}

if instance.Spec.Storage.IsStorageDatabase() {
Expand Down
24 changes: 19 additions & 5 deletions controllers/tas/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ var _ = Describe("TrustyAI operator", func() {
configMap := &corev1.ConfigMap{}
err := k8sClient.Get(ctx, types.NamespacedName{
Namespace: operatorNamespace,
Name: constants.ConfigMap,
Name: imageConfigMap,
}, configMap)

// If the ConfigMap exists, delete it
Expand All @@ -360,7 +360,7 @@ var _ = Describe("TrustyAI operator", func() {
namespace := "trusty-ns-a-1-db"
instance = createDefaultDBCustomResource(namespace)
WaitFor(func() error {
secret := createDatabaseConfiguration(namespace, defaultDatabaseConfigurationName, "mysql")
secret := createDatabaseConfiguration(namespace, defaultDatabaseConfigurationName, "mysql", "trustyai_service")
return k8sClient.Create(ctx, secret)
}, "failed to create ConfigMap")
setupAndTestDeploymentDefault(instance, namespace)
Expand All @@ -369,7 +369,7 @@ var _ = Describe("TrustyAI operator", func() {
namespace := "trusty-ns-a-1-db"
instance = createDefaultDBCustomResource(namespace)
WaitFor(func() error {
secret := createDatabaseConfiguration(namespace, defaultDatabaseConfigurationName, "mariadb")
secret := createDatabaseConfiguration(namespace, defaultDatabaseConfigurationName, "mariadb", "trustyai_service")
return k8sClient.Create(ctx, secret)
}, "failed to create ConfigMap")
setupAndTestDeploymentDefault(instance, namespace)
Expand Down Expand Up @@ -585,9 +585,16 @@ var _ = Describe("TrustyAI operator", func() {
Expect(envVar.ValueFrom.SecretKeyRef.Name).To(Equal(defaultDatabaseConfigurationName), "Secret name does not match")
Expect(envVar.ValueFrom.SecretKeyRef.Key).To(Equal("databasePort"), "Secret key does not match")

envVar = foundEnvVar(trustyaiServiceContainer.Env, "DATABASE_NAME")
Expect(envVar).NotTo(BeNil(), "Env var DATABASE_NAME not found")
Expect(envVar.ValueFrom).NotTo(BeNil(), "Env var DATABASE_NAME does not have ValueFrom set")
Expect(envVar.ValueFrom.SecretKeyRef).NotTo(BeNil(), "Env var DATABASE_NAME is not using SecretKeyRef")
Expect(envVar.ValueFrom.SecretKeyRef.Name).To(Equal(defaultDatabaseConfigurationName), "Secret name does not match")
Expect(envVar.ValueFrom.SecretKeyRef.Key).To(Equal("databaseName"), "Secret key does not match")

envVar = foundEnvVar(trustyaiServiceContainer.Env, "QUARKUS_DATASOURCE_JDBC_URL")
Expect(envVar).NotTo(BeNil(), "Env var QUARKUS_DATASOURCE_JDBC_URL not found")
Expect(envVar.Value).To(Equal("jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/trustyai_database"))
Expect(envVar.Value).To(Equal("jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/${DATABASE_NAME}"))

})

Expand Down Expand Up @@ -696,9 +703,16 @@ var _ = Describe("TrustyAI operator", func() {
Expect(envVar.ValueFrom.SecretKeyRef.Name).To(Equal(defaultDatabaseConfigurationName), "Secret name does not match")
Expect(envVar.ValueFrom.SecretKeyRef.Key).To(Equal("databasePort"), "Secret key does not match")

envVar = foundEnvVar(trustyaiServiceContainer.Env, "DATABASE_NAME")
Expect(envVar).NotTo(BeNil(), "Env var DATABASE_NAME not found")
Expect(envVar.ValueFrom).NotTo(BeNil(), "Env var DATABASE_NAME does not have ValueFrom set")
Expect(envVar.ValueFrom.SecretKeyRef).NotTo(BeNil(), "Env var DATABASE_NAME is not using SecretKeyRef")
Expect(envVar.ValueFrom.SecretKeyRef.Name).To(Equal(defaultDatabaseConfigurationName), "Secret name does not match")
Expect(envVar.ValueFrom.SecretKeyRef.Key).To(Equal("databaseName"), "Secret key does not match")

envVar = foundEnvVar(trustyaiServiceContainer.Env, "QUARKUS_DATASOURCE_JDBC_URL")
Expect(envVar).NotTo(BeNil(), "Env var QUARKUS_DATASOURCE_JDBC_URL not found")
Expect(envVar.Value).To(Equal("jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/trustyai_database"))
Expect(envVar.Value).To(Equal("jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/${DATABASE_NAME}"))

})

Expand Down
4 changes: 2 additions & 2 deletions controllers/tas/inference_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (r *TrustyAIServiceReconciler) patchEnvVarsByLabelForDeployments(ctx contex
}

// Build the payload processor endpoint
url := utils.GenerateServiceURL(crName, namespace) + "/consumer/kserve/v2"
url := utils.GenerateTLSServiceURL(crName, namespace) + "/consumer/kserve/v2"

// Patch environment variables for the Deployments
if shouldContinue, err := r.patchEnvVarsForDeployments(ctx, instance, deployments, envVarName, url, remove); err != nil {
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *TrustyAIServiceReconciler) handleInferenceServices(ctx context.Context,
// patchKServe adds a TrustyAI service as an InferenceLogger to a KServe InferenceService
func (r *TrustyAIServiceReconciler) patchKServe(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, infService kservev1beta1.InferenceService, namespace string, crName string, remove bool) error {

url := utils.GenerateServiceURL(crName, namespace)
url := utils.GenerateNonTLSServiceURL(crName, namespace)

if remove {
if infService.Spec.Predictor.Logger == nil || *infService.Spec.Predictor.Logger.URL != url {
Expand Down
9 changes: 8 additions & 1 deletion controllers/tas/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ func (r *TrustyAIServiceReconciler) findDatabaseSecret(ctx context.Context, inst
// validateDatabaseSecret validates the DB configuration secret
func (r *TrustyAIServiceReconciler) validateDatabaseSecret(secret *corev1.Secret) error {

mandatoryKeys := []string{"databaseKind", "databaseUsername", "databasePassword", "databaseService", "databasePort"}
mandatoryKeys := []string{
"databaseKind",
"databaseUsername",
"databasePassword",
"databaseService",
"databasePort",
"databaseName",
}

for _, key := range mandatoryKeys {
value, exists := secret.Data[key]
Expand Down
3 changes: 2 additions & 1 deletion controllers/tas/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@ func createSecret(namespace string, secretName string, data map[string]string) *
}
}

func createDatabaseConfiguration(namespace string, name string, dbKind string) *corev1.Secret {
func createDatabaseConfiguration(namespace string, name string, dbKind string, databaseName string) *corev1.Secret {
return createSecret(namespace, name, map[string]string{
"databaseKind": dbKind,
"databaseUsername": "foo",
"databasePassword": "bar",
"databaseService": "mariadb-service",
"databasePort": "3306",
"databaseName": databaseName,
})
}

Expand Down
13 changes: 9 additions & 4 deletions controllers/tas/templates/service/deployment.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
maxUnavailable: 1
maxSurge: 0
replicas: 1
selector:
matchLabels:
Expand Down Expand Up @@ -93,11 +93,16 @@ spec:
secretKeyRef:
name: {{ .Instance.Spec.Storage.DatabaseConfigurations }}
key: databasePort
- name: DATABASE_NAME
valueFrom:
secretKeyRef:
name: {{ .Instance.Spec.Storage.DatabaseConfigurations }}
key: databaseName
- name: QUARKUS_DATASOURCE_JDBC_URL
{{ if .UseDBTLSCerts }}
value: "jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/trustyai_database?sslMode=verify-ca&serverSslCert=/etc/tls/db/tls.crt"
value: "jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/${DATABASE_NAME}?sslMode=verify-ca&serverSslCert=/etc/tls/db/tls.crt"
{{ else }}
value: "jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/trustyai_database"
value: "jdbc:${QUARKUS_DATASOURCE_DB_KIND}://${DATABASE_SERVICE}:${DATABASE_PORT}/${DATABASE_NAME}"
{{ end }}
- name: SERVICE_DATA_FORMAT
value: "HIBERNATE"
Expand Down
11 changes: 8 additions & 3 deletions controllers/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ func GetNamespace() (string, error) {
return string(ns), nil
}

// generateServiceURL generates an internal URL for a TrustyAI service
func GenerateServiceURL(crName string, namespace string) string {
return "http://" + crName + "." + namespace + ".svc.cluster.local"
// generateTLSServiceURL generates an internal URL for a TLS-enabled TrustyAI service
func GenerateTLSServiceURL(crName string, namespace string) string {
return "https://" + crName + "." + namespace + ".svc"
}

// generateNonTLSServiceURL generates an internal URL for a TrustyAI service
func GenerateNonTLSServiceURL(crName string, namespace string) string {
return "http://" + crName + "." + namespace + ".svc"
}
Loading