Skip to content

Commit 93eb9af

Browse files
committed
fixing removal of InsecureSkipverify
Signed-off-by: Nelesh Singla <117123879+nsingla@users.noreply.github.com>
1 parent 980a5ae commit 93eb9af

3 files changed

Lines changed: 33 additions & 22 deletions

File tree

.github/resources/scripts/configure-mlflow.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,13 @@ if [ -n "${GITHUB_ENV:-}" ]; then
180180
echo "MLFLOW_PORT_FORWARD_NS=$MLFLOW_NAMESPACE" >> "$GITHUB_ENV"
181181
echo "MLFLOW_PORT_FORWARD_SVC=$MLFLOW_SVC" >> "$GITHUB_ENV"
182182
echo "MLFLOW_PORT_FORWARD_REMOTE_PORT=$MLFLOW_PORT" >> "$GITHUB_ENV"
183+
echo "MLFLOW_CA_BUNDLE_PATH=$CA_CERT_FILE" >> "$GITHUB_ENV"
183184
if [ -n "$SA_TOKEN" ]; then
184185
echo "MLFLOW_BEARER_TOKEN=$SA_TOKEN" >> "$GITHUB_ENV"
185-
echo "Exported MLFLOW_BEARER_TOKEN and MLFLOW_WORKSPACE for test helpers"
186+
echo "Exported MLFLOW_BEARER_TOKEN, MLFLOW_WORKSPACE, and MLFLOW_CA_BUNDLE_PATH for test helpers"
186187
else
187188
echo "WARNING: Could not create SA token; MLflow requests may be unauthenticated"
188-
echo "Exported MLFLOW_WORKSPACE only"
189+
echo "Exported MLFLOW_WORKSPACE and MLFLOW_CA_BUNDLE_PATH only"
189190
fi
190191
fi
191192

@@ -198,7 +199,7 @@ CURL_HEADERS=(-H "X-MLflow-Workspace: $KFP_NAMESPACE")
198199

