Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [#4400]: Updated experiment run status enums and removed hard-coded statuses #4494

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ enum ExperimentRunStatus {
Skipped
Error
Timeout
Terminated
Queued
NA
}

Expand Down
2 changes: 2 additions & 0 deletions chaoscenter/graphql/server/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion chaoscenter/graphql/server/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec

executionData := types.ExecutionData{
Name: workflowManifest.Name,
Phase: "Queued",
Phase: string(model.ExperimentRunStatusQueued),
ExperimentID: workflow.ExperimentID,
}

Expand Down Expand Up @@ -856,7 +856,7 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
err = c.chaosExperimentRunOperator.CreateExperimentRun(sessionContext, dbChaosExperimentRun.ChaosExperimentRun{
InfraID: workflow.InfraID,
ExperimentID: workflow.ExperimentID,
Phase: "Queued",
Phase: string(model.ExperimentRunStatusQueued),
RevisionID: workflow.Revision[0].RevisionID,
ProjectID: projectID,
Audit: mongodb.Audit{
Expand Down Expand Up @@ -1042,27 +1042,27 @@ func (c *ChaosExperimentRunHandler) GetExperimentRunStats(ctx context.Context, p
return nil, err
}

resMap := map[string]int{
"Completed": 0,
"Stopped": 0,
"Running": 0,
"Terminated": 0,
"Error": 0,
resMap := map[model.ExperimentRunStatus]int{
model.ExperimentRunStatusCompleted: 0,
model.ExperimentRunStatusStopped: 0,
model.ExperimentRunStatusRunning: 0,
model.ExperimentRunStatusTerminated: 0,
model.ExperimentRunStatusError: 0,
}

totalExperimentRuns := 0
for _, phase := range res {
resMap[phase.Id] = phase.Count
resMap[model.ExperimentRunStatus(phase.Id)] = phase.Count
totalExperimentRuns = totalExperimentRuns + phase.Count
}

return &model.GetExperimentRunStatsResponse{
TotalExperimentRuns: totalExperimentRuns,
TotalCompletedExperimentRuns: resMap["Completed"],
TotalTerminatedExperimentRuns: resMap["Terminated"],
TotalRunningExperimentRuns: resMap["Running"],
TotalStoppedExperimentRuns: resMap["Stopped"],
TotalErroredExperimentRuns: resMap["Error"],
TotalCompletedExperimentRuns: resMap[model.ExperimentRunStatusCompleted],
TotalTerminatedExperimentRuns: resMap[model.ExperimentRunStatusTerminated],
TotalRunningExperimentRuns: resMap[model.ExperimentRunStatusRunning],
TotalStoppedExperimentRuns: resMap[model.ExperimentRunStatusStopped],
TotalErroredExperimentRuns: resMap[model.ExperimentRunStatusError],
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *ChaosWorkflowHandler) TerminateChaosWorkflow(ctx context.Context, proje
for _, workflowRun := range workflow.WorkflowRuns {
if workflowRun.WorkflowRunID == *workflowRunID {
workflowRun.Completed = true
workflowRun.Phase = "Terminated"
workflowRun.Phase = string(model.WorkflowRunStatusTerminated)
}
}

Expand Down
Loading