Skip to content

Commit

Permalink
chore: Updating GetProbesInExperimentRun API (#4257)
Browse files Browse the repository at this point in the history
* chore: Updating GetProbesInExperimentRun API

* chore: Fixing goimport issue
  • Loading branch information
S-ayanide authored Nov 3, 2023
1 parent 11f97f6 commit 997d1ab
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ func (c *ChaosExperimentHandler) GetProbesInExperimentRun(ctx context.Context, p
probeDetails []*model.GetProbesInExperimentRunResponse
probeStatusMap = make(map[string]model.ProbeVerdict)
probeDescriptionMap = make(map[string]*string)
executionData types.ExecutionData
probeModeMap = make(map[string]model.Mode)
)

wfRun, err := c.chaosExperimentRunOperator.GetExperimentRun(bson.D{
Expand All @@ -1220,16 +1220,12 @@ func (c *ChaosExperimentHandler) GetProbesInExperimentRun(ctx context.Context, p
return nil, err
}

if err = json.Unmarshal([]byte(wfRun.ExecutionData), &executionData); err != nil {
return nil, errors.New("failed to unmarshal workflow manifest")
}

for _, _probe := range wfRun.Probes {
if _probe.FaultName == faultName {

mode := "SOT"
for _, probeName := range _probe.ProbeNames {
var executionData types.ExecutionData
probeStatusMap[probeName] = model.ProbeVerdictNa
probeModeMap[probeName] = model.ModeSot
description := "Either probe is not executed or not evaluated"
probeDescriptionMap[probeName] = &description

Expand All @@ -1250,7 +1246,7 @@ func (c *ChaosExperimentHandler) GetProbesInExperimentRun(ctx context.Context, p

for _, probeStatus := range probeStatuses {
if probeStatus.Name == probeName {
mode = probeStatus.Mode
probeModeMap[probeName] = model.Mode(probeStatus.Mode)

description := probeStatus.Status.Description
probeDescriptionMap[probeStatus.Name] = &description
Expand Down Expand Up @@ -1286,7 +1282,7 @@ func (c *ChaosExperimentHandler) GetProbesInExperimentRun(ctx context.Context, p

probeDetails = append(probeDetails, &model.GetProbesInExperimentRunResponse{
Probe: singleProbe.GetOutputProbe(),
Mode: model.Mode(mode),
Mode: probeModeMap[probeName],
Status: &model.Status{
Verdict: probeStatusMap[probeName],
Description: probeDescriptionMap[probeName],
Expand Down

0 comments on commit 997d1ab

Please sign in to comment.