This is an automated email from the ASF dual-hosted git repository.
DImuthuUpe pushed a commit to branch workflow-pause-on-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/workflow-pause-on-auth by this
push:
new f1ff859a3a Changing process execution to process workflow
f1ff859a3a is described below
commit f1ff859a3aefe0e8b1ab45484ba3a05c9682d7bf
Author: DImuthuUpe <[email protected]>
AuthorDate: Sat Nov 7 00:31:49 2026 -0500
Changing process execution to process workflow
---
api/process/controller/execution.go | 66 ----------
api/process/controller/workflow.go | 66 ++++++++++
api/process/dto/execution.go | 56 ---------
api/process/dto/process.go | 22 ++--
api/process/dto/workflow.go | 56 +++++++++
api/process/model/process.go | 52 ++++----
api/process/repository/execution.go | 138 ---------------------
api/process/repository/workflow.go | 138 +++++++++++++++++++++
api/process/service/execution.go | 129 -------------------
api/process/service/launch.go | 10 +-
api/process/service/workflow.go | 129 +++++++++++++++++++
dashboard/src/lib/types.ts | 2 +-
docs/api.md | 36 +++---
docs/openapi.yaml | 58 ++++-----
internal/app/app.go | 16 +--
internal/db/foreignkey_test.go | 8 +-
internal/db/migrate.go | 4 +-
internal/db/migrate_test.go | 2 +-
.../db/migrations/0007_process_workflow_rename.sql | 31 +++++
internal/orchestration/engine.go | 4 +-
internal/orchestration/workflows/workflows.go | 10 +-
internal/orchestration/workflows/workflows_test.go | 2 +-
internal/server/server.go | 2 +-
internal/server/server_test.go | 77 ++++++------
24 files changed, 573 insertions(+), 541 deletions(-)
diff --git a/api/process/controller/execution.go
b/api/process/controller/execution.go
deleted file mode 100644
index ecec62e31a..0000000000
--- a/api/process/controller/execution.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
- */
-
-package controller
-
-import (
- "net/http"
-
- "github.com/apache/airavata/internal/httpx"
-
- "github.com/apache/airavata/api/process/service"
-)
-
-// ExecutionController serves read-only access to the workflow executions
started for a
-// process, nested under /api/v1/processes/{processId}.
-//
-// There is deliberately no POST or PUT: executions are recorded by
-// service.ExecutionService when a workflow is started, never accepted as a
request
-// body from a client.
-type ExecutionController struct{ svc *service.ExecutionService }
-
-// NewExecutionController returns a handler delegating to svc.
-func NewExecutionController(svc *service.ExecutionService)
*ExecutionController {
- return &ExecutionController{svc: svc}
-}
-
-// Register mounts the read-only execution routes.
-func (h *ExecutionController) Register(mux *http.ServeMux) {
- mux.HandleFunc("GET /api/v1/processes/{processId}/executions", h.list)
- mux.HandleFunc("GET
/api/v1/processes/{processId}/executions/{executionId}", h.get)
-}
-
-func (h *ExecutionController) list(w http.ResponseWriter, r *http.Request) {
- executions, err := h.svc.ListForProcess(r.Context(),
r.PathValue("processId"))
- if err != nil {
- httpx.WriteError(w, r, err)
- return
- }
- httpx.WriteJSON(w, http.StatusOK, executions)
-}
-
-func (h *ExecutionController) get(w http.ResponseWriter, r *http.Request) {
- execution, err := h.svc.Get(r.Context(), r.PathValue("processId"),
r.PathValue("executionId"))
- if err != nil {
- httpx.WriteError(w, r, err)
- return
- }
- httpx.WriteJSON(w, http.StatusOK, execution)
-}
diff --git a/api/process/controller/workflow.go
b/api/process/controller/workflow.go
new file mode 100644
index 0000000000..fe550902aa
--- /dev/null
+++ b/api/process/controller/workflow.go
@@ -0,0 +1,66 @@
+/**
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+ */
+
+package controller
+
+import (
+ "net/http"
+
+ "github.com/apache/airavata/internal/httpx"
+
+ "github.com/apache/airavata/api/process/service"
+)
+
+// WorkflowController serves read-only access to the workflows started for a
+// process, nested under /api/v1/processes/{processId}.
+//
+// There is deliberately no POST or PUT: workflows are recorded by
+// service.WorkflowService when a workflow is started, never accepted as a
request
+// body from a client.
+type WorkflowController struct{ svc *service.WorkflowService }
+
+// NewWorkflowController returns a handler delegating to svc.
+func NewWorkflowController(svc *service.WorkflowService) *WorkflowController {
+ return &WorkflowController{svc: svc}
+}
+
+// Register mounts the read-only workflow routes.
+func (h *WorkflowController) Register(mux *http.ServeMux) {
+ mux.HandleFunc("GET /api/v1/processes/{processId}/workflows", h.list)
+ mux.HandleFunc("GET
/api/v1/processes/{processId}/workflows/{processWorkflowId}", h.get)
+}
+
+func (h *WorkflowController) list(w http.ResponseWriter, r *http.Request) {
+ workflows, err := h.svc.ListForProcess(r.Context(),
r.PathValue("processId"))
+ if err != nil {
+ httpx.WriteError(w, r, err)
+ return
+ }
+ httpx.WriteJSON(w, http.StatusOK, workflows)
+}
+
+func (h *WorkflowController) get(w http.ResponseWriter, r *http.Request) {
+ workflow, err := h.svc.Get(r.Context(), r.PathValue("processId"),
r.PathValue("processWorkflowId"))
+ if err != nil {
+ httpx.WriteError(w, r, err)
+ return
+ }
+ httpx.WriteJSON(w, http.StatusOK, workflow)
+}
diff --git a/api/process/dto/execution.go b/api/process/dto/execution.go
deleted file mode 100644
index 97f5a7025e..0000000000
--- a/api/process/dto/execution.go
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
- */
-
-package dto
-
-import (
- model "github.com/apache/airavata/api/process/model"
-)
-
-// ExecutionResponse is the read model for one recorded process execution. Like
-// StatusResponse it has no request counterpart: executions are recorded when a
-// workflow is started for a process, never accepted from a client.
-type ExecutionResponse struct {
- ProcessExecutionID string
`json:"processExecutionId"`
- ProcessID *string `json:"processId"`
- ExecutionID string
`json:"executionId"`
- ExecutionType *model.ProcessExecutionType
`json:"executionType"`
- Status *model.ProcessExecutionStatusType `json:"status"`
- Timestamp *int64 `json:"timestamp"`
-}
-
-func ToExecutionResponse(e *model.ProcessExecution) ExecutionResponse {
- return ExecutionResponse{
- ProcessExecutionID: e.ID,
- ProcessID: e.ProcessID,
- ExecutionID: e.ExecutionID,
- ExecutionType: e.ExecutionType,
- Status: e.Status,
- Timestamp: e.Timestamp,
- }
-}
-
-func ToExecutionResponses(in []model.ProcessExecution) []ExecutionResponse {
- out := make([]ExecutionResponse, 0, len(in))
- for i := range in {
- out = append(out, ToExecutionResponse(&in[i]))
- }
- return out
-}
diff --git a/api/process/dto/process.go b/api/process/dto/process.go
index 02afc35115..24641b6857 100644
--- a/api/process/dto/process.go
+++ b/api/process/dto/process.go
@@ -190,23 +190,23 @@ func (r *Request) Validate() []httpx.FieldError {
// Response is the read model for a process, with every section it carries
nested
// inside it.
type Response struct {
- ProcessID string `json:"processId"`
- UserID *string `json:"userId"`
- ProcessType *model.ProcessType `json:"processType"`
- LastStatusID *string `json:"lastStatusId"`
- LastExecutionID *string `json:"lastExecutionId"`
+ ProcessID string `json:"processId"`
+ UserID *string `json:"userId"`
+ ProcessType *model.ProcessType `json:"processType"`
+ LastStatusID *string `json:"lastStatusId"`
+ LastWorkflowID *string `json:"lastWorkflowId"`
BatchProcess *BatchProcessResponse `json:"batchProcess"`
}
func ToResponse(p *model.Process) Response {
return Response{
- ProcessID: p.ID,
- UserID: p.OwnerID,
- ProcessType: p.ProcessType,
- LastStatusID: p.LastStatusID,
- LastExecutionID: p.LastExecutionID,
- BatchProcess: ToBatchProcessResponse(p.BatchProcess),
+ ProcessID: p.ID,
+ UserID: p.OwnerID,
+ ProcessType: p.ProcessType,
+ LastStatusID: p.LastStatusID,
+ LastWorkflowID: p.LastWorkflowID,
+ BatchProcess: ToBatchProcessResponse(p.BatchProcess),
}
}
diff --git a/api/process/dto/workflow.go b/api/process/dto/workflow.go
new file mode 100644
index 0000000000..5f7459d628
--- /dev/null
+++ b/api/process/dto/workflow.go
@@ -0,0 +1,56 @@
+/**
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+ */
+
+package dto
+
+import (
+ model "github.com/apache/airavata/api/process/model"
+)
+
+// WorkflowResponse is the read model for one recorded process workflow. Like
+// StatusResponse it has no request counterpart: workflows are recorded when a
+// workflow is started for a process, never accepted from a client.
+type WorkflowResponse struct {
+ ProcessWorkflowID string
`json:"processWorkflowId"`
+ ProcessID *string `json:"processId"`
+ WorkflowID string `json:"workflowId"`
+ WorkflowType *model.ProcessWorkflowType `json:"workflowType"`
+ Status *model.ProcessWorkflowStatusType `json:"status"`
+ Timestamp *int64 `json:"timestamp"`
+}
+
+func ToWorkflowResponse(e *model.ProcessWorkflow) WorkflowResponse {
+ return WorkflowResponse{
+ ProcessWorkflowID: e.ID,
+ ProcessID: e.ProcessID,
+ WorkflowID: e.WorkflowID,
+ WorkflowType: e.WorkflowType,
+ Status: e.Status,
+ Timestamp: e.Timestamp,
+ }
+}
+
+func ToWorkflowResponses(in []model.ProcessWorkflow) []WorkflowResponse {
+ out := make([]WorkflowResponse, 0, len(in))
+ for i := range in {
+ out = append(out, ToWorkflowResponse(&in[i]))
+ }
+ return out
+}
diff --git a/api/process/model/process.go b/api/process/model/process.go
index e87e32bed8..1431521b6e 100644
--- a/api/process/model/process.go
+++ b/api/process/model/process.go
@@ -102,10 +102,10 @@ type Process struct {
// the newest status row, maintained by ProcessStatus.AfterCreate.
LastStatusID *string
`gorm:"column:last_status_id;type:varchar(36);index"
json:"lastStatusId,omitempty"`
- // The last execution recorded for this process, if any. Like
LastStatusID it
+ // The last workflow recorded for this process, if any. Like
LastStatusID it
// carries no foreign key, for the same reason, and is maintained by
- // ProcessExecution.AfterCreate.
- LastExecutionID *string
`gorm:"column:last_execution_id;type:varchar(36);index"
json:"lastExecutionId,omitempty"`
+ // ProcessWorkflow.AfterCreate.
+ LastWorkflowID *string
`gorm:"column:last_workflow_id;type:varchar(36);index"
json:"lastWorkflowId,omitempty"`
// BatchProcess is present exactly when ProcessType is BATCH_JOB. It is
owned by
// the process, not shared with it: deleting the process deletes it too.
@@ -131,9 +131,9 @@ func (p *Process) BeforeCreate(*gorm.DB) error {
// BeforeDelete removes what the database will not.
//
-// The statuses and executions have to go first: their own ProcessID foreign
keys are
+// The statuses and workflows have to go first: their own ProcessID foreign
keys are
// RESTRICT, so the server would refuse to delete a process any of them still
points at.
-// LastStatusID and LastExecutionID need no clearing — they hold no constraint
— and the
+// LastStatusID and LastWorkflowID need no clearing — they hold no constraint
— and the
// row carrying them is about to be deleted in this same transaction.
//
// The batch process is deleted through GORM rather than left to its ON DELETE
CASCADE
@@ -148,7 +148,7 @@ func (p *Process) BeforeDelete(tx *gorm.DB) error {
if err := tx.Where("process_id = ?",
p.ID).Delete(&ProcessStatus{}).Error; err != nil {
return err
}
- if err := tx.Where("process_id = ?",
p.ID).Delete(&ProcessExecution{}).Error; err != nil {
+ if err := tx.Where("process_id = ?",
p.ID).Delete(&ProcessWorkflow{}).Error; err != nil {
return err
}
@@ -228,56 +228,56 @@ func (s *ProcessStatus) AfterCreate(tx *gorm.DB) error {
Update("last_status_id", s.ID).Error
}
-type ProcessExecutionType string
+type ProcessWorkflowType string
const (
- ProcessExecutionTypeBatchJobSubmission ProcessExecutionType =
"BATCH_JOB_SUBMISSION"
- ProcessExecutionTypeJobMonitoring ProcessExecutionType =
"JOB_MONITORING"
- ProcessExecutionTypeJobCompletion ProcessExecutionType =
"BATCH_JOB_COMPLETION"
+ ProcessWorkflowTypeBatchJobSubmission ProcessWorkflowType =
"BATCH_JOB_SUBMISSION"
+ ProcessWorkflowTypeJobMonitoring ProcessWorkflowType =
"JOB_MONITORING"
+ ProcessWorkflowTypeJobCompletion ProcessWorkflowType =
"BATCH_JOB_COMPLETION"
)
-type ProcessExecutionStatusType string
+type ProcessWorkflowStatusType string
const (
- ProcessExecutionStatusTypeRunning ProcessExecutionStatusType =
"RUNNING"
- ProcessExecutionStatusTypeSucceeded ProcessExecutionStatusType =
"SUCCEEDED"
- ProcessExecutionStatusTypeFailed ProcessExecutionStatusType =
"FAILED"
+ ProcessWorkflowStatusTypeRunning ProcessWorkflowStatusType = "RUNNING"
+ ProcessWorkflowStatusTypeSucceeded ProcessWorkflowStatusType =
"SUCCEEDED"
+ ProcessWorkflowStatusTypeFailed ProcessWorkflowStatusType = "FAILED"
)
-// ProcessExecution records one workflow run started on behalf of a process —
the job
+// ProcessWorkflow records one workflow run started on behalf of a process —
the job
// submission, monitoring or completion workflow — by the id the workflow
engine knows
// it by.
-type ProcessExecution struct {
- ID string
`gorm:"column:process_execution_id;primaryKey;type:varchar(36)"
json:"processExecutionId"`
+type ProcessWorkflow struct {
+ ID string
`gorm:"column:process_workflow_id;primaryKey;type:varchar(36)"
json:"processWorkflowId"`
ProcessID *string `gorm:"column:process_id;type:varchar(36);index"
json:"processId,omitempty"`
Process *Process
`gorm:"references:ID;constraint:OnDelete:RESTRICT,OnUpdate:CASCADE" json:"-"`
// Workflow id or monitoring task id
- ExecutionID string
`gorm:"column:execution_id;type:varchar(36)" json:"executionId"`
- ExecutionType *ProcessExecutionType
`gorm:"column:execution_type;type:varchar(255)" json:"executionType,omitempty"`
+ WorkflowID string
`gorm:"column:workflow_id;type:varchar(36)" json:"workflowId"`
+ WorkflowType *ProcessWorkflowType
`gorm:"column:workflow_type;type:varchar(255)" json:"workflowType,omitempty"`
// Where the run stands: RUNNING once started, then SUCCEEDED or FAILED.
- Status *ProcessExecutionStatusType
`gorm:"column:status;type:varchar(255)" json:"status,omitempty"`
+ Status *ProcessWorkflowStatusType
`gorm:"column:status;type:varchar(255)" json:"status,omitempty"`
- // The time the execution was recorded, in milliseconds since the epoch.
+ // The time the workflow was recorded, in milliseconds since the epoch.
Timestamp *int64 `gorm:"column:timestamp" json:"timestamp,omitempty"`
}
-// TableName returns the table backing ProcessExecution.
-func (ProcessExecution) TableName() string { return "process_executions" }
+// TableName returns the table backing ProcessWorkflow.
+func (ProcessWorkflow) TableName() string { return "process_workflows" }
-func (p *ProcessExecution) BeforeCreate(*gorm.DB) error {
+func (p *ProcessWorkflow) BeforeCreate(*gorm.DB) error {
if p.ID == "" {
p.ID = uuid.NewString()
}
return nil
}
-func (p *ProcessExecution) AfterCreate(tx *gorm.DB) error {
+func (p *ProcessWorkflow) AfterCreate(tx *gorm.DB) error {
if p.ProcessID == nil || *p.ProcessID == "" {
return nil
}
return tx.Model(&Process{}).
Where("process_id = ?", *p.ProcessID).
- Update("last_execution_id", p.ID).Error
+ Update("last_workflow_id", p.ID).Error
}
diff --git a/api/process/repository/execution.go
b/api/process/repository/execution.go
deleted file mode 100644
index 987c6c415d..0000000000
--- a/api/process/repository/execution.go
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
- */
-
-package repository
-
-import (
- "context"
- "errors"
- "time"
-
- "gorm.io/gorm"
-
- "github.com/apache/airavata/internal/ptr"
-
- model "github.com/apache/airavata/api/process/model"
-)
-
-// ExecutionRepository reads and writes process executions.
-//
-// Only an execution's status is ever updated: the rest records a workflow run
that was
-// started, which is never corrected in place.
-type ExecutionRepository struct{ db *gorm.DB }
-
-// NewExecutionRepository returns a repository backed by db.
-func NewExecutionRepository(db *gorm.DB) *ExecutionRepository {
- return &ExecutionRepository{db: db}
-}
-
-// WithTx returns a repository bound to tx.
-func (r *ExecutionRepository) WithTx(tx *gorm.DB) *ExecutionRepository {
- return &ExecutionRepository{db: tx}
-}
-
-// FindByProcessID returns every execution recorded for one process, oldest
first.
-func (r *ExecutionRepository) FindByProcessID(ctx context.Context, processID
string) ([]model.ProcessExecution, error) {
- var out []model.ProcessExecution
- err := r.db.WithContext(ctx).
- Where("process_id = ?", processID).
- Order("timestamp").
- Find(&out).Error
- return out, err
-}
-
-// FindByIDAndProcessID returns one execution scoped to its process, or
-// gorm.ErrRecordNotFound if the id does not belong to that process.
-func (r *ExecutionRepository) FindByIDAndProcessID(ctx context.Context, id,
processID string) (*model.ProcessExecution, error) {
- var out model.ProcessExecution
- err := r.db.WithContext(ctx).
- First(&out, "process_execution_id = ? AND process_id = ?", id,
processID).Error
- if err != nil {
- return nil, err
- }
- return &out, nil
-}
-
-// FindByExecutionIDAndProcessID returns the execution recorded for one
workflow
-// instance of one process, or gorm.ErrRecordNotFound if none was.
-func (r *ExecutionRepository) FindByExecutionIDAndProcessID(ctx
context.Context, executionID, processID string) (*model.ProcessExecution,
error) {
- var out model.ProcessExecution
- err := r.db.WithContext(ctx).
- First(&out, "execution_id = ? AND process_id = ?", executionID,
processID).Error
- if err != nil {
- return nil, err
- }
- return &out, nil
-}
-
-// UpdateStatus sets the status of one execution, or returns
gorm.ErrRecordNotFound if
-// no execution has that id.
-func (r *ExecutionRepository) UpdateStatus(ctx context.Context, id string,
status model.ProcessExecutionStatusType) error {
- res := r.db.WithContext(ctx).Model(&model.ProcessExecution{}).
- Where("process_execution_id = ?", id).
- Update("status", status)
- if res.Error != nil {
- return res.Error
- }
- if res.RowsAffected == 0 {
- return gorm.ErrRecordNotFound
- }
- return nil
-}
-
-// Record creates the execution of one workflow instance of a process, or
moves an
-// existing one to status. An update changes only the status: the type and
timestamp
-// stay as first recorded, so the timestamp keeps saying when the execution
started.
-//
-// It is here rather than only in the service so that the orchestration
activities,
-// which cannot import the service package, record executions the same way.
-func (r *ExecutionRepository) Record(ctx context.Context, processID,
executionID string,
- executionType model.ProcessExecutionType, status
model.ProcessExecutionStatusType) (*model.ProcessExecution, error) {
-
- existing, err := r.FindByExecutionIDAndProcessID(ctx, executionID,
processID)
- switch {
- case err == nil:
- if err := r.UpdateStatus(ctx, existing.ID, status); err != nil {
- return nil, err
- }
- existing.Status = &status
- return existing, nil
- case !errors.Is(err, gorm.ErrRecordNotFound):
- return nil, err
- }
-
- created := &model.ProcessExecution{
- ProcessID: &processID,
- ExecutionID: executionID,
- ExecutionType: &executionType,
- Status: &status,
- Timestamp: ptr.To(time.Now().UnixMilli()),
- }
- if err := r.Create(ctx, created); err != nil {
- return nil, err
- }
- return created, nil
-}
-
-// Create inserts an execution row. BeforeCreate assigns its id and AfterCreate
-// repoints the owning process's LastExecutionID at it.
-func (r *ExecutionRepository) Create(ctx context.Context, e
*model.ProcessExecution) error {
- return r.db.WithContext(ctx).Create(e).Error
-}
diff --git a/api/process/repository/workflow.go
b/api/process/repository/workflow.go
new file mode 100644
index 0000000000..9f06d0ce3b
--- /dev/null
+++ b/api/process/repository/workflow.go
@@ -0,0 +1,138 @@
+/**
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+ */
+
+package repository
+
+import (
+ "context"
+ "errors"
+ "time"
+
+ "gorm.io/gorm"
+
+ "github.com/apache/airavata/internal/ptr"
+
+ model "github.com/apache/airavata/api/process/model"
+)
+
+// WorkflowRepository reads and writes process workflows.
+//
+// Only a process workflow's status is ever updated: the rest records a
workflow run
+// that was started, which is never corrected in place.
+type WorkflowRepository struct{ db *gorm.DB }
+
+// NewWorkflowRepository returns a repository backed by db.
+func NewWorkflowRepository(db *gorm.DB) *WorkflowRepository {
+ return &WorkflowRepository{db: db}
+}
+
+// WithTx returns a repository bound to tx.
+func (r *WorkflowRepository) WithTx(tx *gorm.DB) *WorkflowRepository {
+ return &WorkflowRepository{db: tx}
+}
+
+// FindByProcessID returns every workflow recorded for one process, oldest
first.
+func (r *WorkflowRepository) FindByProcessID(ctx context.Context, processID
string) ([]model.ProcessWorkflow, error) {
+ var out []model.ProcessWorkflow
+ err := r.db.WithContext(ctx).
+ Where("process_id = ?", processID).
+ Order("timestamp").
+ Find(&out).Error
+ return out, err
+}
+
+// FindByIDAndProcessID returns one workflow scoped to its process, or
+// gorm.ErrRecordNotFound if the id does not belong to that process.
+func (r *WorkflowRepository) FindByIDAndProcessID(ctx context.Context, id,
processID string) (*model.ProcessWorkflow, error) {
+ var out model.ProcessWorkflow
+ err := r.db.WithContext(ctx).
+ First(&out, "process_workflow_id = ? AND process_id = ?", id,
processID).Error
+ if err != nil {
+ return nil, err
+ }
+ return &out, nil
+}
+
+// FindByWorkflowIDAndProcessID returns the workflow recorded for one workflow
+// instance of one process, or gorm.ErrRecordNotFound if none was.
+func (r *WorkflowRepository) FindByWorkflowIDAndProcessID(ctx context.Context,
workflowID, processID string) (*model.ProcessWorkflow, error) {
+ var out model.ProcessWorkflow
+ err := r.db.WithContext(ctx).
+ First(&out, "workflow_id = ? AND process_id = ?", workflowID,
processID).Error
+ if err != nil {
+ return nil, err
+ }
+ return &out, nil
+}
+
+// UpdateStatus sets the status of one workflow, or returns
gorm.ErrRecordNotFound if
+// no workflow has that id.
+func (r *WorkflowRepository) UpdateStatus(ctx context.Context, id string,
status model.ProcessWorkflowStatusType) error {
+ res := r.db.WithContext(ctx).Model(&model.ProcessWorkflow{}).
+ Where("process_workflow_id = ?", id).
+ Update("status", status)
+ if res.Error != nil {
+ return res.Error
+ }
+ if res.RowsAffected == 0 {
+ return gorm.ErrRecordNotFound
+ }
+ return nil
+}
+
+// Record creates the workflow of one workflow instance of a process, or moves
an
+// existing one to status. An update changes only the status: the type and
timestamp
+// stay as first recorded, so the timestamp keeps saying when the workflow
started.
+//
+// It is here rather than only in the service so that the orchestration
activities,
+// which cannot import the service package, record workflows the same way.
+func (r *WorkflowRepository) Record(ctx context.Context, processID, workflowID
string,
+ workflowType model.ProcessWorkflowType, status
model.ProcessWorkflowStatusType) (*model.ProcessWorkflow, error) {
+
+ existing, err := r.FindByWorkflowIDAndProcessID(ctx, workflowID,
processID)
+ switch {
+ case err == nil:
+ if err := r.UpdateStatus(ctx, existing.ID, status); err != nil {
+ return nil, err
+ }
+ existing.Status = &status
+ return existing, nil
+ case !errors.Is(err, gorm.ErrRecordNotFound):
+ return nil, err
+ }
+
+ created := &model.ProcessWorkflow{
+ ProcessID: &processID,
+ WorkflowID: workflowID,
+ WorkflowType: &workflowType,
+ Status: &status,
+ Timestamp: ptr.To(time.Now().UnixMilli()),
+ }
+ if err := r.Create(ctx, created); err != nil {
+ return nil, err
+ }
+ return created, nil
+}
+
+// Create inserts a process workflow row. BeforeCreate assigns its id and
AfterCreate
+// repoints the owning process's LastWorkflowID at it.
+func (r *WorkflowRepository) Create(ctx context.Context, e
*model.ProcessWorkflow) error {
+ return r.db.WithContext(ctx).Create(e).Error
+}
diff --git a/api/process/service/execution.go b/api/process/service/execution.go
deleted file mode 100644
index 40f1873add..0000000000
--- a/api/process/service/execution.go
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
- */
-
-package service
-
-import (
- "context"
-
- "gorm.io/gorm"
-
- "github.com/apache/airavata/internal/auth"
- "github.com/apache/airavata/internal/httpx"
-
- dto "github.com/apache/airavata/api/process/dto"
- model "github.com/apache/airavata/api/process/model"
- "github.com/apache/airavata/api/process/repository"
-)
-
-// ExecutionService records and reads the workflow executions started for a
process.
-//
-// There is no create endpoint, by design: an execution is recorded by the
code that
-// starts a workflow for the process, never accepted from a client request
body. Reads
-// are owner-scoped like TaskStatusService's, since an execution id is a
handle on the
-// workflow engine's own record of the run.
-type ExecutionService struct {
- db *gorm.DB
- executions *repository.ExecutionRepository
- processes *repository.ProcessRepository
-}
-
-// NewExecutionService returns an execution service.
-func NewExecutionService(db *gorm.DB, executions
*repository.ExecutionRepository, processes *repository.ProcessRepository)
*ExecutionService {
- return &ExecutionService{db: db, executions: executions, processes:
processes}
-}
-
-// Record records where a workflow execution of a process stands, in its own
-// transaction: the first call for an executionID creates the execution, and
later
-// calls for the same one move it to the new status — RUNNING when the
workflow is
-// started, SUCCEEDED or FAILED when it finishes.
-//
-// It does not check authorisation: recording an execution is an internal
operation
-// performed by trusted service code, never taken directly from a client
request.
-func (s *ExecutionService) Record(ctx context.Context, processID, executionID
string, executionType model.ProcessExecutionType, status
model.ProcessExecutionStatusType) (*dto.ExecutionResponse, error) {
- var out dto.ExecutionResponse
- err := s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
- recorded, err := s.RecordTx(ctx, tx, processID, executionID,
executionType, status)
- if err != nil {
- return err
- }
- out = dto.ToExecutionResponse(recorded)
- return nil
- })
- if err != nil {
- return nil, err
- }
- return &out, nil
-}
-
-// RecordTx creates or updates an execution inside an already-open
transaction, so a
-// caller that is already inside one of its own commits or rolls back the
execution
-// together with the rest of its work.
-//
-// See ExecutionRepository.Record for what an update changes.
-func (s *ExecutionService) RecordTx(ctx context.Context, tx *gorm.DB,
processID, executionID string, executionType model.ProcessExecutionType, status
model.ProcessExecutionStatusType) (*model.ProcessExecution, error) {
- if _, err := s.processes.WithTx(tx).FindByID(ctx, processID); err !=
nil {
- return nil, notFoundAs(err, "Process not found: %s", processID)
- }
-
- return s.executions.WithTx(tx).Record(ctx, processID, executionID,
executionType, status)
-}
-
-// ListForProcess returns every execution recorded for a process, oldest first.
-func (s *ExecutionService) ListForProcess(ctx context.Context, processID
string) ([]dto.ExecutionResponse, error) {
- if err := s.requireProcess(ctx, processID); err != nil {
- return nil, err
- }
- found, err := s.executions.FindByProcessID(ctx, processID)
- if err != nil {
- return nil, err
- }
- return dto.ToExecutionResponses(found), nil
-}
-
-// Get returns one execution, scoped to the process it must belong to.
-func (s *ExecutionService) Get(ctx context.Context, processID, executionID
string) (*dto.ExecutionResponse, error) {
- if err := s.requireProcess(ctx, processID); err != nil {
- return nil, err
- }
- found, err := s.executions.FindByIDAndProcessID(ctx, executionID,
processID)
- if err != nil {
- return nil, notFoundAs(err, "Execution not found: %s in process
%s", executionID, processID)
- }
- out := dto.ToExecutionResponse(found)
- return &out, nil
-}
-
-// requireProcess checks the process exists and the caller may see its
executions: its
-// owner, or an admin.
-func (s *ExecutionService) requireProcess(ctx context.Context, processID
string) error {
- principal, err := auth.RequireAuthenticated(ctx)
- if err != nil {
- return err
- }
- proc, err := s.processes.FindByID(ctx, processID)
- if err != nil {
- return notFoundAs(err, "Process not found: %s", processID)
- }
- if !proc.OwnedBy(principal.Name) && !principal.IsAdmin() {
- return httpx.Forbidden("Access denied: you may only work with
executions of your own processes")
- }
- return nil
-}
diff --git a/api/process/service/launch.go b/api/process/service/launch.go
index 2e47310003..22d3897e72 100644
--- a/api/process/service/launch.go
+++ b/api/process/service/launch.go
@@ -60,7 +60,7 @@ type LaunchService struct {
scpDataStorageService *datasev.SCPDataStorageService
dataProductService *datasev.DataProductService
statusService *StatusService
- executionService *ExecutionService
+ processWorkflowService *WorkflowService
dataStagingTasks *repository.DataStagingTaskRepository
jobSubmissionTasks *repository.JobSubmissionTaskRepository
@@ -82,7 +82,7 @@ func NewLaunchService(
scpDataStorageService *datasev.SCPDataStorageService,
dataProductService *datasev.DataProductService,
statusService *StatusService,
- executionService *ExecutionService,
+ processWorkflowService *WorkflowService,
dataStagingTasks *repository.DataStagingTaskRepository,
jobSubmissionTasks *repository.JobSubmissionTaskRepository,
@@ -107,7 +107,7 @@ func NewLaunchService(
monitoringTasks: monitoringTasks,
interactiveTasks: interactiveTasks,
executionEngine: executionEngine,
- executionService: executionService,
+ processWorkflowService: processWorkflowService,
}
}
@@ -279,10 +279,10 @@ func (s *LaunchService) launchBatchProcess(ctx
context.Context, process *dto.Res
return err
}
- _, err = s.executionService.Record(ctx, process.ProcessID, workflowId,
procmodel.ProcessExecutionTypeBatchJobSubmission,
procmodel.ProcessExecutionStatusTypeRunning)
+ _, err = s.processWorkflowService.Record(ctx, process.ProcessID,
workflowId, procmodel.ProcessWorkflowTypeBatchJobSubmission,
procmodel.ProcessWorkflowStatusTypeRunning)
if err != nil {
- slog.Error("Failed to record execution", "processId",
process.ProcessID, "error", err)
+ slog.Error("Failed to record process workflow", "processId",
process.ProcessID, "error", err)
return err
}
slog.Info("Launched batch job submission", "processId",
process.ProcessID, "workflowId", workflowId)
diff --git a/api/process/service/workflow.go b/api/process/service/workflow.go
new file mode 100644
index 0000000000..4e97bf570d
--- /dev/null
+++ b/api/process/service/workflow.go
@@ -0,0 +1,129 @@
+/**
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+ */
+
+package service
+
+import (
+ "context"
+
+ "gorm.io/gorm"
+
+ "github.com/apache/airavata/internal/auth"
+ "github.com/apache/airavata/internal/httpx"
+
+ dto "github.com/apache/airavata/api/process/dto"
+ model "github.com/apache/airavata/api/process/model"
+ "github.com/apache/airavata/api/process/repository"
+)
+
+// WorkflowService records and reads the workflows started for a process.
+//
+// There is no create endpoint, by design: a workflow is recorded by the code
that
+// starts a workflow for the process, never accepted from a client request
body. Reads
+// are owner-scoped like TaskStatusService's, since a workflow id is a handle
on the
+// workflow engine's own record of the run.
+type WorkflowService struct {
+ db *gorm.DB
+ workflows *repository.WorkflowRepository
+ processes *repository.ProcessRepository
+}
+
+// NewWorkflowService returns a process workflow service.
+func NewWorkflowService(db *gorm.DB, workflows *repository.WorkflowRepository,
processes *repository.ProcessRepository) *WorkflowService {
+ return &WorkflowService{db: db, workflows: workflows, processes:
processes}
+}
+
+// Record records where a workflow of a process stands, in its own
+// transaction: the first call for a workflowID creates the record, and later
+// calls for the same one move it to the new status — RUNNING when the
workflow is
+// started, SUCCEEDED or FAILED when it finishes.
+//
+// It does not check authorisation: recording a workflow is an internal
operation
+// performed by trusted service code, never taken directly from a client
request.
+func (s *WorkflowService) Record(ctx context.Context, processID, workflowID
string, workflowType model.ProcessWorkflowType, status
model.ProcessWorkflowStatusType) (*dto.WorkflowResponse, error) {
+ var out dto.WorkflowResponse
+ err := s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
+ recorded, err := s.RecordTx(ctx, tx, processID, workflowID,
workflowType, status)
+ if err != nil {
+ return err
+ }
+ out = dto.ToWorkflowResponse(recorded)
+ return nil
+ })
+ if err != nil {
+ return nil, err
+ }
+ return &out, nil
+}
+
+// RecordTx creates or updates a process workflow inside an already-open
transaction, so a
+// caller that is already inside one of its own commits or rolls back the
workflow
+// together with the rest of its work.
+//
+// See WorkflowRepository.Record for what an update changes.
+func (s *WorkflowService) RecordTx(ctx context.Context, tx *gorm.DB,
processID, workflowID string, workflowType model.ProcessWorkflowType, status
model.ProcessWorkflowStatusType) (*model.ProcessWorkflow, error) {
+ if _, err := s.processes.WithTx(tx).FindByID(ctx, processID); err !=
nil {
+ return nil, notFoundAs(err, "Process not found: %s", processID)
+ }
+
+ return s.workflows.WithTx(tx).Record(ctx, processID, workflowID,
workflowType, status)
+}
+
+// ListForProcess returns every workflow recorded for a process, oldest first.
+func (s *WorkflowService) ListForProcess(ctx context.Context, processID
string) ([]dto.WorkflowResponse, error) {
+ if err := s.requireProcess(ctx, processID); err != nil {
+ return nil, err
+ }
+ found, err := s.workflows.FindByProcessID(ctx, processID)
+ if err != nil {
+ return nil, err
+ }
+ return dto.ToWorkflowResponses(found), nil
+}
+
+// Get returns one process workflow by its processWorkflowId, scoped to the
process it must belong to.
+func (s *WorkflowService) Get(ctx context.Context, processID,
processWorkflowID string) (*dto.WorkflowResponse, error) {
+ if err := s.requireProcess(ctx, processID); err != nil {
+ return nil, err
+ }
+ found, err := s.workflows.FindByIDAndProcessID(ctx, processWorkflowID,
processID)
+ if err != nil {
+ return nil, notFoundAs(err, "Workflow not found: %s in process
%s", processWorkflowID, processID)
+ }
+ out := dto.ToWorkflowResponse(found)
+ return &out, nil
+}
+
+// requireProcess checks the process exists and the caller may see its
workflows: its
+// owner, or an admin.
+func (s *WorkflowService) requireProcess(ctx context.Context, processID
string) error {
+ principal, err := auth.RequireAuthenticated(ctx)
+ if err != nil {
+ return err
+ }
+ proc, err := s.processes.FindByID(ctx, processID)
+ if err != nil {
+ return notFoundAs(err, "Process not found: %s", processID)
+ }
+ if !proc.OwnedBy(principal.Name) && !principal.IsAdmin() {
+ return httpx.Forbidden("Access denied: you may only work with
workflows of your own processes")
+ }
+ return nil
+}
diff --git a/dashboard/src/lib/types.ts b/dashboard/src/lib/types.ts
index a5584ddb58..500c318d84 100644
--- a/dashboard/src/lib/types.ts
+++ b/dashboard/src/lib/types.ts
@@ -250,7 +250,7 @@ export interface Process {
userId: string | null;
processType: "BATCH_JOB" | "CLOUD_JOB" | null;
lastStatusId: string | null;
- lastExecutionId: string | null;
+ lastWorkflowId: string | null;
batchProcess: BatchProcess | null;
}
diff --git a/docs/api.md b/docs/api.md
index 345f6d428d..b95621e713 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -1857,7 +1857,7 @@ Deleting the process deletes the batch section, and the
mappings with it.
"userId": "cilogon:sub:1234",
"processType": "BATCH_JOB",
"lastStatusId": "9f8e7d6c-5b4a-4392-8172-6a5b4c3d2e1f",
- "lastExecutionId": null,
+ "lastWorkflowId": null,
"batchProcess": {
"batchProcessId": "7e6d5c4b-3a29-4187-9605-4b3a2c1d0e9f",
"deploymentId": "c3d4e5f6-a7b8-4901-a2b3-c4d5e6f7a8b9",
@@ -2034,48 +2034,48 @@ Statuses come back oldest first. The newest one is also
cached on the process it
A `statusId` from one process is not reachable through another process's path:
the
mismatch is a `404`, not another run's status.
-## Process Executions
+## Process Workflows
The workflow runs started on a process's behalf, read-only and nested under
the process:
```
-GET /api/v1/processes/{processId}/executions
-GET /api/v1/processes/{processId}/executions/{executionId}
+GET /api/v1/processes/{processId}/workflows
+GET /api/v1/processes/{processId}/workflows/{processWorkflowId}
```
Each entry records one workflow instance — job submission, job monitoring or
job
-completion — by the id the workflow engine knows it by (`executionId`). Like
statuses,
-executions are recorded by the server when it starts a workflow, never
accepted from a
+completion — by the id the workflow engine knows it by (`workflowId`). Like
statuses,
+workflows are recorded by the server when it starts a workflow, never accepted
from a
client: `POST` and `PUT` return `405 Method Not Allowed`.
-Executions come back oldest first. The newest one is also cached on the
process itself
-as `lastExecutionId`, which stays `null` until the first workflow is started.
+Workflows come back oldest first. The newest one is also cached on the process
itself
+as `lastWorkflowId`, which stays `null` until the first workflow is started.
```json
[
{
- "processExecutionId": "4c3b2a19-0f8e-4d7c-9b6a-5e4d3c2b1a09",
+ "processWorkflowId": "4c3b2a19-0f8e-4d7c-9b6a-5e4d3c2b1a09",
"processId": "a1b2c3d4-e5f6-4708-9a1b-2c3d4e5f6a7b",
- "executionId": "e0d1c2b3-a4f5-4e6d-8c7b-9a0f1e2d3c4b",
- "executionType": "BATCH_JOB_SUBMISSION",
+ "workflowId": "e0d1c2b3-a4f5-4e6d-8c7b-9a0f1e2d3c4b",
+ "workflowType": "BATCH_JOB_SUBMISSION",
"status": "RUNNING",
"timestamp": 1755780005000
}
]
```
-`executionType` is one of `BATCH_JOB_SUBMISSION`, `JOB_MONITORING`,
+`workflowType` is one of `BATCH_JOB_SUBMISSION`, `JOB_MONITORING`,
`BATCH_JOB_COMPLETION`. `status` is `RUNNING` once the workflow is started,
then
-`SUCCEEDED` or `FAILED` when it finishes; it is `null` for executions recorded
before
-the server tracked it. `timestamp` is when the execution was started and does
not
-change with its status. The `{executionId}` in the path is the entry's
-`processExecutionId`, not the workflow engine's `executionId`.
+`SUCCEEDED` or `FAILED` when it finishes; it is `null` for workflows recorded
before
+the server tracked it. `timestamp` is when the workflow was started and does
not
+change with its status. The `{processWorkflowId}` in the path is the entry's
+`processWorkflowId`, not the workflow engine's `workflowId`.
Reads are owner-scoped: only the process's owner or an admin may list or read
its
-executions; anyone else gets `403`. A `processExecutionId` from one process is
not
+workflows; anyone else gets `403`. A `processWorkflowId` from one process is
not
reachable through another process's path — the mismatch is a `404`.
-Deleting a process deletes its executions with it.
+Deleting a process deletes its workflows with it.
## Process Tasks
diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index 7c1d356a11..d1974bb029 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -1890,50 +1890,50 @@ paths:
"502": { $ref: "#/components/responses/BadGateway" }
"500": { $ref: "#/components/responses/InternalError" }
- /api/v1/processes/{processId}/executions:
+ /api/v1/processes/{processId}/workflows:
parameters:
- $ref: "#/components/parameters/ProcessId"
get:
tags: [Processes]
- summary: List the workflow executions started for a process
+ summary: List the workflows started for a process
description: |
- Read-only, oldest first. Executions are recorded by the server when it
starts a
+ Read-only, oldest first. Workflows are recorded by the server when it
starts a
workflow for the process, never accepted from a client, so there is no
`POST`
or `PUT` here. Only the process's owner or an admin may read them.
- operationId: listProcessExecutions
+ operationId: listProcessWorkflows
responses:
"200":
- description: Every execution recorded for the process.
+ description: Every workflow recorded for the process.
content:
application/json:
schema:
type: array
- items: { $ref: "#/components/schemas/ExecutionResponse" }
+ items: { $ref: "#/components/schemas/WorkflowResponse" }
"401": { $ref: "#/components/responses/Unauthorized" }
"403": { $ref: "#/components/responses/Forbidden" }
"404": { $ref: "#/components/responses/NotFound" }
"500": { $ref: "#/components/responses/InternalError" }
- /api/v1/processes/{processId}/executions/{executionId}:
+ /api/v1/processes/{processId}/workflows/{processWorkflowId}:
parameters:
- $ref: "#/components/parameters/ProcessId"
- - name: executionId
+ - name: processWorkflowId
in: path
required: true
- description: The execution's `processExecutionId`.
+ description: The process workflow's `processWorkflowId`.
schema: { type: string }
get:
tags: [Processes]
- summary: Read one recorded execution
+ summary: Read one recorded process workflow
description: |
- An execution of another process is a `404` through this process's path.
- operationId: getProcessExecution
+ A workflow of another process is a `404` through this process's path.
+ operationId: getProcessWorkflow
responses:
"200":
- description: The execution.
+ description: The process workflow.
content:
application/json:
- schema: { $ref: "#/components/schemas/ExecutionResponse" }
+ schema: { $ref: "#/components/schemas/WorkflowResponse" }
"401": { $ref: "#/components/responses/Unauthorized" }
"403": { $ref: "#/components/responses/Forbidden" }
"404": { $ref: "#/components/responses/NotFound" }
@@ -2957,10 +2957,10 @@ components:
ProcessStatusType:
type: string
enum: [CREATED, SUBMITTED, RUNNING, COMPLETED, FAILED]
- ProcessExecutionType:
+ ProcessWorkflowType:
type: string
enum: [BATCH_JOB_SUBMISSION, JOB_MONITORING, BATCH_JOB_COMPLETION]
- ProcessExecutionStatusType:
+ ProcessWorkflowStatusType:
type: string
enum: [RUNNING, SUCCEEDED, FAILED]
OnFailureAction:
@@ -3652,10 +3652,10 @@ components:
- { $ref: "#/components/schemas/ProcessType" }
- { type: "null" }
lastStatusId: { type: [string, "null"], format: uuid }
- lastExecutionId:
+ lastWorkflowId:
type: [string, "null"]
format: uuid
- description: The newest recorded execution's `processExecutionId`,
if any.
+ description: The newest recorded workflow's `processWorkflowId`, if
any.
batchProcess:
oneOf:
- { $ref: "#/components/schemas/BatchProcessResponse" }
@@ -3681,34 +3681,34 @@ components:
description: When the status was recorded, in milliseconds since the
epoch.
required: [processStatusId]
- ExecutionResponse:
+ WorkflowResponse:
type: object
description: |
- One workflow execution started for a process. There is no request
counterpart:
- executions are recorded by the server when it starts a workflow, never
created
+ One workflow started for a process. There is no request counterpart:
+ workflows are recorded by the server when it starts a workflow, never
created
from a client body.
properties:
- processExecutionId: { type: string, format: uuid }
+ processWorkflowId: { type: string, format: uuid }
processId: { type: [string, "null"], format: uuid }
- executionId:
+ workflowId:
type: string
description: The id the workflow engine knows the run by.
- executionType:
+ workflowType:
oneOf:
- - { $ref: "#/components/schemas/ProcessExecutionType" }
+ - { $ref: "#/components/schemas/ProcessWorkflowType" }
- { type: "null" }
status:
description: |
`RUNNING` once the workflow is started, then `SUCCEEDED` or
`FAILED`. `null`
- for executions recorded before the server tracked it.
+ for workflows recorded before the server tracked it.
oneOf:
- - { $ref: "#/components/schemas/ProcessExecutionStatusType" }
+ - { $ref: "#/components/schemas/ProcessWorkflowStatusType" }
- { type: "null" }
timestamp:
type: [integer, "null"]
format: int64
- description: When the execution was recorded, in milliseconds since
the epoch.
- required: [processExecutionId, executionId]
+ description: When the workflow was recorded, in milliseconds since
the epoch.
+ required: [processWorkflowId, workflowId]
DataStagingTaskRequest:
type: object
diff --git a/internal/app/app.go b/internal/app/app.go
index e892dc8c61..37e1b598af 100644
--- a/internal/app/app.go
+++ b/internal/app/app.go
@@ -98,7 +98,7 @@ type Services struct {
Process *processsvc.ProcessService
ProcessStatus *processsvc.StatusService
TaskStatus *processsvc.TaskStatusService
- Execution *processsvc.ExecutionService
+ ProcessWorkflow *processsvc.WorkflowService
DataStagingTask *processsvc.DataStagingTaskService
JobSubmissionTask *processsvc.JobSubmissionTaskService
JobMonitoringTask *processsvc.JobMonitoringTaskService
@@ -129,7 +129,7 @@ type Repositories struct {
Processes *processrepo.ProcessRepository
Statuses *processrepo.StatusRepository
TaskStatuses *processrepo.TaskStatusRepository
- Executions *processrepo.ExecutionRepository
+ ProcessWorkflows *processrepo.WorkflowRepository
BatchJobStatuses *processrepo.BatchJobStatusRepository
DataStagingTasks *processrepo.DataStagingTaskRepository
JobSubmissionTasks *processrepo.JobSubmissionTaskRepository
@@ -156,7 +156,7 @@ func NewRepositories(db *gorm.DB) *Repositories {
Processes: processrepo.NewProcessRepository(db),
Statuses: processrepo.NewStatusRepository(db),
TaskStatuses:
processrepo.NewTaskStatusRepository(db),
- Executions: processrepo.NewExecutionRepository(db),
+ ProcessWorkflows: processrepo.NewWorkflowRepository(db),
BatchJobStatuses:
processrepo.NewBatchJobStatusRepository(db),
DataStagingTasks:
processrepo.NewDataStagingTaskRepository(db),
JobSubmissionTasks:
processrepo.NewJobSubmissionTaskRepository(db),
@@ -192,10 +192,10 @@ func NewServices(cfg config.Config, db *gorm.DB, repos
*Repositories, workflowBa
monitoringTasks := repos.JobMonitoringTasks
commandTasks := repos.InteractiveCommandTasks
batchStatus := repos.BatchJobStatuses
- processExecutions := repos.Executions
+ processWorkflows := repos.ProcessWorkflows
statusSvc := processsvc.NewStatusService(db, statuses, processes)
- executionSvc := processsvc.NewExecutionService(db, processExecutions,
processes)
+ processWorkflowSvc := processsvc.NewWorkflowService(db,
processWorkflows, processes)
configAccess := computesvc.NewConfigAccess(clusterConfigs, shares,
groupMembers)
keyAccess := credentialssvc.NewKeyAccess(sshCredentials)
processSvs := processsvc.NewProcessService(db, processes, deployments,
configAccess, users, statusSvc)
@@ -219,7 +219,7 @@ func NewServices(cfg config.Config, db *gorm.DB, repos
*Repositories, workflowBa
sshCredentialSvc :=
credentialssvc.NewSSHCredentialService(sshCredentials, users, clusterConfigs,
storages)
executionEngine := orchestration.NewExecutionEngine(stagingTasks,
submissionTasks,
- monitoringTasks, storages, clusterConfigs, processes,
deployments, templates, batchStatus, statuses, repos.TaskStatuses,
processExecutions, workflowBackend, sshContext)
+ monitoringTasks, storages, clusterConfigs, processes,
deployments, templates, batchStatus, statuses, repos.TaskStatuses,
processWorkflows, workflowBackend, sshContext)
executionEngine.StartEngine()
return &Services{
@@ -257,7 +257,7 @@ func NewServices(cfg config.Config, db *gorm.DB, repos
*Repositories, workflowBa
Process: processSvs,
ProcessStatus: statusSvc,
TaskStatus:
processsvc.NewTaskStatusService(repos.TaskStatuses, processes),
- Execution: executionSvc,
+ ProcessWorkflow: processWorkflowSvc,
DataStagingTask:
processsvc.NewDataStagingTaskService(db, stagingTasks, processes),
JobSubmissionTask:
processsvc.NewJobSubmissionTaskService(db, submissionTasks, processes),
JobMonitoringTask:
processsvc.NewJobMonitoringTaskService(db, monitoringTasks, processes),
@@ -265,7 +265,7 @@ func NewServices(cfg config.Config, db *gorm.DB, repos
*Repositories, workflowBa
Launch: processsvc.NewLaunchService(db, processSvs,
batchDeploymentSvc,
templateSvc, slurmClusterSvc, slurmClusterConfigSvc,
- sshCredentialSvc, scpDataStorageSvc, dataProductSvc,
statusSvc, executionSvc, stagingTasks, submissionTasks,
+ sshCredentialSvc, scpDataStorageSvc, dataProductSvc,
statusSvc, processWorkflowSvc, stagingTasks, submissionTasks,
monitoringTasks, commandTasks, executionEngine),
ExecutionEngine: executionEngine,
diff --git a/internal/db/foreignkey_test.go b/internal/db/foreignkey_test.go
index c4541f3aa9..e9d4894b25 100644
--- a/internal/db/foreignkey_test.go
+++ b/internal/db/foreignkey_test.go
@@ -71,7 +71,7 @@ func TestForeignKeyDirections(t *testing.T) {
{"batch_processes", "slurm_cluster_config_id",
"slurm_cluster_configs", "slurm_cluster_config_id"},
{"batch_processes", "batch_job_config_id", "batch_job_configs",
"batch_job_config_id"},
{"process_statuses", "process_id", "processes", "process_id"},
- {"process_executions", "process_id", "processes", "process_id"},
+ {"process_workflows", "process_id", "processes", "process_id"},
{"process_template_input_mappings", "batch_process_id",
"batch_processes", "batch_process_id"},
{"process_template_input_mappings", "template_input_id",
"application_template_inputs", "input_id"},
{"process_template_output_mappings", "batch_process_id",
"batch_processes", "batch_process_id"},
@@ -82,9 +82,9 @@ func TestForeignKeyDirections(t *testing.T) {
{"job_submission_tasks", "process_id", "processes",
"process_id"},
{"job_monitoring_tasks", "process_id", "processes",
"process_id"},
{"interactive_command_tasks", "process_id", "processes",
"process_id"},
- // processes.last_status_id and last_execution_id deliberately
have none: a constraint in that
- // direction would make the two tables mutually dependent,
which PostgreSQL
- // cannot create. See Process.LastStatusID.
+ // processes.last_status_id and last_workflow_id deliberately
have none: a
+ // constraint in that direction would make the two tables
mutually dependent,
+ // which PostgreSQL cannot create. See Process.LastStatusID.
}
// Collect what the schema actually declares.
diff --git a/internal/db/migrate.go b/internal/db/migrate.go
index 0912e8c731..216e12fb95 100644
--- a/internal/db/migrate.go
+++ b/internal/db/migrate.go
@@ -104,8 +104,8 @@ func Entities() []any {
&processmodel.TaskStatus{},
// The workflow runs started for a process. Like ProcessStatus
it is referenced
- // back from Process, through LastExecutionID, which carries no
constraint.
- &processmodel.ProcessExecution{},
+ // back from Process, through LastWorkflowID, which carries no
constraint.
+ &processmodel.ProcessWorkflow{},
}
}
diff --git a/internal/db/migrate_test.go b/internal/db/migrate_test.go
index 92069ce6fd..0e64cbd098 100644
--- a/internal/db/migrate_test.go
+++ b/internal/db/migrate_test.go
@@ -73,7 +73,7 @@ func TestAutoMigrateCreatesEveryTable(t *testing.T) {
"processes", "batch_processes", "batch_process_statuses",
"process_statuses",
"process_template_input_mappings",
"process_template_output_mappings",
"data_staging_tasks", "job_submission_tasks",
"job_monitoring_tasks",
- "interactive_command_tasks", "task_statuses",
"process_executions",
+ "interactive_command_tasks", "task_statuses",
"process_workflows",
}
for _, table := range want {
if !gdb.Migrator().HasTable(table) {
diff --git a/internal/db/migrations/0007_process_workflow_rename.sql
b/internal/db/migrations/0007_process_workflow_rename.sql
new file mode 100644
index 0000000000..3e8d6937fa
--- /dev/null
+++ b/internal/db/migrations/0007_process_workflow_rename.sql
@@ -0,0 +1,31 @@
+-- Rename the process execution entity to process workflow.
+--
+-- What a row records is a workflow run of the process (or the monitoring task
that
+-- follows its job), and "execution" collided with the execution engine and the
+-- execution context the workflows pass between tasks.
+--
+-- Everything here is a rename, so no data moves and no id changes: a client
holding a
+-- process workflow id keeps addressing the same row. The names are the ones
GORM
+-- derives from the renamed Go identifiers, which is what keeps this file and
+-- AutoMigrate in agreement — see TestBaselineMigrationMatchesAutoMigrate.
+--
+-- This is a migration rather than an edit of 0005 and 0006 because those have
already
+-- run: a database that applied them records their versions and would skip a
rewrite.
+
+ALTER TABLE "process_executions" RENAME TO "process_workflows";
+
+ALTER TABLE "process_workflows" RENAME COLUMN "process_execution_id" TO
"process_workflow_id";
+
+ALTER TABLE "process_workflows" RENAME COLUMN "execution_id" TO "workflow_id";
+
+ALTER TABLE "process_workflows" RENAME COLUMN "execution_type" TO
"workflow_type";
+
+ALTER TABLE "process_workflows" RENAME CONSTRAINT
"fk_process_executions_process" TO "fk_process_workflows_process";
+
+ALTER INDEX "process_executions_pkey" RENAME TO "process_workflows_pkey";
+
+ALTER INDEX "idx_process_executions_process_id" RENAME TO
"idx_process_workflows_process_id";
+
+ALTER TABLE "processes" RENAME COLUMN "last_execution_id" TO
"last_workflow_id";
+
+ALTER INDEX "idx_processes_last_execution_id" RENAME TO
"idx_processes_last_workflow_id";
diff --git a/internal/orchestration/engine.go b/internal/orchestration/engine.go
index 260e07486e..5f018647aa 100644
--- a/internal/orchestration/engine.go
+++ b/internal/orchestration/engine.go
@@ -70,7 +70,7 @@ func NewExecutionEngine(dataStagingTasks
*processrepo.DataStagingTaskRepository,
batchStatus *processrepo.BatchJobStatusRepository,
processStatus *processrepo.StatusRepository,
taskStatus *processrepo.TaskStatusRepository,
- executions *processrepo.ExecutionRepository,
+ processWorkflows *processrepo.WorkflowRepository,
workflowBackend backend.Backend,
sshContext *ssh.GlobalSSHContext,
) *ExecutionEngine {
@@ -90,7 +90,7 @@ func NewExecutionEngine(dataStagingTasks
*processrepo.DataStagingTaskRepository,
batch.New(processes, jobSubmissionTasks,
slurmClusterConfigs, batchDeployments, templates, batchStatus, sshContext,
tracker),
monitoring.New(processes, jobMonitoringTasks, tracker),
dataStagingTasks, jobSubmissionTasks,
jobMonitoringTasks, processStatus,
- executions,
+ processWorkflows,
),
orchestrator: orchestrator,
processes: processes,
diff --git a/internal/orchestration/workflows/workflows.go
b/internal/orchestration/workflows/workflows.go
index 4579176f52..d320642558 100644
--- a/internal/orchestration/workflows/workflows.go
+++ b/internal/orchestration/workflows/workflows.go
@@ -55,7 +55,7 @@ type Workflows struct {
jobSubmissionTasks *processrepo.JobSubmissionTaskRepository
jobMonitoringTasks *processrepo.JobMonitoringTaskRepository
processStatus *processrepo.StatusRepository
- executionRepo *processrepo.ExecutionRepository
+ processWorkflows *processrepo.WorkflowRepository
}
// New returns the workflows over the given tasks and the repositories they are
@@ -65,7 +65,7 @@ func New(data *data.Tasks, batch *batch.Tasks, monitoring
*monitoring.Tasks,
jobSubmissionTasks *processrepo.JobSubmissionTaskRepository,
jobMonitoringTasks *processrepo.JobMonitoringTaskRepository,
processStatus *processrepo.StatusRepository,
- executionRepo *processrepo.ExecutionRepository,
+ processWorkflows *processrepo.WorkflowRepository,
) *Workflows {
return &Workflows{
data: data,
@@ -75,7 +75,7 @@ func New(data *data.Tasks, batch *batch.Tasks, monitoring
*monitoring.Tasks,
jobSubmissionTasks: jobSubmissionTasks,
jobMonitoringTasks: jobMonitoringTasks,
processStatus: processStatus,
- executionRepo: executionRepo,
+ processWorkflows: processWorkflows,
}
}
@@ -171,8 +171,8 @@ func (w *Workflows) HandleBatchJobCompletion(ctx
workflow.Context, processID str
}
// record workflow completion
- if _, err := w.executionRepo.Record(ctxInt, processID,
workflow.WorkflowInstance(ctx).InstanceID,
model.ProcessExecutionTypeBatchJobSubmission,
model.ProcessExecutionStatusTypeSucceeded); err != nil {
- slog.Error("Failed to record execution", "processId",
processID, "error", err)
+ if _, err := w.processWorkflows.Record(ctxInt, processID,
workflow.WorkflowInstance(ctx).InstanceID,
model.ProcessWorkflowTypeBatchJobSubmission,
model.ProcessWorkflowStatusTypeSucceeded); err != nil {
+ slog.Error("Failed to record process workflow", "processId",
processID, "error", err)
return err
}
diff --git a/internal/orchestration/workflows/workflows_test.go
b/internal/orchestration/workflows/workflows_test.go
index fb09af1b5a..573c36e720 100644
--- a/internal/orchestration/workflows/workflows_test.go
+++ b/internal/orchestration/workflows/workflows_test.go
@@ -29,7 +29,7 @@ import (
// The backend refers to a workflow or activity by name alone, so each must
register,
// under the name a running instance was started with.
func TestRegister(t *testing.T) {
- w := New(nil, nil, nil, nil, nil, nil, nil)
+ w := New(nil, nil, nil, nil, nil, nil, nil, nil)
r := registry.New()
if err := w.Register(r); err != nil {
t.Fatal(err)
diff --git a/internal/server/server.go b/internal/server/server.go
index 6e993f36e9..9abeaffbdc 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -73,7 +73,7 @@ func New(cfg config.Config, svcs *app.Services, introspector
auth.Introspector)
processctl.NewLaunchController(svcs.Launch).Register(mux)
processctl.NewStatusController(svcs.ProcessStatus).Register(mux)
processctl.NewTaskStatusController(svcs.TaskStatus).Register(mux)
- processctl.NewExecutionController(svcs.Execution).Register(mux)
+ processctl.NewWorkflowController(svcs.ProcessWorkflow).Register(mux)
processctl.NewDataStagingTaskController(svcs.DataStagingTask).Register(mux)
processctl.NewJobSubmissionTaskController(svcs.JobSubmissionTask).Register(mux)
processctl.NewJobMonitoringTaskController(svcs.JobMonitoringTask).Register(mux)
diff --git a/internal/server/server_test.go b/internal/server/server_test.go
index fb937dd346..e5d3ea2867 100644
--- a/internal/server/server_test.go
+++ b/internal/server/server_test.go
@@ -2599,68 +2599,69 @@ func TestTaskStatusesAreReadThroughTheirProcess(t
*testing.T) {
}
}
-// Executions are recorded by the engine, read through the process they belong
to, and
-// owner-scoped like task statuses. Recording one repoints the process's
lastExecutionId.
-func TestExecutionsAreReadThroughTheirProcess(t *testing.T) {
+// Process workflows are recorded by the engine, read through the process they
belong
+// to, and owner-scoped like task statuses. Recording one repoints the
process's
+// lastWorkflowId.
+func TestProcessWorkflowsAreReadThroughTheirProcess(t *testing.T) {
h := newHarness(t)
- processID := h.seedProcess("executions", tokenAlice)
- other := h.seedProcess("other-executions", tokenAlice)
+ processID := h.seedProcess("workflows", tokenAlice)
+ other := h.seedProcess("other-workflows", tokenAlice)
ctx := context.Background()
- submission, err := h.svcs.Execution.Record(ctx, processID,
"workflow-1", "BATCH_JOB_SUBMISSION", "RUNNING")
+ submission, err := h.svcs.ProcessWorkflow.Record(ctx, processID,
"workflow-1", "BATCH_JOB_SUBMISSION", "RUNNING")
if err != nil {
t.Fatalf("record submission: %v", err)
}
- completion, err := h.svcs.Execution.Record(ctx, processID,
"workflow-2", "BATCH_JOB_COMPLETION", "RUNNING")
+ completion, err := h.svcs.ProcessWorkflow.Record(ctx, processID,
"workflow-2", "BATCH_JOB_COMPLETION", "RUNNING")
if err != nil {
t.Fatalf("record completion: %v", err)
}
- if _, err := h.svcs.Execution.Record(ctx, "no-such-process",
"workflow-3", "BATCH_JOB_SUBMISSION", "RUNNING"); err == nil {
+ if _, err := h.svcs.ProcessWorkflow.Record(ctx, "no-such-process",
"workflow-3", "BATCH_JOB_SUBMISSION", "RUNNING"); err == nil {
t.Error("recording against an unknown process succeeded, want
an error")
}
- all := h.list("/api/v1/processes/"+processID+"/executions", tokenAlice)
- if len(all) != 2 || all[0]["executionId"] != "workflow-1" ||
all[1]["executionId"] != "workflow-2" {
- t.Fatalf("executions = %v, want workflow-1 then workflow-2",
all)
+ all := h.list("/api/v1/processes/"+processID+"/workflows", tokenAlice)
+ if len(all) != 2 || all[0]["workflowId"] != "workflow-1" ||
all[1]["workflowId"] != "workflow-2" {
+ t.Fatalf("workflows = %v, want workflow-1 then workflow-2", all)
}
- if all[1]["executionType"] != "BATCH_JOB_COMPLETION" ||
all[1]["status"] != "RUNNING" {
- t.Errorf("execution = %v, want it to name its type and RUNNING
status", all[1])
+ if all[1]["workflowType"] != "BATCH_JOB_COMPLETION" || all[1]["status"]
!= "RUNNING" {
+ t.Errorf("workflow = %v, want it to name its type and RUNNING
status", all[1])
}
- // Recording the same workflow again moves its execution on rather than
adding one,
+ // Recording the same workflow again moves it on rather than adding one,
// keeping the type and start time it was first recorded with.
- finished, err := h.svcs.Execution.Record(ctx, processID, "workflow-1",
"JOB_MONITORING", "SUCCEEDED")
+ finished, err := h.svcs.ProcessWorkflow.Record(ctx, processID,
"workflow-1", "JOB_MONITORING", "SUCCEEDED")
if err != nil {
t.Fatalf("record finished submission: %v", err)
}
- if finished.ProcessExecutionID != submission.ProcessExecutionID {
- t.Errorf("re-recording created execution %s, want it to update
%s", finished.ProcessExecutionID, submission.ProcessExecutionID)
+ if finished.ProcessWorkflowID != submission.ProcessWorkflowID {
+ t.Errorf("re-recording created workflow %s, want it to update
%s", finished.ProcessWorkflowID, submission.ProcessWorkflowID)
}
- if *finished.ExecutionType != "BATCH_JOB_SUBMISSION" ||
*finished.Timestamp != *submission.Timestamp {
- t.Errorf("re-recorded execution = %+v, want its original type
and timestamp", finished)
+ if *finished.WorkflowType != "BATCH_JOB_SUBMISSION" ||
*finished.Timestamp != *submission.Timestamp {
+ t.Errorf("re-recorded workflow = %+v, want its original type
and timestamp", finished)
}
- if again := h.list("/api/v1/processes/"+processID+"/executions",
tokenAlice); len(again) != 2 {
- t.Errorf("executions after re-recording = %d, want still 2",
len(again))
+ if again := h.list("/api/v1/processes/"+processID+"/workflows",
tokenAlice); len(again) != 2 {
+ t.Errorf("workflows after re-recording = %d, want still 2",
len(again))
}
proc := h.mustDo(http.MethodGet, "/api/v1/processes/"+processID,
tokenAlice, nil, http.StatusOK)
- if proc["lastExecutionId"] != completion.ProcessExecutionID {
- t.Errorf("lastExecutionId = %v, want %s",
proc["lastExecutionId"], completion.ProcessExecutionID)
+ if proc["lastWorkflowId"] != completion.ProcessWorkflowID {
+ t.Errorf("lastWorkflowId = %v, want %s",
proc["lastWorkflowId"], completion.ProcessWorkflowID)
}
- one := h.mustDo(http.MethodGet,
"/api/v1/processes/"+processID+"/executions/"+submission.ProcessExecutionID,
tokenAlice, nil, http.StatusOK)
- if one["executionId"] != "workflow-1" || one["status"] != "SUCCEEDED" {
- t.Errorf("execution = %v, want workflow-1 SUCCEEDED", one)
+ one := h.mustDo(http.MethodGet,
"/api/v1/processes/"+processID+"/workflows/"+submission.ProcessWorkflowID,
tokenAlice, nil, http.StatusOK)
+ if one["workflowId"] != "workflow-1" || one["status"] != "SUCCEEDED" {
+ t.Errorf("workflow = %v, want workflow-1 SUCCEEDED", one)
}
- // An execution id from one process reads nothing through another's
path.
- if rec := h.do(http.MethodGet,
"/api/v1/processes/"+other+"/executions/"+submission.ProcessExecutionID,
tokenAlice, nil); rec.Code != http.StatusNotFound {
- t.Errorf("cross-process execution: status = %d, want 404",
rec.Code)
+ // An workflow id from one process reads nothing through another's path.
+ if rec := h.do(http.MethodGet,
"/api/v1/processes/"+other+"/workflows/"+submission.ProcessWorkflowID,
tokenAlice, nil); rec.Code != http.StatusNotFound {
+ t.Errorf("cross-process workflow: status = %d, want 404",
rec.Code)
}
for _, path := range []string{
- "/api/v1/processes/" + processID + "/executions",
- "/api/v1/processes/" + processID + "/executions/" +
submission.ProcessExecutionID,
+ "/api/v1/processes/" + processID + "/workflows",
+ "/api/v1/processes/" + processID + "/workflows/" +
submission.ProcessWorkflowID,
} {
if rec := h.do(http.MethodGet, path, tokenBob, nil); rec.Code
!= http.StatusForbidden {
t.Errorf("GET %s as another user: status = %d, want
403", path, rec.Code)
@@ -2671,21 +2672,21 @@ func TestExecutionsAreReadThroughTheirProcess(t
*testing.T) {
h.mustDo(http.MethodGet, path, tokenAdmin, nil, http.StatusOK)
}
- if rec := h.do(http.MethodGet,
"/api/v1/processes/no-such-process/executions", tokenAlice, nil); rec.Code !=
http.StatusNotFound {
+ if rec := h.do(http.MethodGet,
"/api/v1/processes/no-such-process/workflows", tokenAlice, nil); rec.Code !=
http.StatusNotFound {
t.Errorf("unknown process: status = %d, want 404", rec.Code)
}
- if rec := h.do(http.MethodPost,
"/api/v1/processes/"+processID+"/executions", tokenAlice, map[string]any{});
rec.Code != http.StatusMethodNotAllowed {
- t.Errorf("POST executions: status = %d, want 405", rec.Code)
+ if rec := h.do(http.MethodPost,
"/api/v1/processes/"+processID+"/workflows", tokenAlice, map[string]any{});
rec.Code != http.StatusMethodNotAllowed {
+ t.Errorf("POST workflows: status = %d, want 405", rec.Code)
}
- // The executions' foreign key is RESTRICT, so deleting the process
relies on
+ // The workflows' foreign key is RESTRICT, so deleting the process
relies on
// Process.BeforeDelete removing them first.
h.mustDo(http.MethodDelete, "/api/v1/processes/"+processID, tokenAdmin,
nil, http.StatusNoContent)
var left int64
- if err := h.db.Table("process_executions").Where("process_id = ?",
processID).Count(&left).Error; err != nil {
- t.Fatalf("count executions: %v", err)
+ if err := h.db.Table("process_workflows").Where("process_id = ?",
processID).Count(&left).Error; err != nil {
+ t.Fatalf("count workflows: %v", err)
}
if left != 0 {
- t.Errorf("executions left after deleting their process = %d,
want 0", left)
+ t.Errorf("workflows left after deleting their process = %d,
want 0", left)
}
}