agent: remove an a branch in the AddService flow

Handle the decision to use ServiceManager in a single place. Instead of
calling ServiceManager.AddService, then calling back into
addServiceInternal, only call ServiceManager.AddService if we are going
to use it.

This change removes some small duplication and removes a branch from the
AddService flow.
This commit is contained in:
Daniel Nephin 2020-11-30 14:24:08 -05:00
parent 4da0718c57
commit 5f9930a9be
2 changed files with 1 additions and 10 deletions

View File

@ -1912,7 +1912,7 @@ func (a *Agent) addServiceLocked(req AddServiceRequest) error {
return err return err
} }
if a.config.EnableCentralServiceConfig { if a.config.EnableCentralServiceConfig && (req.Service.IsSidecarProxy() || req.Service.IsGateway()) {
return a.serviceManager.AddService(req) return a.serviceManager.AddService(req)
} }

View File

@ -122,15 +122,6 @@ func (s *ServiceManager) registerOnce(args addServiceInternalRequest) error {
// //
// NOTE: the caller must hold the Agent.stateLock! // NOTE: the caller must hold the Agent.stateLock!
func (s *ServiceManager) AddService(req AddServiceRequest) error { func (s *ServiceManager) AddService(req AddServiceRequest) error {
req.Service.EnterpriseMeta.Normalize()
// For now only proxies have anything that can be configured
// centrally. So bypass the whole manager for regular services.
if !req.Service.IsSidecarProxy() && !req.Service.IsGateway() {
req.persistServiceConfig = false
return s.agent.addServiceInternal(addServiceInternalRequest{AddServiceRequest: req})
}
// TODO: replace serviceRegistration with AddServiceRequest // TODO: replace serviceRegistration with AddServiceRequest
reg := &serviceRegistration{ reg := &serviceRegistration{
service: req.Service, service: req.Service,