From 885a042d03435cddc5701bf266b6de524f7c9db3 Mon Sep 17 00:00:00 2001 From: Flavio Crisciani Date: Fri, 23 Feb 2018 15:24:47 -0800 Subject: [PATCH] Limit max length transient log Set a limit to the max size of the transient log to avoid filling up logs in case of issues Signed-off-by: Flavio Crisciani --- service_common.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/service_common.go b/service_common.go index 4411c9700f..0ec4cb50e3 100644 --- a/service_common.go +++ b/service_common.go @@ -9,6 +9,8 @@ import ( "github.com/sirupsen/logrus" ) +const maxSetStringLen = 350 + func (c *controller) addEndpointNameResolution(svcName, svcID, nID, eID, containerName string, vip net.IP, serviceAliases, taskAliases []string, ip net.IP, addService bool, method string) error { n, err := c.NetworkByID(nID) if err != nil { @@ -285,7 +287,7 @@ func (c *controller) addServiceBinding(svcName, svcID, nID, eID, containerName s ok, entries := s.assignIPToEndpoint(ip.String(), eID) if !ok || entries > 1 { setStr, b := s.printIPToEndpoint(ip.String()) - logrus.Warnf("addServiceBinding %s possible trainsient state ok:%t entries:%d set:%t %s", eID, ok, entries, b, setStr) + logrus.Warnf("addServiceBinding %s possible transient state ok:%t entries:%d set:%t %s", eID, ok, entries, b, setStr[:maxSetStringLen]) } // Add loadbalancer service and backend in all sandboxes in @@ -353,7 +355,7 @@ func (c *controller) rmServiceBinding(svcName, svcID, nID, eID, containerName st ok, entries := s.removeIPToEndpoint(ip.String(), eID) if !ok || entries > 0 { setStr, b := s.printIPToEndpoint(ip.String()) - logrus.Warnf("rmServiceBinding %s possible trainsient state ok:%t entries:%d set:%t %s", eID, ok, entries, b, setStr) + logrus.Warnf("rmServiceBinding %s possible transient state ok:%t entries:%d set:%t %s", eID, ok, entries, b, setStr[:maxSetStringLen]) } // Remove loadbalancer service(if needed) and backend in all