Skip to content

Commit

Permalink
Optimize the overall log output (#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlanni authored Nov 27, 2024
1 parent ee2dd76 commit ca7458c
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pkg/bootstrap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion pkg/cert/certmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cert/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
2 changes: 1 addition & 1 deletion pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
17 changes: 8 additions & 9 deletions pkg/ingress/config/ingress_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/config/kingress_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/ingress/kube/ingress/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions pkg/ingress/kube/ingressv1/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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.
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/ingress/kube/ingressv1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pkg/ingress/kube/kingress/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingress/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

0 comments on commit ca7458c

Please sign in to comment.