199200
STATUS=000
200201
for i in $(seq 1 30); do
201-
STATUS=$(curl -sk -o /dev/null -w '%{http_code}' --connect-timeout 5 --max-time 10 \
202+
STATUS=$(curl -s --cacert "$CA_CERT_FILE" -o /dev/null -w '%{http_code}' --connect-timeout 5 --max-time 10 \
202203
"${CURL_HEADERS[@]}" "$HEALTH_URL" 2>/dev/null || echo "000")
203204
if [ "$STATUS" != "000" ] && [ "$STATUS" -lt 500 ] 2>/dev/null; then
204205
echo "MLflow backend is healthy on localhost:8080 (HTTPS, status=$STATUS)"

.github/workflows/e2e-test.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ env:
1212
AWS_SECRET_ACCESS_KEY: 'minio123'
1313
AWS_S3_BUCKET: 'mlpipeline'
1414
MLFLOW_TRACKING_URI: "https://localhost:8080/mlflow"
15-
MLFLOW_TRACKING_INSECURE_TLS: "true"
1615
on:
1716
push:
1817
branches:
@@ -357,12 +356,12 @@ jobs:
357356

358357
- name: Deploy MLflow
359358
id: deploy-mlflow
360-
uses: opendatahub-io/mlflow-operator/.github/actions/deploy@b55bcb6aa528ccecf8904745bb0218350b1ff453
359+
uses: opendatahub-io/mlflow-operator/.github/actions/deploy@ec59b7c996ef4d14c448254132e21bd85fd1c28f
361360
if: ${{ steps.create-cluster.outcome == 'success' }}
362361
with:
363362
namespace: 'opendatahub'
364-
mlflow_image: quay.io/${{ github.repository_owner == 'red-hat-data-services' && 'rhoai' || 'opendatahub' }}/mlflow:odh-stable
365-
mlflow_operator_image: quay.io/${{ github.repository_owner == 'red-hat-data-services' && 'rhoai' || 'opendatahub' }}/mlflow-operator:odh-stable
363+
mlflow_image: quay.io/${{ github.repository_owner == 'red-hat-data-services' && 'rhoai' || 'opendatahub' }}/mlflow:odh-stable-490cd77b5b697a8ad0c5a84272983f668b961524
364+
mlflow_operator_image: quay.io/${{ github.repository_owner == 'red-hat-data-services' && 'rhoai' || 'opendatahub' }}/mlflow-operator:ec59b7c996ef4d14c448254132e21bd85fd1c28f
366365
backend_store: ${{ matrix.backend_store }}
367366
artifact_storage: ${{ matrix.artifact_storage }}
368367
registry_store: ${{ matrix.registry_store }}

backend/test/end2end/utils/mlflow_utils.go

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package utils
1717
import (
1818
"context"
1919
"crypto/tls"
20+
"crypto/x509"
2021
"encoding/json"
2122
"fmt"
2223
"net/http"
@@ -38,24 +39,37 @@ import (
3839
)
3940

4041
const (
41-
mlflowEndpointEnv = "MLFLOW_TRACKING_URI"
42-
mlflowInsecureTLSEnv = "MLFLOW_TRACKING_INSECURE_TLS"
43-
mlflowBearerTokenEnv = "MLFLOW_BEARER_TOKEN"
44-
mlflowWorkspaceEnv = "MLFLOW_WORKSPACE"
45-
mlflowPluginKey = "MLflow"
42+
mlflowEndpointEnv = "MLFLOW_TRACKING_URI"
43+
mlflowCABundlePathEnv = "MLFLOW_CA_BUNDLE_PATH"
44+
mlflowBearerTokenEnv = "MLFLOW_BEARER_TOKEN"
45+
mlflowWorkspaceEnv = "MLFLOW_WORKSPACE"
46+
mlflowPluginKey = "MLflow"
4647
)
4748

4849
func getMLflowClient(endpoint string) (*mlflowclient.Client, error) {
49-
insecure := strings.EqualFold(os.Getenv(mlflowInsecureTLSEnv), "true")
5050
workspace := os.Getenv(mlflowWorkspaceEnv)
5151
bearerToken := os.Getenv(mlflowBearerTokenEnv)
52+
53+
tlsConfig := &tls.Config{}
54+
if caBundlePath := os.Getenv(mlflowCABundlePathEnv); caBundlePath != "" {
55+
caCert, err := os.ReadFile(caBundlePath)
56+
if err != nil {
57+
return nil, fmt.Errorf("failed to read CA bundle from %s: %w", caBundlePath, err)
58+
}
59+
pool, err := x509.SystemCertPool()
60+
if err != nil {
61+
pool = x509.NewCertPool()
62+
}
63+
if !pool.AppendCertsFromPEM(caCert) {
64+
return nil, fmt.Errorf("failed to parse CA certificate from %s", caBundlePath)
65+
}
66+
tlsConfig.RootCAs = pool
67+
logger.Log("MLflow client initialized with CA bundle from %s", caBundlePath)
68+
}
69+
5270
httpClient := &http.Client{
53-
Timeout: 30 * time.Second,
54-
Transport: &http.Transport{
55-
TLSClientConfig: &tls.Config{
56-
InsecureSkipVerify: insecure, //nolint:gosec
57-
},
58-
},
71+
Timeout: 30 * time.Second,
72+
Transport: &http.Transport{TLSClientConfig: tlsConfig},
5973
}
6074
client, err := mlflowclient.NewClient(mlflowclient.Config{
6175
Endpoint: endpoint,
@@ -73,9 +87,6 @@ func getMLflowClient(endpoint string) (*mlflowclient.Client, error) {
7387
if workspace != "" {
7488
logger.Log("MLflow client initialized with workspace header: %s", workspace)
7589
}
76-
if insecure {
77-
logger.Log("MLflow client initialized with InsecureSkipVerify=true")
78-
}
7990
return client, nil
8091
}
8192

0 commit comments

Comments
 (0)