Skip to content

Commit

Permalink
fix: Fixed duplicate probe issue in enable/disable cron API (#4296)
Browse files Browse the repository at this point in the history
* fix: Fixed duplicate probe issue in enable/disable cron API

Signed-off-by: Hrishav <hrishav.kumar@harness.io>

* chore: Updated go imports

Signed-off-by: Hrishav <hrishav.kumar@harness.io>

---------

Signed-off-by: Hrishav <hrishav.kumar@harness.io>
  • Loading branch information
hrishavjha committed Nov 15, 2023
1 parent fd2a996 commit 944ba06
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go
Expand Up @@ -9,12 +9,12 @@ import (
"strconv"
"time"

"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
dbChaosInfra "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_infrastructure"
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/probe"

"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
chaosTypes "github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1"
"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_experiment/ops"
dbChaosInfra "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_infrastructure"

dbSchemaProbe "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/probe"

Expand Down Expand Up @@ -1358,11 +1358,6 @@ func (c *ChaosExperimentHandler) UpdateCronExperimentState(ctx context.Context,
return false, fmt.Errorf("failed to unmarshal experiment manifest, error: %s", err.Error())
}

cronWorkflowManifest, err = probe.GenerateCronExperimentManifestWithProbes(experiment.Revision[0].ExperimentManifest, experiment.ProjectID)
if err != nil {
return false, fmt.Errorf("failed to unmarshal experiment manifest, error: %v", err)
}

//state of the cron experiment state
cronWorkflowManifest.Spec.Suspend = disable

Expand All @@ -1386,7 +1381,6 @@ func (c *ChaosExperimentHandler) UpdateCronExperimentState(ctx context.Context,
}

//Update the runtime values in cron experiment manifest

cronWorkflowManifest, _, err = c.chaosExperimentService.UpdateRuntimeCronWorkflowConfiguration(cronWorkflowManifest, experiment)
if err != nil {
return false, err
Expand All @@ -1396,6 +1390,17 @@ func (c *ChaosExperimentHandler) UpdateCronExperimentState(ctx context.Context,
if err != nil {
return false, errors.New("failed to marshal workflow manifest")
}

cronWorkflowManifest, err = probe.GenerateCronExperimentManifestWithProbes(string(updatedManifest), experiment.ProjectID)
if err != nil {
return false, fmt.Errorf("failed to unmarshal experiment manifest, error: %v", err)
}

updatedManifest, err = json.Marshal(cronWorkflowManifest)
if err != nil {
return false, errors.New("failed to marshal workflow manifest")
}

if r != nil {
chaos_infrastructure.SendExperimentToSubscriber(projectID, &model.ChaosExperimentRequest{
ExperimentID: &workflowID,
Expand Down

0 comments on commit 944ba06

Please sign in to comment.