Skip to content

Commit 72f11d9

Browse files
authored
chore(backend): Fixed namespace in job creation (#11480)
Signed-off-by: Helber Belmiro <helber.belmiro@gmail.com>
1 parent 873e9de commit 72f11d9

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
@@ -975,12 +975,6 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
975975
return nil, util.NewInternalServerError(err, "Failed to create a recurring run with an invalid pipeline spec manifest")
976976
}
977977

978-
// TODO(gkcalat): consider changing the flow. Other resource UUIDs are assigned by their respective stores (DB).
979-
// Convert modelJob into scheduledWorkflow.
980-
scheduledWorkflow, err := tmpl.ScheduledWorkflow(job)
981-
if err != nil {
982-
return nil, util.Wrap(err, "Failed to create a recurring run during scheduled workflow creation")
983-
}
984978
// Create a new ScheduledWorkflow at the ScheduledWorkflow client.
985979
k8sNamespace := job.Namespace
986980
if k8sNamespace == "" {
@@ -989,6 +983,15 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
989983
if k8sNamespace == "" {
990984
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")
991985
}
986+
987+
job.Namespace = k8sNamespace
988+
989+
// TODO(gkcalat): consider changing the flow. Other resource UUIDs are assigned by their respective stores (DB).
990+
// Convert modelJob into scheduledWorkflow.
991+
scheduledWorkflow, err := tmpl.ScheduledWorkflow(job)
992+
if err != nil {
993+
return nil, util.Wrap(err, "Failed to create a recurring run during scheduled workflow creation")
994+
}
992995
newScheduledWorkflow, err := r.getScheduledWorkflowClient(k8sNamespace).Create(ctx, scheduledWorkflow)
993996
if err != nil {
994997
if err, ok := err.(net.Error); ok && err.Timeout() {
@@ -1000,7 +1003,6 @@ func (r *ResourceManager) CreateJob(ctx context.Context, job *model.Job) (*model
10001003
swf := util.NewScheduledWorkflow(newScheduledWorkflow)
10011004
job.UUID = string(swf.UID)
10021005
job.K8SName = swf.Name
1003-
job.Namespace = swf.Namespace
10041006
job.Conditions = model.StatusState(swf.ConditionSummary()).ToString()
10051007
for _, modelRef := range job.ResourceReferences {
10061008
modelRef.ResourceUUID = string(swf.UID)

0 commit comments

Comments
 (0)