Skip to content

Commit

Permalink
UPSTREAM: 11578: fix(backend): Replaced hardcoded ServiceAccount with…
Browse files Browse the repository at this point in the history
… default config

Signed-off-by: Helber Belmiro <[email protected]>
  • Loading branch information
hbelmiro committed Feb 5, 2025
1 parent aeb0151 commit 91de12d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
34 changes: 34 additions & 0 deletions backend/src/apiserver/resource/resource_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,40 @@ func TestCreateJob_ThroughWorkflowSpecV2(t *testing.T) {
assert.Equal(t, expectedJob.ToV1(), fetchedJob.ToV1(), "CreateJob stored invalid data in database")
}

func TestCreateJobDifferentDefaultServiceAccountName_ThroughWorkflowSpecV2(t *testing.T) {
originalDefaultServiceAccount := viper.Get(common.DefaultPipelineRunnerServiceAccountFlag)

viper.Set(common.DefaultPipelineRunnerServiceAccountFlag, "my-service-account")
defer viper.Set(common.DefaultPipelineRunnerServiceAccountFlag, originalDefaultServiceAccount)

store, manager, job := initWithJobV2(t)
defer store.Close()
expectedJob := &model.Job{
UUID: "123e4567-e89b-12d3-a456-426655440000",
DisplayName: "j1",
K8SName: "job-",
Namespace: "ns1",
ServiceAccount: "my-service-account",
Enabled: true,
ExperimentId: DefaultFakeUUID,
CreatedAtInSec: 2,
UpdatedAtInSec: 2,
Conditions: "STATUS_UNSPECIFIED",
PipelineSpec: model.PipelineSpec{
PipelineSpecManifest: v2SpecHelloWorld,
RuntimeConfig: model.RuntimeConfig{
Parameters: "{\"text\":\"world\"}",
PipelineRoot: "job-1-root",
},
},
}
expectedJob.PipelineSpec.PipelineName = job.PipelineSpec.PipelineName
require.Equal(t, expectedJob.ToV1(), job.ToV1())
fetchedJob, err := manager.GetJob(job.UUID)
require.Nil(t, err)
require.Equal(t, expectedJob.ToV1(), fetchedJob.ToV1(), "CreateJob stored invalid data in database")
}

func TestCreateJob_ThroughPipelineID(t *testing.T) {
store, manager, pipeline, _ := initWithPipeline(t)
defer store.Close()
Expand Down
5 changes: 3 additions & 2 deletions backend/src/v2/compiler/argocompiler/argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package argocompiler

import (
"fmt"
"github.com/kubeflow/pipelines/backend/src/apiserver/common"
"strings"

wfapi "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
Expand Down Expand Up @@ -63,7 +64,7 @@ func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.S
if err != nil {
return nil, err
}
// fill root component default paramters to PipelineJob
// fill root component default parameters to PipelineJob
specParams := spec.GetRoot().GetInputDefinitions().GetParameters()
for name, param := range specParams {
_, ok := job.RuntimeConfig.ParameterValues[name]
Expand Down Expand Up @@ -108,7 +109,7 @@ func Compile(jobArg *pipelinespec.PipelineJob, kubernetesSpecArg *pipelinespec.S
"pipelines.kubeflow.org/v2_component": "true",
},
},
ServiceAccountName: "pipeline-runner",
ServiceAccountName: common.GetStringConfigWithDefault(common.DefaultPipelineRunnerServiceAccountFlag, common.DefaultPipelineRunnerServiceAccount),
Entrypoint: tmplEntrypoint,
},
}
Expand Down

0 comments on commit 91de12d

Please sign in to comment.