fix: Fixed duplicate probe issue in enable/disable cron API (#4296)
* 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>
This commit is contained in:
parent
fd2a99639d
commit
944ba06e33
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue