Skip to content

Commit 34bf2f8

Browse files
committed
UPSTREAM: 11480: chore(backend): Fixed namespace in job creation
Signed-off-by: Helber Belmiro <[email protected]> (cherry picked from commit 72f11d9) Signed-off-by: Helber Belmiro <[email protected]>
1 parent 2969fca commit 34bf2f8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

backend/src/apiserver/resource/resource_manager.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -990,12 +990,6 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
990990
return nil, util.NewInternalServerError(err, "Failed to create a recurring run with an invalid pipeline spec manifest")
991991
}
992992

993-
// TODO(gkcalat): consider changing the flow. Other resource UUIDs are assigned by their respective stores (DB).
994-
// Convert modelJob into scheduledWorkflow.
995-
scheduledWorkflow, err := tmpl.ScheduledWorkflow(job, r.getOwnerReferences())
996-
if err != nil {
997-
return nil, util.Wrap(err, "Failed to create a recurring run during scheduled workflow creation")
998-
}
999993
// Create a new ScheduledWorkflow at the ScheduledWorkflow client.
1000994
k8sNamespace := job.Namespace
1001995
if k8sNamespace == "" {
@@ -1004,6 +998,15 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
1004998
if k8sNamespace == "" {
1005999
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")
10061000
}
1001+
1002+
job.Namespace = k8sNamespace
1003+
1004+
// TODO(gkcalat): consider changing the flow. Other resource UUIDs are assigned by their respective stores (DB).
1005+
// Convert modelJob into scheduledWorkflow.
1006+
scheduledWorkflow, err := tmpl.ScheduledWorkflow(job, r.getOwnerReferences())
1007+
if err != nil {
1008+
return nil, util.Wrap(err, "Failed to create a recurring run during scheduled workflow creation")
1009+
}
10071010
newScheduledWorkflow, err := r.getScheduledWorkflowClient(k8sNamespace).Create(ctx, scheduledWorkflow)
10081011
if err != nil {
10091012
if err, ok := err.(net.Error); ok && err.Timeout() {
@@ -1015,7 +1018,6 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
10151018
swf := util.NewScheduledWorkflow(newScheduledWorkflow)
10161019
job.UUID = string(swf.UID)
10171020
job.K8SName = swf.Name
1018-
job.Namespace = swf.Namespace
10191021
job.Conditions = model.StatusState(swf.ConditionSummary()).ToString()
10201022
for _, modelRef := range job.ResourceReferences {
10211023
modelRef.ResourceUUID = string(swf.UID)

0 commit comments

Comments
 (0)