From 565a540b728973fca9a91c3cbd8fb74ad54a85cf Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Wed, 8 Jan 2025 15:14:42 +0800 Subject: [PATCH] fix typo Signed-off-by: Ryan Leung --- .github/workflows/pd-tests.yaml | 4 +- client/http/api.go | 16 +-- client/http/interface.go | 24 ++-- client/http/request_info.go | 4 +- client/http/types.go | 4 +- pkg/errs/errno.go | 2 +- pkg/member/election_leader.go | 2 +- pkg/schedule/placement/rule_manager.go | 2 +- pkg/utils/apiutil/apiutil.go | 8 +- pkg/utils/apiutil/serverapi/middleware.go | 16 +-- pkg/utils/keypath/absolute_key_path.go | 2 +- server/api/config.go | 14 +-- server/apiv2/handlers/micro_service.go | 8 +- server/apiv2/router.go | 2 +- server/cluster/cluster.go | 4 +- server/config/config.go | 18 +-- server/config/persist_options.go | 20 ++-- server/server.go | 28 ++--- tests/integrations/mcs/members/member_test.go | 36 +++--- tests/integrations/mcs/scheduling/api_test.go | 112 +++++++++--------- .../mcs/scheduling/server_test.go | 12 +- tests/integrations/mcs/tso/api_test.go | 8 +- tests/integrations/mcs/tso/server_test.go | 16 +-- tests/integrations/tso/client_test.go | 2 +- tools/pd-ctl/pdctl/command/config_command.go | 24 ++-- tools/pd-ctl/pdctl/command/global.go | 6 +- tools/pd-ctl/tests/config/config_test.go | 12 +- 27 files changed, 203 insertions(+), 203 deletions(-) diff --git a/.github/workflows/pd-tests.yaml b/.github/workflows/pd-tests.yaml index 1464c696db3..2379f67d759 100644 --- a/.github/workflows/pd-tests.yaml +++ b/.github/workflows/pd-tests.yaml @@ -43,9 +43,9 @@ jobs: - worker_id: 8 name: 'TSO Integration Test' - worker_id: 9 - name: 'MicroService Integration(!TSO)' + name: 'Microservice Integration(!TSO)' - worker_id: 10 - name: 'MicroService Integration(TSO)' + name: 'Microservice Integration(TSO)' outputs: job-total: 10 steps: diff --git a/client/http/api.go b/client/http/api.go index 42d965ec17c..028af858904 100644 --- a/client/http/api.go +++ b/client/http/api.go @@ -80,8 +80,8 @@ const ( Version = "/pd/api/v1/version" operators = "/pd/api/v1/operators" safepoint = "/pd/api/v1/gc/safepoint" - // Micro Service - microServicePrefix = "/pd/api/v2/ms" + // Microservice + microservicePrefix = "/pd/api/v2/ms" // Keyspace KeyspaceConfig = "/pd/api/v2/keyspaces/%s/config" GetKeyspaceMetaByName = "/pd/api/v2/keyspaces/%s" @@ -198,14 +198,14 @@ func PProfGoroutineWithDebugLevel(level int) string { return fmt.Sprintf("%s?debug=%d", PProfGoroutine, level) } -// MicroServiceMembers returns the path of PD HTTP API to get the members of microservice. -func MicroServiceMembers(service string) string { - return fmt.Sprintf("%s/members/%s", microServicePrefix, service) +// MicroserviceMembers returns the path of PD HTTP API to get the members of microservice. +func MicroserviceMembers(service string) string { + return fmt.Sprintf("%s/members/%s", microservicePrefix, service) } -// MicroServicePrimary returns the path of PD HTTP API to get the primary of microservice. -func MicroServicePrimary(service string) string { - return fmt.Sprintf("%s/primary/%s", microServicePrefix, service) +// MicroservicePrimary returns the path of PD HTTP API to get the primary of microservice. +func MicroservicePrimary(service string) string { + return fmt.Sprintf("%s/primary/%s", microservicePrefix, service) } // GetUpdateKeyspaceConfigURL returns the path of PD HTTP API to update keyspace config. diff --git a/client/http/interface.go b/client/http/interface.go index 1aabd1ae331..3008824edb8 100644 --- a/client/http/interface.go +++ b/client/http/interface.go @@ -103,9 +103,9 @@ type Client interface { GetPDVersion(context.Context) (string, error) GetGCSafePoint(context.Context) (ListServiceGCSafepoint, error) DeleteGCSafePoint(context.Context, string) (string, error) - /* Micro Service interfaces */ - GetMicroServiceMembers(context.Context, string) ([]MicroServiceMember, error) - GetMicroServicePrimary(context.Context, string) (string, error) + /* Microservice interfaces */ + GetMicroserviceMembers(context.Context, string) ([]MicroserviceMember, error) + GetMicroservicePrimary(context.Context, string) (string, error) DeleteOperators(context.Context) error /* Keyspace interface */ @@ -937,12 +937,12 @@ func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []uin return resp.MinResolvedTS, resp.StoresMinResolvedTS, nil } -// GetMicroServiceMembers gets the members of the microservice. -func (c *client) GetMicroServiceMembers(ctx context.Context, service string) ([]MicroServiceMember, error) { - var members []MicroServiceMember +// GetMicroserviceMembers gets the members of the microservice. +func (c *client) GetMicroserviceMembers(ctx context.Context, service string) ([]MicroserviceMember, error) { + var members []MicroserviceMember err := c.request(ctx, newRequestInfo(). - WithName(getMicroServiceMembersName). - WithURI(MicroServiceMembers(service)). + WithName(getMicroserviceMembersName). + WithURI(MicroserviceMembers(service)). WithMethod(http.MethodGet). WithResp(&members)) if err != nil { @@ -951,12 +951,12 @@ func (c *client) GetMicroServiceMembers(ctx context.Context, service string) ([] return members, nil } -// GetMicroServicePrimary gets the primary of the microservice. -func (c *client) GetMicroServicePrimary(ctx context.Context, service string) (string, error) { +// GetMicroservicePrimary gets the primary of the microservice. +func (c *client) GetMicroservicePrimary(ctx context.Context, service string) (string, error) { var primary string err := c.request(ctx, newRequestInfo(). - WithName(getMicroServicePrimaryName). - WithURI(MicroServicePrimary(service)). + WithName(getMicroservicePrimaryName). + WithURI(MicroservicePrimary(service)). WithMethod(http.MethodGet). WithResp(&primary)) return primary, err diff --git a/client/http/request_info.go b/client/http/request_info.go index d1930800304..2cc95e0215a 100644 --- a/client/http/request_info.go +++ b/client/http/request_info.go @@ -76,8 +76,8 @@ const ( accelerateScheduleName = "AccelerateSchedule" accelerateScheduleInBatchName = "AccelerateScheduleInBatch" getMinResolvedTSByStoresIDsName = "GetMinResolvedTSByStoresIDs" - getMicroServiceMembersName = "GetMicroServiceMembers" - getMicroServicePrimaryName = "GetMicroServicePrimary" + getMicroserviceMembersName = "GetMicroserviceMembers" + getMicroservicePrimaryName = "GetMicroservicePrimary" getPDVersionName = "GetPDVersion" resetTSName = "ResetTS" resetBaseAllocIDName = "ResetBaseAllocID" diff --git a/client/http/types.go b/client/http/types.go index 83e8badf334..75e9db127ff 100644 --- a/client/http/types.go +++ b/client/http/types.go @@ -605,8 +605,8 @@ type MembersInfo struct { EtcdLeader *pdpb.Member `json:"etcd_leader,omitempty"` } -// MicroServiceMember is the member info of a micro service. -type MicroServiceMember struct { +// MicroserviceMember is the member info of a microservice. +type MicroserviceMember struct { ServiceAddr string `json:"service-addr"` Version string `json:"version"` GitHash string `json:"git-hash"` diff --git a/pkg/errs/errno.go b/pkg/errs/errno.go index 834bf4f824e..25f69af327f 100644 --- a/pkg/errs/errno.go +++ b/pkg/errs/errno.go @@ -542,7 +542,7 @@ var ( ErrInvalidGroup = errors.Normalize("invalid group settings, please check the group name, priority and the number of resources", errors.RFCCodeText("PD:resourcemanager:ErrInvalidGroup")) ) -// Micro service errors +// Microservice errors var ( ErrNotFoundSchedulingPrimary = errors.Normalize("cannot find scheduling primary", errors.RFCCodeText("PD:mcs:ErrNotFoundSchedulingPrimary")) ErrSchedulingServer = errors.Normalize("scheduling server meets %v", errors.RFCCodeText("PD:mcs:ErrSchedulingServer")) diff --git a/pkg/member/election_leader.go b/pkg/member/election_leader.go index 2e5769d7dc4..5cdc7b4cd9b 100644 --- a/pkg/member/election_leader.go +++ b/pkg/member/election_leader.go @@ -21,7 +21,7 @@ import ( ) // ElectionLeader defines the common interface of the leader, which is the pdpb.Member -// for in PD/PD service or the tsopb.Participant in the micro services. +// for in PD/PD service or the tsopb.Participant in the microservices. type ElectionLeader interface { // GetListenUrls returns the listen urls GetListenUrls() []string diff --git a/pkg/schedule/placement/rule_manager.go b/pkg/schedule/placement/rule_manager.go index 4470ff28424..7dc24de0f60 100644 --- a/pkg/schedule/placement/rule_manager.go +++ b/pkg/schedule/placement/rule_manager.go @@ -88,7 +88,7 @@ func (m *RuleManager) Initialize(maxReplica int, locationLabels []string, isolat if m.initialized { return nil } - // If RuleManager is initialized in micro service, + // If RuleManager is initialized in microservice, // it will load from etcd watcher and do not modify rule directly. if skipLoadRules { m.ruleList = ruleList{ diff --git a/pkg/utils/apiutil/apiutil.go b/pkg/utils/apiutil/apiutil.go index a743c543468..0b064b6d91a 100644 --- a/pkg/utils/apiutil/apiutil.go +++ b/pkg/utils/apiutil/apiutil.go @@ -64,10 +64,10 @@ const ( XRealIPHeader = "X-Real-Ip" // XCallerIDHeader is used to mark the caller ID. XCallerIDHeader = "X-Caller-ID" - // XForbiddenForwardToMicroServiceHeader is used to indicate that forwarding the request to a microservice is explicitly disallowed. - XForbiddenForwardToMicroServiceHeader = "X-Forbidden-Forward-To-MicroService" - // XForwardedToMicroServiceHeader is used to signal that the request has already been forwarded to a microservice. - XForwardedToMicroServiceHeader = "X-Forwarded-To-MicroService" + // XForbiddenForwardToMicroserviceHeader is used to indicate that forwarding the request to a microservice is explicitly disallowed. + XForbiddenForwardToMicroserviceHeader = "X-Forbidden-Forward-To-Microservice" + // XForwardedToMicroserviceHeader is used to signal that the request has already been forwarded to a microservice. + XForwardedToMicroserviceHeader = "X-Forwarded-To-Microservice" chunkSize = 4096 ) diff --git a/pkg/utils/apiutil/serverapi/middleware.go b/pkg/utils/apiutil/serverapi/middleware.go index 823deed64ea..0b03c787e6b 100644 --- a/pkg/utils/apiutil/serverapi/middleware.go +++ b/pkg/utils/apiutil/serverapi/middleware.go @@ -115,14 +115,14 @@ func MicroserviceRedirectRule(matchPath, targetPath, targetServiceName string, } } -func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, string) { +func (h *redirector) matchMicroserviceRedirectRules(r *http.Request) (bool, string) { if !h.s.IsPDServiceMode() { return false, "" } if len(h.microserviceRedirectRules) == 0 { return false, "" } - if r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) == "true" { + if r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) == "true" { return false, "" } // Remove trailing '/' from the URL path @@ -166,7 +166,7 @@ func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, stri } else { r.URL.Path = rule.targetPath } - log.Debug("redirect to micro service", zap.String("path", r.URL.Path), zap.String("origin-path", origin), + log.Debug("redirect to microservice", zap.String("path", r.URL.Path), zap.String("origin-path", origin), zap.String("target", addr), zap.String("method", r.Method)) return true, addr } @@ -175,7 +175,7 @@ func (h *redirector) matchMicroServiceRedirectRules(r *http.Request) (bool, stri } func (h *redirector) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { - redirectToMicroService, targetAddr := h.matchMicroServiceRedirectRules(r) + redirectToMicroservice, targetAddr := h.matchMicroserviceRedirectRules(r) allowFollowerHandle := len(r.Header.Get(apiutil.PDAllowFollowerHandleHeader)) > 0 if h.s.IsClosed() { @@ -183,7 +183,7 @@ func (h *redirector) ServeHTTP(w http.ResponseWriter, r *http.Request, next http return } - if (allowFollowerHandle || h.s.GetMember().IsLeader()) && !redirectToMicroService { + if (allowFollowerHandle || h.s.GetMember().IsLeader()) && !redirectToMicroservice { next(w, r) return } @@ -200,14 +200,14 @@ func (h *redirector) ServeHTTP(w http.ResponseWriter, r *http.Request, next http } var clientUrls []string - if redirectToMicroService { + if redirectToMicroservice { if len(targetAddr) == 0 { http.Error(w, errs.ErrRedirect.FastGenByArgs().Error(), http.StatusInternalServerError) return } clientUrls = append(clientUrls, targetAddr) - // Add a header to the response, it is used to mark whether the request has been forwarded to the micro service. - w.Header().Add(apiutil.XForwardedToMicroServiceHeader, "true") + // Add a header to the response, it is used to mark whether the request has been forwarded to the microservice. + w.Header().Add(apiutil.XForwardedToMicroserviceHeader, "true") } else if name := r.Header.Get(apiutil.PDRedirectorHeader); len(name) == 0 { leader := h.waitForLeader(r) // The leader has not been elected yet. diff --git a/pkg/utils/keypath/absolute_key_path.go b/pkg/utils/keypath/absolute_key_path.go index 40692dc14bd..c3acbe6ea9c 100644 --- a/pkg/utils/keypath/absolute_key_path.go +++ b/pkg/utils/keypath/absolute_key_path.go @@ -44,7 +44,7 @@ const ( msTsoKespaceExpectedLeaderPathFormat = "/ms/%d/tso/keyspace_groups/election/%05d/primary/expected_primary" // "/ms/{cluster_id}/tso/keyspace_groups/election/{group_id}/primary" ) -// MsParam is the parameter of micro service. +// MsParam is the parameter of microservice. type MsParam struct { ServiceName string GroupID uint32 // only used for tso keyspace group diff --git a/server/api/config.go b/server/api/config.go index a27a1ed5e9b..ff4fe0add82 100644 --- a/server/api/config.go +++ b/server/api/config.go @@ -65,7 +65,7 @@ func newConfHandler(svr *server.Server, rd *render.Render) *confHandler { func (h *confHandler) GetConfig(w http.ResponseWriter, r *http.Request) { cfg := h.svr.GetConfig() if h.svr.IsServiceIndependent(constant.SchedulingServiceName) && - r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) != "true" { + r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) != "true" { schedulingServerConfig, err := h.getSchedulingServerConfig() if err != nil { h.rd.JSON(w, http.StatusInternalServerError, err.Error()) @@ -188,7 +188,7 @@ func (h *confHandler) updateConfig(cfg *config.Config, key string, value any) er case "keyspace": return h.updateKeyspaceConfig(cfg, kp[len(kp)-1], value) case "micro-service": - return h.updateMicroServiceConfig(cfg, kp[len(kp)-1], value) + return h.updateMicroserviceConfig(cfg, kp[len(kp)-1], value) } return errors.Errorf("config prefix %s not found", kp[0]) } @@ -209,8 +209,8 @@ func (h *confHandler) updateKeyspaceConfig(config *config.Config, key string, va return err } -func (h *confHandler) updateMicroServiceConfig(config *config.Config, key string, value any) error { - updated, found, err := jsonutil.AddKeyValue(&config.MicroService, key, value) +func (h *confHandler) updateMicroserviceConfig(config *config.Config, key string, value any) error { + updated, found, err := jsonutil.AddKeyValue(&config.Microservice, key, value) if err != nil { return err } @@ -220,7 +220,7 @@ func (h *confHandler) updateMicroServiceConfig(config *config.Config, key string } if updated { - err = h.svr.SetMicroServiceConfig(config.MicroService) + err = h.svr.SetMicroserviceConfig(config.Microservice) } return err } @@ -339,7 +339,7 @@ func getConfigMap(cfg map[string]any, key []string, value any) map[string]any { // @Router /config/schedule [get] func (h *confHandler) GetScheduleConfig(w http.ResponseWriter, r *http.Request) { if h.svr.IsServiceIndependent(constant.SchedulingServiceName) && - r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) != "true" { + r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) != "true" { cfg, err := h.getSchedulingServerConfig() if err != nil { h.rd.JSON(w, http.StatusInternalServerError, err.Error()) @@ -412,7 +412,7 @@ func (h *confHandler) SetScheduleConfig(w http.ResponseWriter, r *http.Request) // @Router /config/replicate [get] func (h *confHandler) GetReplicationConfig(w http.ResponseWriter, r *http.Request) { if h.svr.IsServiceIndependent(constant.SchedulingServiceName) && - r.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) != "true" { + r.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) != "true" { cfg, err := h.getSchedulingServerConfig() if err != nil { h.rd.JSON(w, http.StatusInternalServerError, err.Error()) diff --git a/server/apiv2/handlers/micro_service.go b/server/apiv2/handlers/micro_service.go index b4d3d6bbe89..3a0d6a2c2a6 100644 --- a/server/apiv2/handlers/micro_service.go +++ b/server/apiv2/handlers/micro_service.go @@ -24,8 +24,8 @@ import ( "github.com/tikv/pd/server/apiv2/middlewares" ) -// RegisterMicroService registers microservice handler to the router. -func RegisterMicroService(r *gin.RouterGroup) { +// RegisterMicroservice registers microservice handler to the router. +func RegisterMicroservice(r *gin.RouterGroup) { router := r.Group("ms") router.GET("members/:service", GetMembers) router.GET("primary/:service", GetPrimary) @@ -40,7 +40,7 @@ func RegisterMicroService(r *gin.RouterGroup) { func GetMembers(c *gin.Context) { svr := c.MustGet(middlewares.ServerContextKey).(*server.Server) if !svr.IsPDServiceMode() { - c.AbortWithStatusJSON(http.StatusNotFound, "not support micro service") + c.AbortWithStatusJSON(http.StatusNotFound, "not support microservice") return } @@ -66,7 +66,7 @@ func GetMembers(c *gin.Context) { func GetPrimary(c *gin.Context) { svr := c.MustGet(middlewares.ServerContextKey).(*server.Server) if !svr.IsPDServiceMode() { - c.AbortWithStatusJSON(http.StatusNotFound, "not support micro service") + c.AbortWithStatusJSON(http.StatusNotFound, "not support microservice") return } diff --git a/server/apiv2/router.go b/server/apiv2/router.go index 7f927dd9705..8df34e0a742 100644 --- a/server/apiv2/router.go +++ b/server/apiv2/router.go @@ -56,6 +56,6 @@ func NewV2Handler(_ context.Context, svr *server.Server) (http.Handler, apiutil. root.GET("ready", handlers.Ready) handlers.RegisterKeyspace(root) handlers.RegisterTSOKeyspaceGroup(root) - handlers.RegisterMicroService(root) + handlers.RegisterMicroservice(root) return router, group, nil } diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index e482b7b8b68..4ad97dfd0cc 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -406,7 +406,7 @@ func (c *RaftCluster) Start(s Server, bootstrap bool) (err error) { func (c *RaftCluster) checkSchedulingService() { if c.isPDServiceMode { servers, err := discovery.Discover(c.etcdClient, constant.SchedulingServiceName) - if c.opt.GetMicroServiceConfig().IsSchedulingFallbackEnabled() && (err != nil || len(servers) == 0) { + if c.opt.GetMicroserviceConfig().IsSchedulingFallbackEnabled() && (err != nil || len(servers) == 0) { c.startSchedulingJobs(c, c.hbstreams) c.UnsetServiceIndependent(constant.SchedulingServiceName) } else { @@ -426,7 +426,7 @@ func (c *RaftCluster) checkSchedulingService() { // checkTSOService checks the TSO service. func (c *RaftCluster) checkTSOService() { if c.isPDServiceMode { - if c.opt.GetMicroServiceConfig().IsTSODynamicSwitchingEnabled() { + if c.opt.GetMicroserviceConfig().IsTSODynamicSwitchingEnabled() { servers, err := discovery.Discover(c.etcdClient, constant.TSOServiceName) if err != nil || len(servers) == 0 { if err := c.startTSOJobsIfNeeded(); err != nil { diff --git a/server/config/config.go b/server/config/config.go index 69cd76409bc..3d0d16bc376 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -162,7 +162,7 @@ type Config struct { Keyspace KeyspaceConfig `toml:"keyspace" json:"keyspace"` - MicroService MicroServiceConfig `toml:"micro-service" json:"micro-service"` + Microservice MicroserviceConfig `toml:"micro-service" json:"micro-service"` Controller rm.ControllerConfig `toml:"controller" json:"controller"` } @@ -457,7 +457,7 @@ func (c *Config) Adjust(meta *toml.MetaData, reloading bool) error { c.Keyspace.adjust(configMetaData.Child("keyspace")) - c.MicroService.adjust(configMetaData.Child("micro-service")) + c.Microservice.adjust(configMetaData.Child("micro-service")) if err := c.Security.Encryption.Adjust(); err != nil { return err @@ -839,13 +839,13 @@ func (c *DRAutoSyncReplicationConfig) adjust(meta *configutil.ConfigMetaData) { } } -// MicroServiceConfig is the configuration for micro service. -type MicroServiceConfig struct { +// MicroserviceConfig is the configuration for microservice. +type MicroserviceConfig struct { EnableSchedulingFallback bool `toml:"enable-scheduling-fallback" json:"enable-scheduling-fallback,string"` EnableTSODynamicSwitching bool `toml:"enable-tso-dynamic-switching" json:"enable-tso-dynamic-switching,string"` } -func (c *MicroServiceConfig) adjust(meta *configutil.ConfigMetaData) { +func (c *MicroserviceConfig) adjust(meta *configutil.ConfigMetaData) { if !meta.IsDefined("enable-scheduling-fallback") { c.EnableSchedulingFallback = defaultEnableSchedulingFallback } @@ -854,19 +854,19 @@ func (c *MicroServiceConfig) adjust(meta *configutil.ConfigMetaData) { } } -// Clone returns a copy of micro service config. -func (c *MicroServiceConfig) Clone() *MicroServiceConfig { +// Clone returns a copy of microservice config. +func (c *MicroserviceConfig) Clone() *MicroserviceConfig { cfg := *c return &cfg } // IsSchedulingFallbackEnabled returns whether to enable scheduling service fallback to PD service. -func (c *MicroServiceConfig) IsSchedulingFallbackEnabled() bool { +func (c *MicroserviceConfig) IsSchedulingFallbackEnabled() bool { return c.EnableSchedulingFallback } // IsTSODynamicSwitchingEnabled returns whether to enable TSO dynamic switching. -func (c *MicroServiceConfig) IsTSODynamicSwitchingEnabled() bool { +func (c *MicroserviceConfig) IsTSODynamicSwitchingEnabled() bool { return c.EnableTSODynamicSwitching } diff --git a/server/config/persist_options.go b/server/config/persist_options.go index 59d42383743..5ce24ac3f56 100644 --- a/server/config/persist_options.go +++ b/server/config/persist_options.go @@ -55,7 +55,7 @@ type PersistOptions struct { replicationMode atomic.Value labelProperty atomic.Value keyspace atomic.Value - microService atomic.Value + microservice atomic.Value storeConfig atomic.Value clusterVersion unsafe.Pointer } @@ -69,7 +69,7 @@ func NewPersistOptions(cfg *Config) *PersistOptions { o.replicationMode.Store(&cfg.ReplicationMode) o.labelProperty.Store(cfg.LabelProperty) o.keyspace.Store(&cfg.Keyspace) - o.microService.Store(&cfg.MicroService) + o.microservice.Store(&cfg.Microservice) // storeConfig will be fetched from TiKV later, // set it to an empty config here first. o.storeConfig.Store(&sc.StoreConfig{}) @@ -138,14 +138,14 @@ func (o *PersistOptions) SetKeyspaceConfig(cfg *KeyspaceConfig) { o.keyspace.Store(cfg) } -// GetMicroServiceConfig returns the micro service configuration. -func (o *PersistOptions) GetMicroServiceConfig() *MicroServiceConfig { - return o.microService.Load().(*MicroServiceConfig) +// GetMicroserviceConfig returns the microservice configuration. +func (o *PersistOptions) GetMicroserviceConfig() *MicroserviceConfig { + return o.microservice.Load().(*MicroserviceConfig) } -// SetMicroServiceConfig sets the micro service configuration. -func (o *PersistOptions) SetMicroServiceConfig(cfg *MicroServiceConfig) { - o.microService.Store(cfg) +// SetMicroserviceConfig sets the microservice configuration. +func (o *PersistOptions) SetMicroserviceConfig(cfg *MicroserviceConfig) { + o.microservice.Store(cfg) } // GetStoreConfig returns the store config. @@ -791,7 +791,7 @@ func (o *PersistOptions) Persist(storage endpoint.ConfigStorage) error { ReplicationMode: *o.GetReplicationModeConfig(), LabelProperty: o.GetLabelPropertyConfig(), Keyspace: *o.GetKeyspaceConfig(), - MicroService: *o.GetMicroServiceConfig(), + Microservice: *o.GetMicroserviceConfig(), ClusterVersion: *o.GetClusterVersion(), }, StoreConfig: *o.GetStoreConfig(), @@ -825,7 +825,7 @@ func (o *PersistOptions) Reload(storage endpoint.ConfigStorage) error { o.replicationMode.Store(&cfg.ReplicationMode) o.labelProperty.Store(cfg.LabelProperty) o.keyspace.Store(&cfg.Keyspace) - o.microService.Store(&cfg.MicroService) + o.microservice.Store(&cfg.Microservice) o.storeConfig.Store(&cfg.StoreConfig) o.SetClusterVersion(&cfg.ClusterVersion) } diff --git a/server/server.go b/server/server.go index 8de2a5c57f3..7ecf309b1d9 100644 --- a/server/server.go +++ b/server/server.go @@ -300,7 +300,7 @@ func CreateServer(ctx context.Context, cfg *config.Config, services []string, le }) s.registry.RegisterService("MetaStorage", ms_server.NewService) s.registry.RegisterService("ResourceManager", rm_server.NewService[*Server]) - // Register the micro services REST path. + // Register the microservices REST path. s.registry.InstallAllRESTHandler(s, etcdCfg.UserHandlers) etcdCfg.ServiceRegister = func(gs *grpc.Server) { @@ -308,7 +308,7 @@ func CreateServer(ctx context.Context, cfg *config.Config, services []string, le pdpb.RegisterPDServer(gs, grpcServer) keyspacepb.RegisterKeyspaceServer(gs, &KeyspaceServer{GrpcServer: grpcServer}) diagnosticspb.RegisterDiagnosticsServer(gs, s) - // Register the micro services GRPC service. + // Register the microservices GRPC service. s.registry.InstallAllGRPCServices(s, gs) s.grpcServer = gs } @@ -948,7 +948,7 @@ func (s *Server) GetConfig() *config.Config { cfg.PDServerCfg = *s.persistOptions.GetPDServerConfig().Clone() cfg.ReplicationMode = *s.persistOptions.GetReplicationModeConfig() cfg.Keyspace = *s.persistOptions.GetKeyspaceConfig().Clone() - cfg.MicroService = *s.persistOptions.GetMicroServiceConfig().Clone() + cfg.Microservice = *s.persistOptions.GetMicroserviceConfig().Clone() cfg.LabelProperty = s.persistOptions.GetLabelPropertyConfig().Clone() cfg.ClusterVersion = *s.persistOptions.GetClusterVersion() return cfg @@ -979,24 +979,24 @@ func (s *Server) SetKeyspaceConfig(cfg config.KeyspaceConfig) error { return nil } -// GetMicroServiceConfig gets the micro service config information. -func (s *Server) GetMicroServiceConfig() *config.MicroServiceConfig { - return s.persistOptions.GetMicroServiceConfig().Clone() +// GetMicroserviceConfig gets the microservice config information. +func (s *Server) GetMicroserviceConfig() *config.MicroserviceConfig { + return s.persistOptions.GetMicroserviceConfig().Clone() } -// SetMicroServiceConfig sets the micro service config information. -func (s *Server) SetMicroServiceConfig(cfg config.MicroServiceConfig) error { - old := s.persistOptions.GetMicroServiceConfig() - s.persistOptions.SetMicroServiceConfig(&cfg) +// SetMicroserviceConfig sets the microservice config information. +func (s *Server) SetMicroserviceConfig(cfg config.MicroserviceConfig) error { + old := s.persistOptions.GetMicroserviceConfig() + s.persistOptions.SetMicroserviceConfig(&cfg) if err := s.persistOptions.Persist(s.storage); err != nil { - s.persistOptions.SetMicroServiceConfig(old) - log.Error("failed to update micro service config", + s.persistOptions.SetMicroserviceConfig(old) + log.Error("failed to update microservice config", zap.Reflect("new", cfg), zap.Reflect("old", old), errs.ZapError(err)) return err } - log.Info("micro service config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) + log.Info("microservice config is updated", zap.Reflect("new", cfg), zap.Reflect("old", old)) return nil } @@ -1391,7 +1391,7 @@ func (s *Server) GetRaftCluster() *cluster.RaftCluster { // IsServiceIndependent returns whether the service is independent. func (s *Server) IsServiceIndependent(name string) bool { if s.mode == PDServiceMode && !s.IsClosed() { - if name == constant.TSOServiceName && !s.GetMicroServiceConfig().IsTSODynamicSwitchingEnabled() { + if name == constant.TSOServiceName && !s.GetMicroserviceConfig().IsTSODynamicSwitchingEnabled() { return true } return s.cluster.IsServiceIndependent(name) diff --git a/tests/integrations/mcs/members/member_test.go b/tests/integrations/mcs/members/member_test.go index 7e83ea570b9..0ec0b323d7a 100644 --- a/tests/integrations/mcs/members/member_test.go +++ b/tests/integrations/mcs/members/member_test.go @@ -126,29 +126,29 @@ func (suite *memberTestSuite) TearDownTest() { func (suite *memberTestSuite) TestMembers() { re := suite.Require() - members, err := suite.pdClient.GetMicroServiceMembers(suite.ctx, "tso") + members, err := suite.pdClient.GetMicroserviceMembers(suite.ctx, "tso") re.NoError(err) re.Len(members, 3) - members, err = suite.pdClient.GetMicroServiceMembers(suite.ctx, "scheduling") + members, err = suite.pdClient.GetMicroserviceMembers(suite.ctx, "scheduling") re.NoError(err) re.Len(members, 3) } func (suite *memberTestSuite) TestPrimary() { re := suite.Require() - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, "tso") + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, "tso") re.NoError(err) re.NotEmpty(primary) - primary, err = suite.pdClient.GetMicroServicePrimary(suite.ctx, "scheduling") + primary, err = suite.pdClient.GetMicroservicePrimary(suite.ctx, "scheduling") re.NoError(err) re.NotEmpty(primary) } func (suite *memberTestSuite) TestPrimaryWorkWhileOtherServerClose() { re := suite.Require() - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, "tso") + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, "tso") re.NoError(err) re.NotEmpty(primary) @@ -162,7 +162,7 @@ func (suite *memberTestSuite) TestPrimaryWorkWhileOtherServerClose() { nodes = suite.schedulingNodes } - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) // Close non-primary node. @@ -174,7 +174,7 @@ func (suite *memberTestSuite) TestPrimaryWorkWhileOtherServerClose() { tests.WaitForPrimaryServing(re, nodes) // primary should be same with before. - curPrimary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + curPrimary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) re.Equal(primary, curPrimary) } @@ -193,7 +193,7 @@ func (suite *memberTestSuite) TestTransferPrimary() { } // Test resign primary by random - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) newPrimaryData := make(map[string]any) @@ -214,7 +214,7 @@ func (suite *memberTestSuite) TestTransferPrimary() { return false }, testutil.WithWaitFor(5*time.Second), testutil.WithTickInterval(50*time.Millisecond)) - primary, err = suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + primary, err = suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) // Test transfer primary to a specific node @@ -240,7 +240,7 @@ func (suite *memberTestSuite) TestTransferPrimary() { return nodes[newPrimary].IsServing() }, testutil.WithWaitFor(5*time.Second), testutil.WithTickInterval(50*time.Millisecond)) - primary, err = suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + primary, err = suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) re.Equal(primary, newPrimary) @@ -268,7 +268,7 @@ func (suite *memberTestSuite) TestCampaignPrimaryAfterTransfer() { nodes = suite.schedulingNodes } - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) // Test transfer primary to a specific node @@ -292,7 +292,7 @@ func (suite *memberTestSuite) TestCampaignPrimaryAfterTransfer() { resp.Body.Close() tests.WaitForPrimaryServing(re, nodes) - newPrimary, err = suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + newPrimary, err = suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) re.NotEqual(primary, newPrimary) @@ -300,7 +300,7 @@ func (suite *memberTestSuite) TestCampaignPrimaryAfterTransfer() { nodes[newPrimary].Close() tests.WaitForPrimaryServing(re, nodes) // Primary should be different with before - anotherPrimary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + anotherPrimary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) re.NotEqual(newPrimary, anotherPrimary) } @@ -308,7 +308,7 @@ func (suite *memberTestSuite) TestCampaignPrimaryAfterTransfer() { func (suite *memberTestSuite) TestTransferPrimaryWhileLeaseExpired() { re := suite.Require() - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, "tso") + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, "tso") re.NoError(err) re.NotEmpty(primary) @@ -322,7 +322,7 @@ func (suite *memberTestSuite) TestTransferPrimaryWhileLeaseExpired() { nodes = suite.schedulingNodes } - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) // Test transfer primary to a specific node @@ -363,7 +363,7 @@ func (suite *memberTestSuite) TestTransferPrimaryWhileLeaseExpired() { // TestTransferPrimaryWhileLeaseExpiredAndServerDown tests transfer primary while lease expired and server down func (suite *memberTestSuite) TestTransferPrimaryWhileLeaseExpiredAndServerDown() { re := suite.Require() - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, "tso") + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, "tso") re.NoError(err) re.NotEmpty(primary) @@ -377,7 +377,7 @@ func (suite *memberTestSuite) TestTransferPrimaryWhileLeaseExpiredAndServerDown( nodes = suite.schedulingNodes } - primary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + primary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) // Test transfer primary to a specific node @@ -415,7 +415,7 @@ func (suite *memberTestSuite) TestTransferPrimaryWhileLeaseExpiredAndServerDown( tests.WaitForPrimaryServing(re, nodes) // Primary should be different with before - onlyPrimary, err := suite.pdClient.GetMicroServicePrimary(suite.ctx, service) + onlyPrimary, err := suite.pdClient.GetMicroservicePrimary(suite.ctx, service) re.NoError(err) re.NotEqual(newPrimary, onlyPrimary) } diff --git a/tests/integrations/mcs/scheduling/api_test.go b/tests/integrations/mcs/scheduling/api_test.go index 9b6b3d95145..e52ced10011 100644 --- a/tests/integrations/mcs/scheduling/api_test.go +++ b/tests/integrations/mcs/scheduling/api_test.go @@ -118,29 +118,29 @@ func (suite *apiTestSuite) checkAPIForward(cluster *tests.TestCluster) { // Test operators err := testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "operators"), &respSlice, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) re.Empty(respSlice) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "operators"), []byte(``), - testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "operators/2"), nil, - testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckDelete(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "operators/2"), - testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "operators/records"), nil, - testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) // Test checker err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "checker/merge"), &resp, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) re.False(resp["paused"].(bool)) @@ -151,7 +151,7 @@ func (suite *apiTestSuite) checkAPIForward(cluster *tests.TestCluster) { pauseArgs, err := json.Marshal(input) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "checker/merge"), pauseArgs, - testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) } postChecker(30) @@ -170,7 +170,7 @@ func (suite *apiTestSuite) checkAPIForward(cluster *tests.TestCluster) { // "/schedulers/{name}", http.MethodDelete testutil.Eventually(re, func() bool { err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "schedulers"), &respSlice, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) return slice.Contains(respSlice, "balance-leader-scheduler") }) @@ -181,18 +181,18 @@ func (suite *apiTestSuite) checkAPIForward(cluster *tests.TestCluster) { pauseArgs, err := json.Marshal(input) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "schedulers/balance-leader-scheduler"), pauseArgs, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) } postScheduler(30) postScheduler(0) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "schedulers/diagnostic/balance-leader-scheduler"), &resp, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "scheduler-config"), &resp, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) re.Contains(resp, "balance-leader-scheduler") re.Contains(resp, "balance-hot-region-scheduler") @@ -203,16 +203,16 @@ func (suite *apiTestSuite) checkAPIForward(cluster *tests.TestCluster) { } for _, schedulerName := range schedulers { err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s/%s/%s", urlPrefix, "scheduler-config", schedulerName, "list"), &resp, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) } err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "schedulers"), nil, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckDelete(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "schedulers/balance-leader-scheduler"), - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) input := make(map[string]any) @@ -220,74 +220,74 @@ func (suite *apiTestSuite) checkAPIForward(cluster *tests.TestCluster) { b, err := json.Marshal(input) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "schedulers"), b, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) // Test hotspot var hotRegions statistics.StoreHotPeersInfos err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "hotspot/regions/write"), &hotRegions, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "hotspot/regions/read"), &hotRegions, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) var stores handler.HotStoreStats err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "hotspot/stores"), &stores, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) var buckets handler.HotBucketsResponse err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "hotspot/buckets"), &buckets, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) var history storage.HistoryHotRegions err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "hotspot/regions/history"), &history, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) // Test region label var labelRules []*labeler.LabelRule err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/region-label/rules"), &labelRules, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.ReadGetJSONWithBody(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/region-label/rules/ids"), []byte(`["rule1", "rule3"]`), - &labelRules, testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + &labelRules, testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/region-label/rule/rule1"), nil, - testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusNotOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "region/id/1"), nil, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "region/id/1/label/key"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "region/id/1/labels"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) // Test Region body := fmt.Sprintf(`{"start_key":"%s", "end_key": "%s"}`, hex.EncodeToString([]byte("a1")), hex.EncodeToString([]byte("a3"))) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "regions/accelerate-schedule"), []byte(body), - testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) body = fmt.Sprintf(`[{"start_key":"%s", "end_key": "%s"}, {"start_key":"%s", "end_key": "%s"}]`, hex.EncodeToString([]byte("a1")), hex.EncodeToString([]byte("a3")), hex.EncodeToString([]byte("a4")), hex.EncodeToString([]byte("a6"))) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "regions/accelerate-schedule/batch"), []byte(body), - testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) body = fmt.Sprintf(`{"start_key":"%s", "end_key": "%s"}`, hex.EncodeToString([]byte("b1")), hex.EncodeToString([]byte("b3"))) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "regions/scatter"), []byte(body), - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) body = fmt.Sprintf(`{"retry_limit":%v, "split_keys": ["%s","%s","%s"]}`, 3, hex.EncodeToString([]byte("bbb")), hex.EncodeToString([]byte("ccc")), hex.EncodeToString([]byte("ddd"))) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "regions/split"), []byte(body), - testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf(`%s/regions/replicated?startKey=%s&endKey=%s`, urlPrefix, hex.EncodeToString([]byte("a1")), hex.EncodeToString([]byte("a2"))), nil, - testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusOK(re), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) // Test rules: only forward `GET` request var rules []*placement.Rule @@ -305,76 +305,76 @@ func (suite *apiTestSuite) checkAPIForward(cluster *tests.TestCluster) { re.NoError(err) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules"), &rules, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules"), rulesArgs, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules/batch"), rulesArgs, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules/group/pd"), &rules, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules/region/2"), &rules, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) var fit placement.RegionFit err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules/region/2/detail"), &fit, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules/key/0000000000000001"), &rules, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rule/pd/2"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckDelete(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rule/pd/2"), - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rule"), rulesArgs, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rule_group/pd"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckDelete(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rule_group/pd"), - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rule_group"), rulesArgs, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rule_groups"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/placement-rule"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/placement-rule"), rulesArgs, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/placement-rule/pd"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) err = testutil.CheckDelete(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/placement-rule/pd"), - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/placement-rule/pd"), rulesArgs, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) // test redirect is disabled err = testutil.CheckGetJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/placement-rule/pd"), nil, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/%s", urlPrefix, "config/placement-rule/pd"), http.NoBody) re.NoError(err) - req.Header.Set(apiutil.XForbiddenForwardToMicroServiceHeader, "true") + req.Header.Set(apiutil.XForbiddenForwardToMicroserviceHeader, "true") httpResp, err := tests.TestDialClient.Do(req) re.NoError(err) re.Equal(http.StatusOK, httpResp.StatusCode) defer httpResp.Body.Close() - re.Empty(httpResp.Header.Get(apiutil.XForwardedToMicroServiceHeader)) + re.Empty(httpResp.Header.Get(apiutil.XForwardedToMicroserviceHeader)) } func (suite *apiTestSuite) TestConfig() { @@ -536,14 +536,14 @@ func (suite *apiTestSuite) checkFollowerForward(cluster *tests.TestCluster) { // follower will forward to scheduling server directly re.NotEqual(cluster.GetLeaderServer().GetAddr(), followerAddr) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules"), &rules, - testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true"), + testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true"), ) re.NoError(err) } else { // follower will forward to leader server re.NotEqual(cluster.GetLeaderServer().GetAddr(), followerAddr) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config/rules"), &rules, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader), + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader), ) re.NoError(err) } @@ -552,7 +552,7 @@ func (suite *apiTestSuite) checkFollowerForward(cluster *tests.TestCluster) { re.NotEqual(cluster.GetLeaderServer().GetAddr(), followerAddr) results := make(map[string]any) err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "config"), &results, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader), + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader), ) re.NoError(err) } diff --git a/tests/integrations/mcs/scheduling/server_test.go b/tests/integrations/mcs/scheduling/server_test.go index 9a3d33d1dcf..7271111bd79 100644 --- a/tests/integrations/mcs/scheduling/server_test.go +++ b/tests/integrations/mcs/scheduling/server_test.go @@ -216,10 +216,10 @@ func (suite *serverTestSuite) TestForwardStoreHeartbeat() { func (suite *serverTestSuite) TestSchedulingServiceFallback() { re := suite.Require() leaderServer := suite.pdLeader.GetServer() - conf := leaderServer.GetMicroServiceConfig().Clone() + conf := leaderServer.GetMicroserviceConfig().Clone() // Change back to the default value. conf.EnableSchedulingFallback = true - leaderServer.SetMicroServiceConfig(*conf) + leaderServer.SetMicroserviceConfig(*conf) // PD service will execute scheduling jobs since there is no scheduling server. testutil.Eventually(re, func() bool { return suite.pdLeader.GetServer().GetRaftCluster().IsSchedulingControllerRunning() @@ -267,15 +267,15 @@ func (suite *serverTestSuite) TestDisableSchedulingServiceFallback() { }) leaderServer := suite.pdLeader.GetServer() // After Disabling scheduling service fallback, the PD service will stop scheduling. - conf := leaderServer.GetMicroServiceConfig().Clone() + conf := leaderServer.GetMicroserviceConfig().Clone() conf.EnableSchedulingFallback = false - leaderServer.SetMicroServiceConfig(*conf) + leaderServer.SetMicroserviceConfig(*conf) testutil.Eventually(re, func() bool { return !suite.pdLeader.GetServer().GetRaftCluster().IsSchedulingControllerRunning() }) // Enable scheduling service fallback again, the PD service will restart scheduling. conf.EnableSchedulingFallback = true - leaderServer.SetMicroServiceConfig(*conf) + leaderServer.SetMicroserviceConfig(*conf) testutil.Eventually(re, func() bool { return suite.pdLeader.GetServer().GetRaftCluster().IsSchedulingControllerRunning() }) @@ -294,7 +294,7 @@ func (suite *serverTestSuite) TestDisableSchedulingServiceFallback() { }) // Disable scheduling service fallback and stop scheduling server. PD service won't execute scheduling jobs again. conf.EnableSchedulingFallback = false - leaderServer.SetMicroServiceConfig(*conf) + leaderServer.SetMicroserviceConfig(*conf) tc.GetPrimaryServer().Close() time.Sleep(time.Second) testutil.Eventually(re, func() bool { diff --git a/tests/integrations/mcs/tso/api_test.go b/tests/integrations/mcs/tso/api_test.go index dceb5ccdf7c..97f56cbcee1 100644 --- a/tests/integrations/mcs/tso/api_test.go +++ b/tests/integrations/mcs/tso/api_test.go @@ -107,13 +107,13 @@ func (suite *tsoAPITestSuite) TestForwardResetTS() { // Test reset ts input := []byte(`{"tso":"121312", "force-use-larger":true}`) err := testutil.CheckPostJSON(tests.TestDialClient, url, input, - testutil.StatusOK(re), testutil.StringContain(re, "Reset ts successfully"), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusOK(re), testutil.StringContain(re, "Reset ts successfully"), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) // Test reset ts with invalid tso input = []byte(`{}`) err = testutil.CheckPostJSON(tests.TestDialClient, url, input, - testutil.StatusNotOK(re), testutil.StringContain(re, "invalid tso value"), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusNotOK(re), testutil.StringContain(re, "invalid tso value"), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) } @@ -217,14 +217,14 @@ func TestForwardOnlyTSONoScheduling(t *testing.T) { // Test /operators, it should not forward when there is no scheduling server. var slice []string err = testutil.ReadGetJSON(re, tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "operators"), &slice, - testutil.WithoutHeader(re, apiutil.XForwardedToMicroServiceHeader)) + testutil.WithoutHeader(re, apiutil.XForwardedToMicroserviceHeader)) re.NoError(err) re.Empty(slice) // Test admin/reset-ts, it should forward to tso server. input := []byte(`{"tso":"121312", "force-use-larger":true}`) err = testutil.CheckPostJSON(tests.TestDialClient, fmt.Sprintf("%s/%s", urlPrefix, "admin/reset-ts"), input, - testutil.StatusOK(re), testutil.StringContain(re, "Reset ts successfully"), testutil.WithHeader(re, apiutil.XForwardedToMicroServiceHeader, "true")) + testutil.StatusOK(re), testutil.StringContain(re, "Reset ts successfully"), testutil.WithHeader(re, apiutil.XForwardedToMicroserviceHeader, "true")) re.NoError(err) // If close tso server, it should try forward to tso server, but return error in pd service mode. diff --git a/tests/integrations/mcs/tso/server_test.go b/tests/integrations/mcs/tso/server_test.go index 7416a314949..4c9bb4248e5 100644 --- a/tests/integrations/mcs/tso/server_test.go +++ b/tests/integrations/mcs/tso/server_test.go @@ -169,7 +169,7 @@ func checkTSOPath(re *require.Assertions, isPDServiceMode bool) { defer cancel() if isPDServiceMode { cluster, err = tests.NewTestPDServiceCluster(ctx, 1, func(conf *config.Config, _ string) { - conf.MicroService.EnableTSODynamicSwitching = false + conf.Microservice.EnableTSODynamicSwitching = false }) } else { cluster, err = tests.NewTestCluster(ctx, 1) @@ -276,9 +276,9 @@ func TestForwardTSORelated(t *testing.T) { suite := NewPDServiceForward(re) defer suite.ShutDown() leaderServer := suite.cluster.GetLeaderServer().GetServer() - cfg := leaderServer.GetMicroServiceConfig().Clone() + cfg := leaderServer.GetMicroserviceConfig().Clone() cfg.EnableTSODynamicSwitching = false - leaderServer.SetMicroServiceConfig(*cfg) + leaderServer.SetMicroserviceConfig(*cfg) // Unable to use the tso-related interface without tso server suite.checkUnavailableTSO(re) tc, err := tests.NewTestTSOCluster(suite.ctx, 1, suite.backendEndpoints) @@ -600,7 +600,7 @@ func TestTSOServiceSwitch(t *testing.T) { tc, err := tests.NewTestPDServiceCluster(ctx, 1, func(conf *config.Config, _ string) { - conf.MicroService.EnableTSODynamicSwitching = true + conf.Microservice.EnableTSODynamicSwitching = true }, ) re.NoError(err) @@ -638,9 +638,9 @@ func TestTSOServiceSwitch(t *testing.T) { re.NoError(err) // Disable TSO switching - cfg := pdLeader.GetServer().GetMicroServiceConfig().Clone() + cfg := pdLeader.GetServer().GetMicroserviceConfig().Clone() cfg.EnableTSODynamicSwitching = false - pdLeader.GetServer().SetMicroServiceConfig(*cfg) + pdLeader.GetServer().SetMicroserviceConfig(*cfg) tsoCluster.Destroy() @@ -654,10 +654,10 @@ func TestTSOServiceSwitch(t *testing.T) { } // Now enable TSO switching - cfg = pdLeader.GetServer().GetMicroServiceConfig().Clone() + cfg = pdLeader.GetServer().GetMicroserviceConfig().Clone() cfg.EnableTSODynamicSwitching = true - pdLeader.GetServer().SetMicroServiceConfig(*cfg) + pdLeader.GetServer().SetMicroserviceConfig(*cfg) // Wait for PD to detect the change time.Sleep(300 * time.Millisecond) diff --git a/tests/integrations/tso/client_test.go b/tests/integrations/tso/client_test.go index a06e44ed4ab..87ddd9e226b 100644 --- a/tests/integrations/tso/client_test.go +++ b/tests/integrations/tso/client_test.go @@ -99,7 +99,7 @@ func (suite *tsoClientTestSuite) SetupSuite() { suite.cluster, err = tests.NewTestCluster(suite.ctx, serverCount) } else { suite.cluster, err = tests.NewTestPDServiceCluster(suite.ctx, serverCount, func(conf *config.Config, _ string) { - conf.MicroService.EnableTSODynamicSwitching = false + conf.Microservice.EnableTSODynamicSwitching = false }) } re.NoError(err) diff --git a/tools/pd-ctl/pdctl/command/config_command.go b/tools/pd-ctl/pdctl/command/config_command.go index f89c63bc51c..c49b0e3b9e5 100644 --- a/tools/pd-ctl/pdctl/command/config_command.go +++ b/tools/pd-ctl/pdctl/command/config_command.go @@ -81,7 +81,7 @@ func NewShowConfigCommand() *cobra.Command { sc.AddCommand(newShowReplicationModeCommand()) sc.AddCommand(NewShowServerConfigCommand()) sc.AddCommand(NewShowServiceMiddlewareConfigCommand()) - sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") return sc } @@ -92,7 +92,7 @@ func NewShowAllConfigCommand() *cobra.Command { Short: "show all config of PD", Run: showAllConfigCommandFunc, } - sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") return sc } @@ -103,7 +103,7 @@ func NewShowScheduleConfigCommand() *cobra.Command { Short: "show schedule config of PD", Run: showScheduleConfigCommandFunc, } - sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") return sc } @@ -114,7 +114,7 @@ func NewShowReplicationConfigCommand() *cobra.Command { Short: "show replication config of PD", Run: showReplicationConfigCommandFunc, } - sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + sc.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") return sc } @@ -528,7 +528,7 @@ func NewPlacementRulesCommand() *cobra.Command { show.Flags().String("id", "", "rule id") show.Flags().String("region", "", "region id") show.Flags().Bool("detail", false, "detailed match info for region") - show.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + show.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") load := &cobra.Command{ Use: "load", Short: "load placement rules to a file", @@ -538,7 +538,7 @@ func NewPlacementRulesCommand() *cobra.Command { load.Flags().String("id", "", "rule id") load.Flags().String("region", "", "region id") load.Flags().String("out", "rules.json", "the filename contains rules") - load.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + load.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") save := &cobra.Command{ Use: "save", Short: "save rules from file", @@ -554,7 +554,7 @@ func NewPlacementRulesCommand() *cobra.Command { Short: "show rule group configuration(s)", Run: showRuleGroupFunc, } - ruleGroupShow.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + ruleGroupShow.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") ruleGroupSet := &cobra.Command{ Use: "set ", Short: "update rule group configuration", @@ -577,7 +577,7 @@ func NewPlacementRulesCommand() *cobra.Command { Run: getRuleBundle, } ruleBundleGet.Flags().String("out", "", "the output file") - ruleBundleGet.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + ruleBundleGet.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") ruleBundleSet := &cobra.Command{ Use: "set", Short: "set rule group config and its rules from file", @@ -596,7 +596,7 @@ func NewPlacementRulesCommand() *cobra.Command { Run: loadRuleBundle, } ruleBundleLoad.Flags().String("out", "rules.json", "the output file") - ruleBundleLoad.Flags().Bool(flagFromPDService, false, "read data from PD service rather than micro service") + ruleBundleLoad.Flags().Bool(flagFromPDService, false, "read data from PD service rather than microservice") ruleBundleSave := &cobra.Command{ Use: "save", Short: "save all group configs and rules from file", @@ -895,9 +895,9 @@ func saveRuleBundle(cmd *cobra.Command, _ []string) { func buildHeader(cmd *cobra.Command) http.Header { header := http.Header{} - forbiddenRedirectToMicroService, err := cmd.Flags().GetBool(flagFromPDService) - if err == nil && forbiddenRedirectToMicroService { - header.Add(apiutil.XForbiddenForwardToMicroServiceHeader, "true") + forbiddenRedirectToMicroservice, err := cmd.Flags().GetBool(flagFromPDService) + if err == nil && forbiddenRedirectToMicroservice { + header.Add(apiutil.XForbiddenForwardToMicroserviceHeader, "true") } return header } diff --git a/tools/pd-ctl/pdctl/command/global.go b/tools/pd-ctl/pdctl/command/global.go index ce79277db1b..4e91f0de514 100644 --- a/tools/pd-ctl/pdctl/command/global.go +++ b/tools/pd-ctl/pdctl/command/global.go @@ -207,9 +207,9 @@ func dial(req *http.Request) (string, error) { if err != nil { return "", err } - if req.Header.Get(apiutil.XForbiddenForwardToMicroServiceHeader) == "true" { - if resp.Header.Get(apiutil.XForwardedToMicroServiceHeader) == "true" { - return string(content), errors.Errorf("the request is forwarded to micro service unexpectedly") + if req.Header.Get(apiutil.XForbiddenForwardToMicroserviceHeader) == "true" { + if resp.Header.Get(apiutil.XForwardedToMicroserviceHeader) == "true" { + return string(content), errors.Errorf("the request is forwarded to microservice unexpectedly") } } return string(content), nil diff --git a/tools/pd-ctl/tests/config/config_test.go b/tools/pd-ctl/tests/config/config_test.go index 39820a6c7b7..3b622beecbf 100644 --- a/tools/pd-ctl/tests/config/config_test.go +++ b/tools/pd-ctl/tests/config/config_test.go @@ -1233,11 +1233,11 @@ func (suite *configTestSuite) checkPDServerConfig(cluster *pdTests.TestCluster) re.Equal(int(3), conf.FlowRoundByDigit) } -func (suite *configTestSuite) TestMicroServiceConfig() { - suite.env.RunTestBasedOnMode(suite.checkMicroServiceConfig) +func (suite *configTestSuite) TestMicroserviceConfig() { + suite.env.RunTestBasedOnMode(suite.checkMicroserviceConfig) } -func (suite *configTestSuite) checkMicroServiceConfig(cluster *pdTests.TestCluster) { +func (suite *configTestSuite) checkMicroserviceConfig(cluster *pdTests.TestCluster) { re := suite.Require() leaderServer := cluster.GetLeaderServer() pdAddr := leaderServer.GetAddr() @@ -1254,13 +1254,13 @@ func (suite *configTestSuite) checkMicroServiceConfig(cluster *pdTests.TestClust re.NoError(err) cfg := config.Config{} re.NoError(json.Unmarshal(output, &cfg)) - re.True(svr.GetMicroServiceConfig().EnableSchedulingFallback) - re.True(cfg.MicroService.EnableSchedulingFallback) + re.True(svr.GetMicroserviceConfig().EnableSchedulingFallback) + re.True(cfg.Microservice.EnableSchedulingFallback) // config set enable-scheduling-fallback args := []string{"-u", pdAddr, "config", "set", "enable-scheduling-fallback", "false"} _, err = tests.ExecuteCommand(cmd, args...) re.NoError(err) - re.False(svr.GetMicroServiceConfig().EnableSchedulingFallback) + re.False(svr.GetMicroserviceConfig().EnableSchedulingFallback) } func (suite *configTestSuite) TestRegionRules() {