Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcs: fix api wrongly send to scheduling server #7403

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions server/api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
return
}
rc.DropCacheRegion(regionID)
if h.svr.IsAPIServiceMode() {
if h.svr.IsServiceIndependent(utils.SchedulingServiceName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to add judge in pkg/utils/apiutil/serverapi/middleware.go with h.s.IsServiceIndependent(rule.targetServiceName)
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added it in #7297

err = h.DeleteRegionCacheInSchedulingServer(regionID)
}
msg := "The region is removed from server cache."
Expand Down Expand Up @@ -101,7 +101,7 @@
}
// Remove region from cache.
rc.DropCacheRegion(regionID)
if h.svr.IsAPIServiceMode() {
if h.svr.IsServiceIndependent(utils.SchedulingServiceName) {

Check warning on line 104 in server/api/admin.go

View check run for this annotation

Codecov / codecov/patch

server/api/admin.go#L104

Added line #L104 was not covered by tests
err = h.DeleteRegionCacheInSchedulingServer(regionID)
}
msg := "The region is removed from server cache and region meta storage."
Expand All @@ -117,7 +117,7 @@
var err error
rc := getCluster(r)
rc.DropCacheAllRegion()
if h.svr.IsAPIServiceMode() {
if h.svr.IsServiceIndependent(utils.SchedulingServiceName) {
err = h.DeleteRegionCacheInSchedulingServer()
}
msg := "All regions are removed from server cache."
Expand Down Expand Up @@ -241,7 +241,7 @@
}

func (h *adminHandler) buildMsg(msg string, err error) string {
if h.svr.IsAPIServiceMode() && err != nil {
if h.svr.IsServiceIndependent(utils.SchedulingServiceName) && err != nil {
return fmt.Sprintf("This operation was executed in API server but needs to be re-executed on scheduling server due to the following error: %s", err.Error())
}
return msg
Expand Down
6 changes: 3 additions & 3 deletions server/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func newConfHandler(svr *server.Server, rd *render.Render) *confHandler {
// @Router /config [get]
func (h *confHandler) GetConfig(w http.ResponseWriter, r *http.Request) {
cfg := h.svr.GetConfig()
if h.svr.IsAPIServiceMode() {
if h.svr.IsServiceIndependent(utils.SchedulingServiceName) {
schedulingServerConfig, err := h.GetSchedulingServerConfig()
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
Expand Down Expand Up @@ -313,7 +313,7 @@ func getConfigMap(cfg map[string]interface{}, key []string, value interface{}) m
// @Success 200 {object} sc.ScheduleConfig
// @Router /config/schedule [get]
func (h *confHandler) GetScheduleConfig(w http.ResponseWriter, r *http.Request) {
if h.svr.IsAPIServiceMode() {
if h.svr.IsServiceIndependent(utils.SchedulingServiceName) {
cfg, err := h.GetSchedulingServerConfig()
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
Expand Down Expand Up @@ -386,7 +386,7 @@ func (h *confHandler) SetScheduleConfig(w http.ResponseWriter, r *http.Request)
// @Success 200 {object} sc.ReplicationConfig
// @Router /config/replicate [get]
func (h *confHandler) GetReplicationConfig(w http.ResponseWriter, r *http.Request) {
if h.svr.IsAPIServiceMode() {
if h.svr.IsServiceIndependent(utils.SchedulingServiceName) {
cfg, err := h.GetSchedulingServerConfig()
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
Expand Down
Loading