Skip to content

Commit

Permalink
chore(backend): Fixed ServiceAccount in job creation
Browse files Browse the repository at this point in the history
Signed-off-by: Helber Belmiro <helber.belmiro@gmail.com>
  • Loading branch information
hbelmiro committed Dec 20, 2024
1 parent 54b9a25 commit 8a361a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 1 addition & 9 deletions backend/src/apiserver/resource/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,15 +1005,7 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
for _, modelRef := range job.ResourceReferences {
modelRef.ResourceUUID = string(swf.UID)
}
// Get the service account
serviceAccount := ""
if swf.Spec.Workflow != nil {
execSpec, err := util.ScheduleSpecToExecutionSpec(util.ArgoWorkflow, swf.Spec.Workflow)
if err == nil {
serviceAccount = execSpec.ServiceAccount()
}
}
job.ServiceAccount = serviceAccount
job.ServiceAccount = newScheduledWorkflow.Spec.ServiceAccount
if tmpl.GetTemplateType() == template.V1 {
job.PipelineSpec.WorkflowSpecManifest = manifest
} else {
Expand Down
6 changes: 4 additions & 2 deletions backend/src/apiserver/template/v2_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func (t *V2Spec) ScheduledWorkflow(modelJob *model.Job) (*scheduledworkflow.Sche
if modelJob.Namespace != "" {
executionSpec.SetExecutionNamespace(modelJob.Namespace)
}
setDefaultServiceAccount(executionSpec, modelJob.ServiceAccount)
if executionSpec.ServiceAccount() == "" {
setDefaultServiceAccount(executionSpec, modelJob.ServiceAccount)
}
// Disable istio sidecar injection if not specified
executionSpec.SetAnnotationsToAllTemplatesIfKeyNotExist(util.AnnotationKeyIstioSidecarInject, util.AnnotationValueIstioSidecarInjectDisabled)
swfGeneratedName, err := toSWFCRDResourceGeneratedName(modelJob.K8SName)
Expand Down Expand Up @@ -132,7 +134,7 @@ func (t *V2Spec) ScheduledWorkflow(modelJob *model.Job) (*scheduledworkflow.Sche
PipelineId: modelJob.PipelineId,
PipelineName: modelJob.PipelineName,
PipelineVersionId: modelJob.PipelineVersionId,
ServiceAccount: modelJob.ServiceAccount,
ServiceAccount: executionSpec.ServiceAccount(),
},
}
return scheduledWorkflow, nil
Expand Down

0 comments on commit 8a361a5

Please sign in to comment.