Skip to content

Commit

Permalink
Enable cron (#4239)
Browse files Browse the repository at this point in the history
* Added API for enable  and disable cron

Signed-off-by: Saranya-jena <[email protected]>

* Added backend implementation to toggle enable/disable cron experiment

Signed-off-by: Saranya-jena <[email protected]>

* fixed imports

Signed-off-by: Saranya-jena <[email protected]>

* removed code for disable cron from stop experiment

Signed-off-by: Saranya-jena <[email protected]>

---------

Signed-off-by: Saranya-jena <[email protected]>
  • Loading branch information
Saranya-jena authored Nov 7, 2023
1 parent 997d1ab commit 8cf7902
Show file tree
Hide file tree
Showing 9 changed files with 360 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -768,4 +768,12 @@ extend type Mutation {
experimentRunID: String
projectID: ID!
): Boolean!

"""
Enable/Disable cron experiment state
"""
updateCronExperimentState(experimentID: String!
disable: Boolean!
projectID: ID!
): Boolean! @authorized
}
23 changes: 23 additions & 0 deletions chaoscenter/graphql/server/graph/chaos_experiment.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,29 @@ func (r *mutationResolver) DeleteChaosExperiment(ctx context.Context, experiment
return uiResponse, err
}

func (r *mutationResolver) UpdateCronExperimentState(ctx context.Context, experimentID string, disable bool, projectID string) (bool, error) {
logFields := logrus.Fields{
"projectId": projectID,
"chaosExperimentId": experimentID,
}

logrus.WithFields(logFields).Info("request received to update cron chaos experiment")

err := authorization.ValidateRole(ctx, projectID,
authorization.MutationRbacRules[authorization.UpdateChaosWorkflow],
model.InvitationAccepted.String())
if err != nil {
return false, err
}

uiResponse, err := r.chaosExperimentHandler.UpdateCronExperimentState(ctx, experimentID, disable, projectID, data_store.Store)
if err != nil {
logrus.WithFields(logFields).Error(err)
return false, err
}
return uiResponse, err
}

func (r *queryResolver) GetExperiment(ctx context.Context, projectID string, experimentID string) (*model.GetExperimentResponse, error) {
logFields := logrus.Fields{
"projectId": projectID,
Expand Down
184 changes: 151 additions & 33 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.

Loading

0 comments on commit 8cf7902

Please sign in to comment.