Skip to content

Commit

Permalink
mcs: remove resource manager service (#8804)
Browse files Browse the repository at this point in the history
close #8805

Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx authored Nov 12, 2024
1 parent bb4c437 commit 9415fdc
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 711 deletions.
26 changes: 1 addition & 25 deletions cmd/pd-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/tikv/pd/pkg/autoscaling"
"github.com/tikv/pd/pkg/dashboard"
"github.com/tikv/pd/pkg/errs"
resource_manager "github.com/tikv/pd/pkg/mcs/resourcemanager/server"
scheduling "github.com/tikv/pd/pkg/mcs/scheduling/server"
tso "github.com/tikv/pd/pkg/mcs/tso/server"
"github.com/tikv/pd/pkg/memory"
Expand All @@ -53,7 +52,6 @@ import (
const (
apiMode = "api"
tsoMode = "tso"
rmMode = "resource-manager"
serviceModeEnv = "PD_SERVICE_MODE"
)

Expand All @@ -78,10 +76,9 @@ func main() {
func NewServiceCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "services <mode>",
Short: "Run services, for example, tso, resource_manager",
Short: "Run services, for example, tso, scheduling",
}
cmd.AddCommand(NewTSOServiceCommand())
cmd.AddCommand(NewResourceManagerServiceCommand())
cmd.AddCommand(NewSchedulingServiceCommand())
cmd.AddCommand(NewAPIServiceCommand())
return cmd
Expand Down Expand Up @@ -129,27 +126,6 @@ func NewSchedulingServiceCommand() *cobra.Command {
return cmd
}

// NewResourceManagerServiceCommand returns the resource manager service command.
func NewResourceManagerServiceCommand() *cobra.Command {
cmd := &cobra.Command{
Use: rmMode,
Short: "Run the resource manager service",
Run: resource_manager.CreateServerWrapper,
}
cmd.Flags().StringP("name", "", "", "human-readable name for this resource manager member")
cmd.Flags().BoolP("version", "V", false, "print version information and exit")
cmd.Flags().StringP("config", "", "", "config file")
cmd.Flags().StringP("backend-endpoints", "", "", "url for etcd client")
cmd.Flags().StringP("listen-addr", "", "", "listen address for resource management service")
cmd.Flags().StringP("advertise-listen-addr", "", "", "advertise urls for listen address (default '${listen-addr}')")
cmd.Flags().StringP("cacert", "", "", "path of file that contains list of trusted TLS CAs")
cmd.Flags().StringP("cert", "", "", "path of file that contains X509 certificate in PEM format")
cmd.Flags().StringP("key", "", "", "path of file that contains X509 key in PEM format")
cmd.Flags().StringP("log-level", "L", "", "log level: debug, info, warn, error, fatal (default 'info')")
cmd.Flags().StringP("log-file", "", "", "log file path")
return cmd
}

// NewAPIServiceCommand returns the API service command.
func NewAPIServiceCommand() *cobra.Command {
cmd := &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion pkg/mcs/discovery/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Discover(cli *clientv3.Client, serviceName string) ([]string, error) {
// GetMSMembers returns all the members of the specified service name.
func GetMSMembers(serviceName string, client *clientv3.Client) ([]ServiceRegistryEntry, error) {
switch serviceName {
case constant.TSOServiceName, constant.SchedulingServiceName, constant.ResourceManagerServiceName:
case constant.TSOServiceName, constant.SchedulingServiceName:
servicePath := keypath.ServicePath(serviceName)
resps, err := kv.NewSlowLogTxn(client).Then(clientv3.OpGet(servicePath, clientv3.WithPrefix())).Commit()
if err != nil {
Expand Down
25 changes: 0 additions & 25 deletions pkg/mcs/resourcemanager/server/apis/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ import (
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
rmpb "github.com/pingcap/kvproto/pkg/resource_manager"
"github.com/pingcap/log"
rmserver "github.com/tikv/pd/pkg/mcs/resourcemanager/server"
"github.com/tikv/pd/pkg/mcs/utils"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/apiutil/multiservicesapi"
"github.com/tikv/pd/pkg/utils/logutil"
"github.com/tikv/pd/pkg/utils/reflectutil"
)

Expand Down Expand Up @@ -84,17 +82,10 @@ func NewService(srv *rmserver.Service) *Service {
apiHandlerEngine: apiHandlerEngine,
root: endpoint,
}
s.RegisterAdminRouter()
s.RegisterRouter()
return s
}

// RegisterAdminRouter registers the router of the TSO admin handler.
func (s *Service) RegisterAdminRouter() {
router := s.root.Group("admin")
router.PUT("/log", changeLogLevel)
}

// RegisterRouter registers the router of the service.
func (s *Service) RegisterRouter() {
configEndpoint := s.root.Group("/config")
Expand All @@ -113,22 +104,6 @@ func (s *Service) handler() http.Handler {
})
}

func changeLogLevel(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*rmserver.Service)
var level string
if err := c.Bind(&level); err != nil {
c.String(http.StatusBadRequest, err.Error())
return
}

if err := svr.SetLogLevel(level); err != nil {
c.String(http.StatusBadRequest, err.Error())
return
}
log.SetLevel(logutil.StringToZapLogLevel(level))
c.String(http.StatusOK, "The log level is updated.")
}

// postResourceGroup
//
// @Tags ResourceManager
Expand Down
3 changes: 1 addition & 2 deletions pkg/mcs/resourcemanager/server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ func (dummyRestService) ServeHTTP(w http.ResponseWriter, _ *http.Request) {

// Service is the gRPC service for resource manager.
type Service struct {
ctx context.Context
*Server
ctx context.Context
manager *Manager
// settings
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/mcs/resourcemanager/server/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ func init() {

// Install registers the API group and grpc service.
func Install(register *registry.ServiceRegistry) {
register.RegisterService("ResourceManager", server.NewService[*server.Server])
register.RegisterService("ResourceManager", server.NewService[*server.Manager])
}
Loading

0 comments on commit 9415fdc

Please sign in to comment.