Skip to content

Commit ed811db

Browse files
committed
rm: map keyspace service-limit errors to 403/500
Signed-off-by: okjiang <819421878@qq.com>
1 parent 0ff97e8 commit ed811db

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pkg/mcs/resourcemanager/server/apis/v1/api.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,11 @@ func (s *Service) setKeyspaceServiceLimit(c *gin.Context) {
376376
}
377377
keyspaceID := rmserver.ExtractKeyspaceID(keyspaceIDValue)
378378
if err := s.manager.SetKeyspaceServiceLimit(keyspaceID, req.ServiceLimit); err != nil {
379-
c.String(http.StatusBadRequest, err.Error())
379+
if rmserver.IsMetadataWriteDisabledError(err) {
380+
c.String(http.StatusForbidden, err.Error())
381+
return
382+
}
383+
c.String(http.StatusInternalServerError, err.Error())
380384
return
381385
}
382386
c.String(http.StatusOK, "Success!")

pkg/mcs/resourcemanager/server/write_role.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 TiKV Project Authors.
1+
// Copyright 2026 TiKV Project Authors.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -39,3 +39,8 @@ func (r ResourceGroupWriteRole) AllowsStateWrite() bool {
3939
}
4040

4141
var errMetadataWriteDisabled = errors.New("metadata write is disabled")
42+
43+
// IsMetadataWriteDisabledError reports whether err is a metadata-write-disabled error.
44+
func IsMetadataWriteDisabledError(err error) bool {
45+
return errors.ErrorEqual(err, errMetadataWriteDisabled)
46+
}

0 commit comments

Comments
 (0)