Skip to content

Commit

Permalink
fix(obcluster): restrict locality principle when deleting obzone
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI committed Mar 27, 2024
1 parent 4519f6c commit ed3a6c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/dashboard/business/oceanbase/obcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ func DeleteOBZone(ctx context.Context, obzoneIdentity *param.OBZoneIdentity) (*r
// if obcluster.Status.Status != clusterstatus.Running {
// return errors.Errorf("Obcluster status invalid %s", obcluster.Status.Status)
// }
if len(obcluster.Spec.Topology) <= 2 {
return nil, oberr.NewBadRequest("Forbid to delete zone when the number of zone <= 2")
}
newTopology := make([]apitypes.OBZoneTopology, 0)
found := false
for _, obzone := range obcluster.Spec.Topology {
Expand Down
3 changes: 3 additions & 0 deletions internal/dashboard/handler/obcluster_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ func ScaleOBServer(c *gin.Context) (*response.OBCluster, error) {
if err != nil {
return nil, httpErr.NewBadRequest(err.Error())
}
if scaleParam.Replicas <= 0 {
return nil, httpErr.NewBadRequest("Replicas must be greater than 0")
}
logger.Infof("Scale observer with param: %+v", scaleParam)
return oceanbase.ScaleOBServer(c, obzoneIdentity, scaleParam)
}
Expand Down

0 comments on commit ed3a6c5

Please sign in to comment.