Skip to content

Commit

Permalink
Merge pull request #122 from hbelmiro/cherry-pick-11480
Browse files Browse the repository at this point in the history
UPSTREAM: 11480: chore(backend): Fixed namespace in job creation
  • Loading branch information
openshift-merge-bot[bot] authored Jan 16, 2025
2 parents 2969fca + 34bf2f8 commit 937dd10
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions backend/src/apiserver/resource/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,12 +990,6 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
return nil, util.NewInternalServerError(err, "Failed to create a recurring run with an invalid pipeline spec manifest")
}

// TODO(gkcalat): consider changing the flow. Other resource UUIDs are assigned by their respective stores (DB).
// Convert modelJob into scheduledWorkflow.
scheduledWorkflow, err := tmpl.ScheduledWorkflow(job, r.getOwnerReferences())
if err != nil {
return nil, util.Wrap(err, "Failed to create a recurring run during scheduled workflow creation")
}
// Create a new ScheduledWorkflow at the ScheduledWorkflow client.
k8sNamespace := job.Namespace
if k8sNamespace == "" {
Expand All @@ -1004,6 +998,15 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
if k8sNamespace == "" {
return nil, util.NewInternalServerError(util.NewInvalidInputError("Namespace cannot be empty when creating an Argo scheduled workflow. Check if you have specified POD_NAMESPACE or try adding the parent namespace to the request"), "Failed to create a recurring run due to empty namespace")
}

job.Namespace = k8sNamespace

// TODO(gkcalat): consider changing the flow. Other resource UUIDs are assigned by their respective stores (DB).
// Convert modelJob into scheduledWorkflow.
scheduledWorkflow, err := tmpl.ScheduledWorkflow(job, r.getOwnerReferences())
if err != nil {
return nil, util.Wrap(err, "Failed to create a recurring run during scheduled workflow creation")
}
newScheduledWorkflow, err := r.getScheduledWorkflowClient(k8sNamespace).Create(ctx, scheduledWorkflow)
if err != nil {
if err, ok := err.(net.Error); ok && err.Timeout() {
Expand All @@ -1015,7 +1018,6 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
swf := util.NewScheduledWorkflow(newScheduledWorkflow)
job.UUID = string(swf.UID)
job.K8SName = swf.Name
job.Namespace = swf.Namespace
job.Conditions = model.StatusState(swf.ConditionSummary()).ToString()
for _, modelRef := range job.ResourceReferences {
modelRef.ResourceUUID = string(swf.UID)
Expand Down

0 comments on commit 937dd10

Please sign in to comment.