From 852b836f7e4645134707cf89762f07b410e776e0 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Mon, 15 Sep 2025 12:09:56 +0200 Subject: [PATCH] Add /cluster/db/map/reallocate for retrieving the current reallocation jobs --- http/api/cluster.go | 2 ++ http/handler/api/cluster.go | 4 ++-- http/handler/api/cluster_store.go | 17 ++++++++++++++++- http/server.go | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/http/api/cluster.go b/http/api/cluster.go index eeed2b8b..b287ebfe 100644 --- a/http/api/cluster.go +++ b/http/api/cluster.go @@ -108,6 +108,8 @@ type ClusterKVS map[string]ClusterKVSValue type ClusterProcessMap map[string]string +type ClusterProcessRelocateMap map[string]string + type ClusterProcessReallocate struct { TargetNodeID string `json:"target_node_id"` Processes []ProcessID `json:"process_ids"` diff --git a/http/handler/api/cluster.go b/http/handler/api/cluster.go index 35185e96..4fbbd801 100644 --- a/http/handler/api/cluster.go +++ b/http/handler/api/cluster.go @@ -247,8 +247,8 @@ func (h *ClusterHandler) GetSnapshot(c echo.Context) error { } // Reallocation issues reallocation requests of processes -// @Summary Retrieve snapshot of the cluster DB -// @Description Retrieve snapshot of the cluster DB +// @Summary Issue reallocation requests of processes +// @Description Issue reallocation requests of processes // @Tags v16.?.? // @ID cluster-3-reallocation // @Produce json diff --git a/http/handler/api/cluster_store.go b/http/handler/api/cluster_store.go index 59eeadae..3dc09513 100644 --- a/http/handler/api/cluster_store.go +++ b/http/handler/api/cluster_store.go @@ -86,13 +86,28 @@ func (h *ClusterHandler) StoreGetProcess(c echo.Context) error { // @Produce json // @Success 200 {object} api.ClusterProcessMap // @Security ApiKeyAuth -// @Router /api/v3/cluster/map/process [get] +// @Router /api/v3/cluster/db/map/process [get] func (h *ClusterHandler) StoreGetProcessNodeMap(c echo.Context) error { m := h.cluster.Store().ProcessGetNodeMap() return c.JSON(http.StatusOK, m) } +// StoreGetProcessRelocateMap returns a map of which processes should be relocated +// @Summary Retrieve a map of which processes should be relocated +// @Description Retrieve a map of which processes should be relocated +// @Tags v16.?.? +// @ID cluster-3-db-process-relocate-map +// @Produce json +// @Success 200 {object} api.ClusterProcessRelocateMap +// @Security ApiKeyAuth +// @Router /api/v3/cluster/db/map/reallocate [get] +func (h *ClusterHandler) StoreGetProcessRelocateMap(c echo.Context) error { + m := h.cluster.Store().ProcessGetRelocateMap() + + return c.JSON(http.StatusOK, m) +} + // StoreListIdentities returns the list of identities stored in the DB of the cluster // @Summary List of identities in the cluster // @Description List of identities in the cluster diff --git a/http/server.go b/http/server.go index 1e545425..5a6cf62e 100644 --- a/http/server.go +++ b/http/server.go @@ -742,6 +742,7 @@ func (s *server) setRoutesV3(v3 *echo.Group) { v3.GET("/cluster/db/locks", s.v3handler.cluster.StoreListLocks) v3.GET("/cluster/db/kv", s.v3handler.cluster.StoreListKV) v3.GET("/cluster/db/map/process", s.v3handler.cluster.StoreGetProcessNodeMap) + v3.GET("/cluster/db/map/reallocate", s.v3handler.cluster.StoreGetProcessRelocateMap) v3.GET("/cluster/db/node", s.v3handler.cluster.StoreListNodes) v3.GET("/cluster/iam/user", s.v3handler.cluster.IAMIdentityList)