Skip to content

Commit

Permalink
Merge pull request opendatahub-io#748 from hbelmiro/RHOAIENG-15689-st…
Browse files Browse the repository at this point in the history
…able

Cherry-pick a8da75c, f10945b and 0e775db
  • Loading branch information
HumairAK authored Nov 13, 2024
2 parents 00e59f1 + 51277ad commit 145bf15
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 29 deletions.
8 changes: 4 additions & 4 deletions controllers/dspipeline_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
// "odh-trusted-ca-bundle" can have fields: "odh-ca-bundle.crt" and "ca-bundle.crt", we need to utilize both
for _, val := range globalCerts {
// If the ca-bundle field is empty, ignore it
if val != "" {
if strings.TrimSpace(val) != "" {
p.APICustomPemCerts = append(p.APICustomPemCerts, []byte(val))
}
}
Expand All @@ -679,7 +679,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
}
dspaProvidedCABundle := util.GetConfigMapValue(dspaCaBundleCfgKey, dspaCAConfigMap)
// If the ca-bundle field is empty, ignore it
if dspaProvidedCABundle != "" {
if strings.TrimSpace(dspaProvidedCABundle) != "" {
p.APICustomPemCerts = append(p.APICustomPemCerts, []byte(dspaProvidedCABundle))
}
}
Expand All @@ -694,7 +694,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
return serviceCACfgErr
}
serviceCABundle := util.GetConfigMapValue(config.OpenshiftServiceCAConfigMapKey, serviceCA)
if serviceCABundle == "" {
if strings.TrimSpace(serviceCABundle) == "" {
return fmt.Errorf("expected key %s from configmap %s not found", config.OpenshiftServiceCAConfigMapKey, config.OpenshiftServiceCAConfigMapName)
}
p.APICustomPemCerts = append(p.APICustomPemCerts, []byte(serviceCABundle))
Expand Down Expand Up @@ -729,7 +729,7 @@ func (p *DSPAParams) ExtractParams(ctx context.Context, dsp *dspa.DataSciencePip
return sysCertsErr
}

if len(certs) != 0 {
if len(bytes.TrimSpace(certs)) != 0 {
p.APICustomPemCerts = append(p.APICustomPemCerts, certs)
}
}
Expand Down
50 changes: 29 additions & 21 deletions tests/dspa_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ package integration
import (
"fmt"
"testing"
"time"

testUtil "github.com/opendatahub-io/data-science-pipelines-operator/tests/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -51,30 +51,38 @@ func (suite *IntegrationTestSuite) TestDSPADeployment() {
}
suite.T().Run("with default MariaDB and Minio", func(t *testing.T) {
t.Run(fmt.Sprintf("should have %d pods", podCount), func(t *testing.T) {
podList := &corev1.PodList{}
// retrieve the running pods only, to allow for multiple reruns of the test suite
listOpts := []client.ListOption{
client.InNamespace(suite.DSPANamespace),
client.MatchingFields{"status.phase": string(corev1.PodRunning)},
}
err := suite.Clientmgr.k8sClient.List(suite.Ctx, podList, listOpts...)
require.NoError(t, err)
actualPodCount := len(podList.Items)
assert.Equal(t, podCount, actualPodCount)
timeout := time.Second * 120
interval := time.Second * 2
actualPodCount := 0

// Print out pod statuses for troubleshooting
if podCount != actualPodCount {
t.Log(fmt.Sprintf("expected %d pods to successfully deploy, got %d instead. Pods in the namespace:", podCount, actualPodCount))
totalPodList := &corev1.PodList{}
listOpts1 := []client.ListOption{
require.Eventually(t, func() bool {
podList := &corev1.PodList{}
// retrieve the running pods only, to allow for multiple reruns of the test suite
listOpts := []client.ListOption{
client.InNamespace(suite.DSPANamespace),
client.MatchingFields{"status.phase": string(corev1.PodRunning)},
}
err1 := suite.Clientmgr.k8sClient.List(suite.Ctx, totalPodList, listOpts1...)
require.NoError(t, err1)
for _, pod := range totalPodList.Items {
t.Log(fmt.Sprintf("Pod Name: %s, Status: %s", pod.Name, pod.Status.Phase))
err := suite.Clientmgr.k8sClient.List(suite.Ctx, podList, listOpts...)
require.NoError(suite.T(), err)
actualPodCount = len(podList.Items)

// Print out pod statuses for troubleshooting
if podCount != actualPodCount {
t.Log(fmt.Sprintf("expected %d pods to successfully deploy, got %d instead. Pods in the namespace:", podCount, actualPodCount))
totalPodList := &corev1.PodList{}
listOpts1 := []client.ListOption{
client.InNamespace(suite.DSPANamespace),
}
err1 := suite.Clientmgr.k8sClient.List(suite.Ctx, totalPodList, listOpts1...)
require.NoError(t, err1)
for _, pod := range totalPodList.Items {
t.Log(fmt.Sprintf("Pod Name: %s, Status: %s", pod.Name, pod.Status.Phase))
}
return false
} else {
return true
}
}
}, timeout, interval)
})
for _, deployment := range deployments {
t.Run(fmt.Sprintf("should have a ready %s deployment", deployment), func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions tests/resources/test-pipeline-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.9.0'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.10.0'\
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\
$0\" \"$@\"\n"
- sh
Expand Down Expand Up @@ -77,4 +77,4 @@ root:
Output:
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.9.0
sdkVersion: kfp-2.10.0
4 changes: 2 additions & 2 deletions tests/resources/test-pipeline-with-custom-pip-server-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ deploymentSpec:
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location --index-url https://nginx-service.test-pypiserver.svc.cluster.local/simple/\
\ 'kfp==2.9.0' '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"\
\ 'kfp==2.10.0' '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"\
3.9\"' && python3 -m pip install --quiet --no-warn-script-location --index-url\
\ https://nginx-service.test-pypiserver.svc.cluster.local/simple/ 'numpy'\
\ && \"$0\" \"$@\"\n"
Expand Down Expand Up @@ -66,4 +66,4 @@ root:
Output:
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.9.0
sdkVersion: kfp-2.10.0

0 comments on commit 145bf15

Please sign in to comment.