From 7f1af6312279119ed46d5f4b0e34dcfc8588f5fb Mon Sep 17 00:00:00 2001 From: wangyd1988 Date: Tue, 5 Dec 2023 15:22:49 +0800 Subject: [PATCH] Improve operator logging --- api/v1/helper.go | 1 - controllers/sriovnetworknodepolicy_controller.go | 4 ++-- main.go | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/v1/helper.go b/api/v1/helper.go index f060316b..e14da3ec 100644 --- a/api/v1/helper.go +++ b/api/v1/helper.go @@ -230,7 +230,6 @@ func (p *SriovNetworkNodePolicy) Selected(node *corev1.Node) bool { } return false } - log.Info("Selected():", "node", node.Name) return true } diff --git a/controllers/sriovnetworknodepolicy_controller.go b/controllers/sriovnetworknodepolicy_controller.go index af1538b7..4a66ad8e 100644 --- a/controllers/sriovnetworknodepolicy_controller.go +++ b/controllers/sriovnetworknodepolicy_controller.go @@ -579,7 +579,7 @@ func renderDsForCR(path string, data *render.RenderData) ([]*uns.Unstructured, e func (r *SriovNetworkNodePolicyReconciler) renderDevicePluginConfigData(pl *sriovnetworkv1.SriovNetworkNodePolicyList, node *corev1.Node) (dptypes.ResourceConfList, error) { logger := log.Log.WithName("renderDevicePluginConfigData") - logger.Info("Start to render device plugin config data") + logger.Info("Start to render device plugin config data", "node", node.Name) rcl := dptypes.ResourceConfList{} for _, p := range pl.Items { if p.Name == constants.DefaultPolicyName { @@ -720,7 +720,7 @@ func (r *SriovNetworkNodePolicyReconciler) renderDevicePluginConfigData(pl *srio rawNetDeviceSelectors := json.RawMessage(netDeviceSelectorsMarshal) rc.Selectors = &rawNetDeviceSelectors rcl.ResourceList = append(rcl.ResourceList, *rc) - logger.Info("Add resource", "Resource", *rc, "Resource list", rcl.ResourceList) + logger.Info("Add resource", "Resource", *rc) } } return rcl, nil diff --git a/main.go b/main.go index eb81e387..157b069a 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( "context" "flag" "fmt" + "go.uber.org/zap/zapcore" "os" netattdefv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" @@ -76,6 +77,7 @@ func main() { "Enabling this will ensure there is only one active controller manager.") opts := zap.Options{ Development: true, + TimeEncoder: zapcore.RFC3339NanoTimeEncoder, } opts.BindFlags(flag.CommandLine) flag.Parse()