Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
namkyu1999 authored Nov 15, 2024
2 parents 43cad5d + 0c4d175 commit fa6c679
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 12 deletions.
42 changes: 35 additions & 7 deletions chaoscenter/authentication/api/handlers/rest/project_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,12 @@ func CreateProject(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, userRequest.UserID)
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

// checking if project name is empty
Expand Down Expand Up @@ -456,8 +460,12 @@ func SendInvitation(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, c.MustGet("uid").(string))
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

// Validating member role
Expand Down Expand Up @@ -558,8 +566,12 @@ func AcceptInvitation(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, c.MustGet("uid").(string))
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

err = validations.RbacValidator(c.MustGet("uid").(string), member.ProjectID,
Expand Down Expand Up @@ -614,8 +626,12 @@ func DeclineInvitation(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, c.MustGet("uid").(string))
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

err = validations.RbacValidator(c.MustGet("uid").(string), member.ProjectID,
Expand Down Expand Up @@ -684,8 +700,12 @@ func LeaveProject(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, c.MustGet("uid").(string))
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

err = validations.RbacValidator(c.MustGet("uid").(string), member.ProjectID,
Expand Down Expand Up @@ -744,8 +764,12 @@ func RemoveInvitation(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, c.MustGet("uid").(string))
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

err = validations.RbacValidator(c.MustGet("uid").(string), member.ProjectID,
Expand Down Expand Up @@ -824,8 +848,12 @@ func UpdateProjectName(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, c.MustGet("uid").(string))
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

err = validations.RbacValidator(c.MustGet("uid").(string),
Expand Down
31 changes: 26 additions & 5 deletions chaoscenter/authentication/api/handlers/rest/user_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,18 @@ func UpdateUser(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, uid)
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

err = service.UpdateUser(&userRequest)
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
return
}
c.JSON(http.StatusOK, gin.H{"message": "User details updated successfully"})
}
Expand Down Expand Up @@ -554,8 +559,12 @@ func ResetPassword(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, uid)
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

if userPasswordRequest.NewPassword != "" {
Expand Down Expand Up @@ -610,8 +619,12 @@ func UpdateUserState(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, adminUser.ID)
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

if entities.Role(userRole) != entities.RoleAdmin {
Expand Down Expand Up @@ -689,8 +702,12 @@ func CreateApiToken(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, apiTokenRequest.UserID)
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

// Checking if user exists
Expand Down Expand Up @@ -785,8 +802,12 @@ func DeleteApiToken(service services.ApplicationService) gin.HandlerFunc {
initialLogin, err := CheckInitialLogin(service, deleteApiTokenRequest.UserID)
if err != nil {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError))
} else if initialLogin {
return
}

if initialLogin {
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrPasswordNotUpdated))
return
}

token := deleteApiTokenRequest.Token
Expand Down
Binary file added proposals/images/rds-fault-scenario.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions proposals/rds-instance-chaos-fault.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
| title | authors | creation-date | last-updated |
|--------------------------------------------------|------------------------------------------|---------------|--------------|
| Adding a New Chaos Fault - AWS RDS Instance Stop | [@jongwooo](https://github.com/jongwooo) | 2024-09-02 | 2024-09-02 |

# Adding a New Chaos Fault - AWS RDS Instance Stop

- [Summary](#summary)
- [Motivation](#motivation)
- [Goals](#goals)
- [Non-Goals](#non-goals)
- [Proposal](#proposal)
- [Use Cases](#use-cases)
- [Implementation Details](#implementation-details)
- [Risks and Mitigations](#risks-and-mitigations)
- [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy)
- [Drawbacks](#drawbacks)
- [Alternatives](#alternatives)
- [References](#references)

## Summary

[Amazon Relational Database Service (RDS)](https://aws.amazon.com/en/rds/) is a managed relational database service provided by AWS. It is a fully managed database service that makes it easy to set up, operate, and scale a relational database in the cloud.
So I want to add a new chaos fault(rds instance stop) to Litmus ChaosHub.

## Motivation

Litmus ChaosHub has plenty of Chaos Faults. But there is no Chaos Fault for RDS. RDS is a widely used service in AWS. So I want to add a new Chaos Fault for RDS. Adding 'rds instance stop' Chaos Fault to Litmus ChaosHub can help create a more resilient system.
### Goals

- Adding a 'rds instance stop' Chaos Fault to [Litmus ChaosHub](https://hub.litmuschaos.io/)
- Fixing [litmus-go](https://github.com/litmuschaos/litmus-go) and [chaos-charts](https://github.com/litmuschaos/chaos-charts) codes

### Non-Goals

- Fixing Litmus codes except for [litmus-go](https://github.com/litmuschaos/litmus-go) and [chaos-charts](https://github.com/litmuschaos/chaos-charts) is a non-goal

## Proposal

### Use Cases

#### Use case 1

In Chaos Studio, Users can select 'rds instance stop' Chaos Fault as part of the Chaos Experiment. They can compose it with other Chaos Faults.

### Implementation Details

Here's a Chaos Fault Scenario.

![rds-fault-scenario](./images/rds-fault-scenario.png)

#### Phase 1 - Add scenario to the litmus-go repository

I will use `litmuschaos/go-runner` image. So I am going to add a new case in the litmus-go repository.

#### Phase 2 - Add a new Chaos Fault to the Litmus ChaosHub

After Phase 1 PR gets merged, I will raise a PR that adds a 'rds instance stop' Chaos Fault to the `chaos-charts` repository. When all is done, the user can easily assault the AWS RDS instance.

## Risks and Mitigations

We need to grant proper RBAC permissions to the runner container. Granting override permissions may affect other systems.

## Upgrade / Downgrade Strategy

## Drawbacks

## Alternatives

## References

- [Amazon Relational Database Service (RDS)](https://aws.amazon.com/en/rds/)
38 changes: 38 additions & 0 deletions proposals/replace-mongoDB-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
| title | authors | creation-date | last-updated |
|-------|------------------------------------------|---------------|--------------|
| Replace mongoDB features not supported by AWS | [@kwx4957](https://github.com/kwx4957) | | |

### Summary

There are some operators that are supported by mongoDB but not by aws documentDB. Enhancing this feature with other features or code would make LitmusChaos more developer-friendly on AWS.

### Goals

- Changing features not supported by the cloud environment (AWS) with alternative operators or in code

### Implementation Details
[AWS support api scanning](https://docs.aws.amazon.com/documentdb/latest/developerguide/migration-playbook.html)

As a result of using these features, the two operators $facet and $bucket are not supported by AWS. We are using the following features in graphQL and expect that modifying them with other features or code will make it easier to run LitmusChaos on AWS.

```
he following 2 unsupported operators were found:
$facet | found 8 time(s)
$bucket | found 1 time(s)
Unsupported operators by filename and line number:
$facet | lines = found 8 time(s)
../../litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go | lines = [664, 841]
../../litmus/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go | lines = [733, 955, 1131]
../../litmus/chaoscenter/graphql/server/pkg/chaos_experiment_run/handler/handler.go | lines = [531]
../../litmus/chaoscenter/graphql/server/pkg/environment/handler/handler.go | lines = [346]
../../litmus/chaoscenter/graphql/server/pkg/chaoshub/service.go | lines = [922]
$bucket | lines = found 1 time(s)
../../litmus/chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go | lines = [1106]
```


## References
[issue#4459](https://github.com/litmuschaos/litmus/issues/4459)
[AWS support api](https://docs.aws.amazon.com/documentdb/latest/developerguide/mongo-apis.html#w144aac17c19b5b3)
[Azure support api](https://learn.microsoft.com/es-es/azure/cosmos-db/mongodb/feature-support-36#aggregation-stages)

0 comments on commit fa6c679

Please sign in to comment.