MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / Remove

Method Remove

server/api/shard.go:92–115  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

90}
91
92func (handler *ShardHandler) Remove(c *gin.Context) {
93 ns := c.Param("namespace")
94 shardIdx, err := strconv.Atoi(c.Param("shard"))
95 if err != nil {
96 helper.ResponseBadRequest(c, err)
97 return
98 }
99 cluster, _ := c.MustGet(consts.ContextKeyCluster).(*store.Cluster)
100
101 if shardIdx < 0 || shardIdx >= len(cluster.Shards) {
102 helper.ResponseBadRequest(c, consts.ErrIndexOutOfRange)
103 return
104 }
105 if cluster.Shards[shardIdx].IsServicing() {
106 helper.ResponseBadRequest(c, consts.ErrShardIsServicing)
107 return
108 }
109 cluster.Shards = append(cluster.Shards[:shardIdx], cluster.Shards[shardIdx+1:]...)
110 if err := handler.s.UpdateCluster(c, ns, cluster); err != nil {
111 helper.ResponseError(c, err)
112 return
113 }
114 helper.ResponseNoContent(c)
115}
116
117func (handler *ShardHandler) Failover(c *gin.Context) {
118 ns := c.Param("namespace")

Callers 1

TestShardBasicsFunction · 0.95

Calls 5

ResponseBadRequestFunction · 0.92
ResponseErrorFunction · 0.92
ResponseNoContentFunction · 0.92
IsServicingMethod · 0.80
UpdateClusterMethod · 0.65

Tested by 1

TestShardBasicsFunction · 0.76