From ca7458cf1c7ad2d5605a3dd8f9f96da9c511a54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=84=E6=BD=AD?= Date: Wed, 27 Nov 2024 20:44:34 +0800 Subject: [PATCH] Optimize the overall log output (#1549) --- pkg/bootstrap/server.go | 2 +- pkg/cert/certmgr.go | 2 +- pkg/cert/log.go | 4 ++-- pkg/cmd/server.go | 2 +- pkg/ingress/config/ingress_config.go | 17 ++++++++--------- pkg/ingress/config/kingress_config.go | 2 +- pkg/ingress/kube/ingress/status.go | 2 -- pkg/ingress/kube/ingressv1/controller.go | 14 +++++++++++--- pkg/ingress/kube/ingressv1/status.go | 2 -- pkg/ingress/kube/kingress/status.go | 1 - pkg/ingress/log/log.go | 4 ++-- 11 files changed, 27 insertions(+), 25 deletions(-) diff --git a/pkg/bootstrap/server.go b/pkg/bootstrap/server.go index 7c54332b5b..717704c4ef 100644 --- a/pkg/bootstrap/server.go +++ b/pkg/bootstrap/server.go @@ -41,11 +41,11 @@ import ( "istio.io/istio/pkg/config/schema/kind" "istio.io/istio/pkg/keepalive" istiokube "istio.io/istio/pkg/kube" + "istio.io/istio/pkg/log" "istio.io/istio/pkg/security" "istio.io/istio/security/pkg/server/ca/authenticate" "istio.io/istio/security/pkg/server/ca/authenticate/kubeauth" "istio.io/pkg/ledger" - "istio.io/pkg/log" "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" diff --git a/pkg/cert/certmgr.go b/pkg/cert/certmgr.go index 34f4ffbe83..db5a030193 100644 --- a/pkg/cert/certmgr.go +++ b/pkg/cert/certmgr.go @@ -173,7 +173,7 @@ func (s *CertMgr) Reconcile(ctx context.Context, oldConfig *Config, newConfig *C s.cache.Start() // sync domains s.configMgr.SetConfig(newConfig) - CertLog.Infof("certMgr start to manageSync domains:+v%", newDomains) + CertLog.Infof("certMgr start to manageSync domains: %+v", newDomains) s.manageSync(context.Background(), newDomains) CertLog.Infof("certMgr manageSync domains done") } else { diff --git a/pkg/cert/log.go b/pkg/cert/log.go index 15017c8f68..e8190cd916 100644 --- a/pkg/cert/log.go +++ b/pkg/cert/log.go @@ -14,6 +14,6 @@ package cert -import "istio.io/pkg/log" +import "istio.io/istio/pkg/log" -var CertLog = log.RegisterScope("cert", "Higress Cert process.", 0) +var CertLog = log.RegisterScope("cert", "Higress Cert process.") diff --git a/pkg/cmd/server.go b/pkg/cmd/server.go index 0f6ccbc811..548fc61f3c 100644 --- a/pkg/cmd/server.go +++ b/pkg/cmd/server.go @@ -25,7 +25,7 @@ import ( "istio.io/istio/pkg/config/constants" "istio.io/istio/pkg/env" "istio.io/istio/pkg/keepalive" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" ) var ( diff --git a/pkg/ingress/config/ingress_config.go b/pkg/ingress/config/ingress_config.go index 9f016903c1..bb4b261ac1 100644 --- a/pkg/ingress/config/ingress_config.go +++ b/pkg/ingress/config/ingress_config.go @@ -303,21 +303,21 @@ func (m *IngressConfig) listFromIngressControllers(typ config.GroupVersionKind, common.SortIngressByCreationTime(configs) wrapperConfigs := m.createWrapperConfigs(configs) - IngressLog.Infof("resource type %s, configs number %d", typ, len(wrapperConfigs)) + var result []config.Config switch typ { case gvk.Gateway: - return m.convertGateways(wrapperConfigs) + result = m.convertGateways(wrapperConfigs) case gvk.VirtualService: - return m.convertVirtualService(wrapperConfigs) + result = m.convertVirtualService(wrapperConfigs) case gvk.DestinationRule: - return m.convertDestinationRule(wrapperConfigs) + result = m.convertDestinationRule(wrapperConfigs) case gvk.ServiceEntry: - return m.convertServiceEntry(wrapperConfigs) + result = m.convertServiceEntry(wrapperConfigs) case gvk.WasmPlugin: - return m.convertWasmPlugin(wrapperConfigs) + result = m.convertWasmPlugin(wrapperConfigs) } - - return nil + IngressLog.Infof("resource type %s, ingress number %d, convert configs number %d", typ, len(configs), len(result)) + return result } func (m *IngressConfig) listFromGatewayControllers(typ config.GroupVersionKind, namespace string) []config.Config { @@ -712,7 +712,6 @@ func (m *IngressConfig) convertDestinationRule(configs []common.WrapperConfig) [ if m.RegistryReconciler != nil { drws := m.RegistryReconciler.GetAllDestinationRuleWrapper() - IngressLog.Infof("Found mcp destinationRules: %v", drws) for _, destinationRuleWrapper := range drws { serviceName := destinationRuleWrapper.ServiceKey.ServiceFQDN dr, exist := destinationRules[serviceName] diff --git a/pkg/ingress/config/kingress_config.go b/pkg/ingress/config/kingress_config.go index 5e2e6221e2..b84b25db27 100644 --- a/pkg/ingress/config/kingress_config.go +++ b/pkg/ingress/config/kingress_config.go @@ -493,7 +493,7 @@ func (m *KIngressConfig) HasSynced() bool { defer m.mutex.RUnlock() for _, remoteIngressController := range m.remoteIngressControllers { - IngressLog.Info("In Kingress Synced.", remoteIngressController) + IngressLog.Info("In Kingress Synced.") if !remoteIngressController.HasSynced() { return false } diff --git a/pkg/ingress/kube/ingress/status.go b/pkg/ingress/kube/ingress/status.go index f8707c2cf0..04d38a5699 100644 --- a/pkg/ingress/kube/ingress/status.go +++ b/pkg/ingress/kube/ingress/status.go @@ -81,8 +81,6 @@ func (s *statusSyncer) runUpdateStatus() error { return err } - IngressLog.Debugf("found number %d of svc", len(svcList)) - lbStatusList := common.GetLbStatusListV1Beta1(svcList) if len(lbStatusList) == 0 { return nil diff --git a/pkg/ingress/kube/ingressv1/controller.go b/pkg/ingress/kube/ingressv1/controller.go index 847f2eb852..3412e6432e 100644 --- a/pkg/ingress/kube/ingressv1/controller.go +++ b/pkg/ingress/kube/ingressv1/controller.go @@ -162,6 +162,7 @@ func (c *controller) onEvent(namespacedName types.NamespacedName) error { delete(c.ingresses, namespacedName.String()) c.mutex.Unlock() } else { + IngressLog.Warnf("ingressLister Get failed, ingress: %s, err: %v", namespacedName, err) return err } } @@ -171,7 +172,7 @@ func (c *controller) onEvent(namespacedName types.NamespacedName) error { return nil } - IngressLog.Debugf("ingress: %s, event: %s", namespacedName, event) + IngressLog.Infof("ingress: %s, event: %s", namespacedName, event) // we should check need process only when event is not delete, // if it is delete event, and previously processed, we need to process too. @@ -181,7 +182,7 @@ func (c *controller) onEvent(namespacedName types.NamespacedName) error { return err } if !shouldProcess { - IngressLog.Infof("no need process, ingress %s", namespacedName) + IngressLog.Infof("no need process, ingress: %s", namespacedName) return nil } } @@ -279,10 +280,17 @@ func (c *controller) List() []config.Config { for _, raw := range c.ingressInformer.Informer.GetStore().List() { ing, ok := raw.(*ingress.Ingress) if !ok { + IngressLog.Warnf("get ingress from informer failed: %v", raw) continue } - if should, err := c.shouldProcessIngress(ing); !should || err != nil { + should, err := c.shouldProcessIngress(ing) + if err != nil { + IngressLog.Warnf("check should process ingress failed: %v", err) + continue + } + if !should { + IngressLog.Debugf("no need process ingress: %s/%s", ing.Namespace, ing.Name) continue } diff --git a/pkg/ingress/kube/ingressv1/status.go b/pkg/ingress/kube/ingressv1/status.go index bdd42ef613..4f83f59c81 100644 --- a/pkg/ingress/kube/ingressv1/status.go +++ b/pkg/ingress/kube/ingressv1/status.go @@ -81,8 +81,6 @@ func (s *statusSyncer) runUpdateStatus() error { return err } - IngressLog.Debugf("found number %d of svc", len(svcList)) - lbStatusList := common.GetLbStatusListV1(svcList) if len(lbStatusList) == 0 { return nil diff --git a/pkg/ingress/kube/kingress/status.go b/pkg/ingress/kube/kingress/status.go index e3c7c32939..30fd109151 100644 --- a/pkg/ingress/kube/kingress/status.go +++ b/pkg/ingress/kube/kingress/status.go @@ -77,7 +77,6 @@ func (s *statusSyncer) runUpdateStatus() error { return err } - IngressLog.Debugf("found number %d of svc", len(svcList)) lbStatusList := common2.GetLbStatusList(svcList) return s.updateStatus(lbStatusList) } diff --git a/pkg/ingress/log/log.go b/pkg/ingress/log/log.go index 898c540d83..a4da3b5f8d 100644 --- a/pkg/ingress/log/log.go +++ b/pkg/ingress/log/log.go @@ -14,6 +14,6 @@ package log -import "istio.io/pkg/log" +import "istio.io/istio/pkg/log" -var IngressLog = log.RegisterScope("ingress", "Higress Ingress process.", 0) +var IngressLog = log.RegisterScope("ingress", "Higress Ingress process.")