From 64c8ba8f6ec2fdb52484e277c9a3dace9cf70174 Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Tue, 26 Dec 2023 15:32:16 +0800 Subject: [PATCH] fix:code style --- common/log/type.go | 10 +--------- pkg/controller/configmap.go | 12 ++++++------ pkg/controller/controller.go | 2 ++ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/common/log/type.go b/common/log/type.go index a45b1a4b..0de013a6 100644 --- a/common/log/type.go +++ b/common/log/type.go @@ -17,8 +17,6 @@ package log // logger type const ( - // NamingLoggerName sync logger name, can use FindScope function to get the logger - SyncLoggerName = "sync" // ConfigLoggerName config logger name, can use FindScope function to get the logger InjectLoggerName = "inject" // SyncNamingLoggerName naming sync logger name, can use FindScope function to get the logger @@ -32,7 +30,6 @@ const ( ) var ( - syncScope = RegisterScope(SyncLoggerName, "sync logging messages.", 0) injectScope = RegisterScope(InjectLoggerName, "pod inject logging messages.", 0) syncNamingScope = RegisterScope(SyncNamingLoggerName, "naming sync logging messages.", 0) syncConfigScope = RegisterScope(SyncConfigLoggerName, "config sync logging messages.", 0) @@ -41,7 +38,7 @@ var ( ) func allLoggerTypes() []string { - return []string{SyncLoggerName, SyncNamingLoggerName, SyncConfigLoggerName, + return []string{SyncNamingLoggerName, SyncConfigLoggerName, SyncConfigMapLoggerName, InjectLoggerName, DefaultLoggerName} } @@ -50,11 +47,6 @@ func DefaultScope() *Scope { return defaultScope } -// SyncScope naming logging scope handler -func SyncScope() *Scope { - return syncScope -} - // SyncNamingScope naming logging scope handler func SyncNamingScope() *Scope { return syncNamingScope diff --git a/pkg/controller/configmap.go b/pkg/controller/configmap.go index 4dadb072..9f6f0ea9 100644 --- a/pkg/controller/configmap.go +++ b/pkg/controller/configmap.go @@ -294,7 +294,6 @@ func (p *PolarisController) watchPolarisConfig() error { ctx, cancel := context.WithCancel(context.Background()) - // watcher := &PolarisConfigWatcher{ controller: p, k8sClient: p.client, @@ -388,10 +387,13 @@ func (p *PolarisConfigWatcher) doRecv(ctx context.Context) { default: msg, err := discoverClient.Recv() if err != nil { + log.SyncConfigMapScope().Info("receive fetch config resource fail", zap.Error(err)) continue } - if msg.Code == uint32(apimodel.Code_DataNoChange) { + log.SyncConfigMapScope().Infof("receive fetch config resource for type(%v) code(%d)", + msg.GetType().String(), msg.GetCode()) + if msg.Code != uint32(apimodel.Code_ExecuteSuccess) { continue } @@ -439,6 +441,7 @@ func (p *PolarisConfigWatcher) fetchResources(ctx context.Context) { } func (p *PolarisConfigWatcher) fetchGroups(ns string) { + log.SyncConfigMapScope().Infof("begin fetch config groups for namespace(%v)", ns) p.groups.ComputeIfAbsent(ns, func(k string) *util.SyncSet[string] { return util.NewSyncSet[string]() }) @@ -481,6 +484,7 @@ func (p *PolarisConfigWatcher) receiveGroups(resp *config_manage.ConfigDiscoverR } func (p *PolarisConfigWatcher) fetchConfigFiles(namespace, group string) { + log.SyncConfigMapScope().Infof("begin fetch config files for namespace(%v) group(%s)", namespace, group) key := namespace + "/" + group preRevision, _ := p.filesRevisions.Load(key) discoverClient := p.discoverClient @@ -597,10 +601,6 @@ const ( ) func (p *PolarisConfigWatcher) allowSyncToConfigMap(file *config_manage.ClientConfigFileInfo) bool { - // 如果是加密配置,目前不支持,跳过同步 - if file.GetEncrypted().GetValue() { - return false - } var ( allowSync bool isSourceFromK8s bool diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 9d0d625f..e22b0642 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -20,6 +20,7 @@ import ( "github.com/polarismesh/polaris-go/api" "go.uber.org/atomic" + "go.uber.org/zap" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/runtime" @@ -199,6 +200,7 @@ func NewPolarisController( p.provider = providerAPI p.config = config + log.Info("controller config", zap.Any("info", p.config.PolarisController)) return p, p.watchPolarisConfig() }