@@ -99,26 +99,38 @@ func int32Ptr(i int) *int32 {
9999
100100// TenantServiceBase conv tenant service base info
101101func TenantServiceBase (as * v1.AppService , dbmanager db.Manager ) error {
102- logrus .Debugf ("[TenantServiceBase] Querying tenant_service table for serviceID: %s" , as .ServiceID )
102+ shouldDebug := shouldDebugServiceID (as .ServiceID )
103+ if shouldDebug {
104+ logrus .Infof ("[TenantServiceBase] Querying tenant_service table for serviceID: %s" , as .ServiceID )
105+ }
103106 tenantService , err := dbmanager .TenantServiceDao ().GetServiceByID (as .ServiceID )
104107 if err != nil {
105108 if err == gorm .ErrRecordNotFound {
106- logrus .Warnf ("[TenantServiceBase] Service %s not found in database (ErrRecordNotFound)" , as .ServiceID )
109+ if shouldDebug {
110+ logrus .Warnf ("[TenantServiceBase] Service %s not found in database (ErrRecordNotFound)" , as .ServiceID )
111+ }
107112 return ErrServiceNotFound
108113 }
109- logrus .Errorf ("[TenantServiceBase] Database error querying service %s: %v" , as .ServiceID , err )
114+ if shouldDebug {
115+ logrus .Errorf ("[TenantServiceBase] Database error querying service %s: %v" , as .ServiceID , err )
116+ }
110117 return fmt .Errorf ("error getting service base info by serviceID(%s) %s" , as .ServiceID , err .Error ())
111118 }
112- logrus .Infof ("[TenantServiceBase] Found service in DB: serviceID=%s, alias=%s, kind=%s, tenantID=%s, deployVersion=%s" ,
113- as .ServiceID , tenantService .ServiceAlias , tenantService .Kind , tenantService .TenantID , tenantService .DeployVersion )
119+ if shouldDebug {
120+ logrus .Infof ("[TenantServiceBase] Found service in DB: serviceID=%s, alias=%s, kind=%s, tenantID=%s, deployVersion=%s" ,
121+ as .ServiceID , tenantService .ServiceAlias , tenantService .Kind , tenantService .TenantID , tenantService .DeployVersion )
122+ }
114123 as .ServiceKind = dbmodel .ServiceKind (tenantService .Kind )
115- logrus .Debugf ("[TenantServiceBase] Querying tenant info for tenantID: %s" , tenantService .TenantID )
124+ if shouldDebug {
125+ logrus .Infof ("[TenantServiceBase] Querying tenant info for tenantID: %s" , tenantService .TenantID )
126+ }
116127 tenant , err := dbmanager .TenantDao ().GetTenantByUUID (tenantService .TenantID )
117128 if err != nil {
118- logrus .Errorf ("[TenantServiceBase] Failed to get tenant %s: %v" , tenantService .TenantID , err )
129+ if shouldDebug {
130+ logrus .Errorf ("[TenantServiceBase] Failed to get tenant %s: %v" , tenantService .TenantID , err )
131+ }
119132 return fmt .Errorf ("get tenant info failure %s" , err .Error ())
120133 }
121- logrus .Debugf ("[TenantServiceBase] Found tenant: %s" , tenant .Name )
122134 as .TenantID = tenantService .TenantID
123135 if as .DeployVersion == "" {
124136 as .DeployVersion = tenantService .DeployVersion
@@ -135,18 +147,24 @@ func TenantServiceBase(as *v1.AppService, dbmanager db.Manager) error {
135147 }
136148 as .TenantName = tenant .Name
137149 if err := initTenant (as , tenant ); err != nil {
138- logrus .Errorf ("[TenantServiceBase] Failed to init tenant for service %s: %v" , as .ServiceID , err )
150+ if shouldDebug {
151+ logrus .Errorf ("[TenantServiceBase] Failed to init tenant for service %s: %v" , as .ServiceID , err )
152+ }
139153 return fmt .Errorf ("conversion tenant info failure %s" , err .Error ())
140154 }
141155 if tenantService .Kind == dbmodel .ServiceKindThirdParty .String () {
142- logrus .Debugf ("[TenantServiceBase] Service %s is third-party, loading discovery config" , as .ServiceID )
156+ if shouldDebug {
157+ logrus .Infof ("[TenantServiceBase] Service %s is third-party, loading discovery config" , as .ServiceID )
158+ }
143159 disCfg , _ := dbmanager .ThirdPartySvcDiscoveryCfgDao ().GetByServiceID (as .ServiceID )
144160 as .SetDiscoveryCfg (disCfg )
145161 return nil
146162 }
147163
148164 if tenantService .Kind == dbmodel .ServiceKindCustom .String () {
149- logrus .Debugf ("[TenantServiceBase] Service %s is custom component" , as .ServiceID )
165+ if shouldDebug {
166+ logrus .Infof ("[TenantServiceBase] Service %s is custom component" , as .ServiceID )
167+ }
150168 return nil
151169 }
152170 label , _ := dbmanager .TenantServiceLabelDao ().GetLabelByNodeSelectorKey (as .ServiceID , "windows" )
0 commit comments