[PATCH 1/2 - v2][wok] Limit number of backup log files and make it configurable

Currently Wok is configured to keep up to 1000 log files of 10MB, this behavior makes Wok/Kimchi log space become huge (up to 20GB, for error and access logs). This patch changes the configuration, limiting the number of stored log files to 10. So space required in the system will be up to 200MB. It also adds log_backup_count property to /etc/wok.conf, allowing users to change this value if necessary. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/wok.conf.in | 3 +++ src/wok/config.py.in | 2 ++ src/wok/server.py | 6 ++++-- src/wokd.in | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/wok.conf.in b/src/wok.conf.in index 60d826f..5e86ff8 100644 --- a/src/wok.conf.in +++ b/src/wok.conf.in @@ -43,6 +43,9 @@ # Logging level: debug, info, warning, error or critical #log_level = debug +# Log files backup count. The number of old log files to keep in the system +# log_backup_count = 10 + [display] # Port for websocket proxy to listen on #display_proxy_port = 64667 diff --git a/src/wok/config.py.in b/src/wok/config.py.in index 0c83812..342e80b 100644 --- a/src/wok/config.py.in +++ b/src/wok/config.py.in @@ -29,6 +29,7 @@ __release__ = "@wokrelease@" CACHEEXPIRES = 31536000 # expires is one year. DEFAULT_LOG_LEVEL = "debug" +DEFAULT_LOG_BACKUP_COUNT = 10 FONT_FILES = {'fontawesome': ['fontawesome-webfont.ttf'], 'opensans': ['OpenSans-ExtraBoldItalic.ttf', @@ -247,6 +248,7 @@ def _get_config(): config.add_section("logging") config.set("logging", "log_dir", paths.log_dir) config.set("logging", "log_level", DEFAULT_LOG_LEVEL) + config.set("logging", "log_backup_count", str(DEFAULT_LOG_BACKUP_COUNT)) config.add_section("display") config.set("display", "display_proxy_port", "64667") diff --git a/src/wok/server.py b/src/wok/server.py index 59ecdc0..53af12a 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -101,7 +101,8 @@ class Server(object): # Create handler to rotate access log file h = logging.handlers.RotatingFileHandler(options.access_log, 'a', - 10000000, 1000) + 10000000, + options.log_backup_count) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) @@ -110,7 +111,8 @@ class Server(object): # Create handler to rotate error log file h = logging.handlers.RotatingFileHandler(options.error_log, 'a', - 10000000, 1000) + 10000000, + options.log_backup_count) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt) diff --git a/src/wokd.in b/src/wokd.in index c5510fd..ac43df6 100644 --- a/src/wokd.in +++ b/src/wokd.in @@ -94,6 +94,8 @@ def main(options): setattr(options, 'ssl_key', config.config.get('server', 'ssl_key')) setattr(options, 'max_body_size', config.config.get('server', 'max_body_size')) + setattr(options, 'log_backup_count', + config.config.get('logging', 'log_backup_count')) wok.server.main(options) -- 2.1.0

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/wok/config.py.in | 2 +- src/wok/server.py | 2 +- src/wokd.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wok/config.py.in b/src/wok/config.py.in index 342e80b..1129afd 100644 --- a/src/wok/config.py.in +++ b/src/wok/config.py.in @@ -1,7 +1,7 @@ # # Project Wok # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # Code derived from Project Kimchi # diff --git a/src/wok/server.py b/src/wok/server.py index 53af12a..c06aa1b 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -1,7 +1,7 @@ # # Project Wok # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # Code derived from Project Kimchi # diff --git a/src/wokd.in b/src/wokd.in index ac43df6..9ce4cce 100644 --- a/src/wokd.in +++ b/src/wokd.in @@ -2,7 +2,7 @@ # # Project Wok # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # Code derived from Project Kimchi # -- 2.1.0

Reviewed-By: Ramon Medeiros <ramonn@br.ibm.com> On 01/13/2016 10:11 AM, Rodrigo Trujillo wrote:
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/wok/config.py.in | 2 +- src/wok/server.py | 2 +- src/wokd.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/wok/config.py.in b/src/wok/config.py.in index 342e80b..1129afd 100644 --- a/src/wok/config.py.in +++ b/src/wok/config.py.in @@ -1,7 +1,7 @@ # # Project Wok # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # Code derived from Project Kimchi # diff --git a/src/wok/server.py b/src/wok/server.py index 53af12a..c06aa1b 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -1,7 +1,7 @@ # # Project Wok # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # Code derived from Project Kimchi # diff --git a/src/wokd.in b/src/wokd.in index ac43df6..9ce4cce 100644 --- a/src/wokd.in +++ b/src/wokd.in @@ -2,7 +2,7 @@ # # Project Wok # -# Copyright IBM, Corp. 2013-2015 +# Copyright IBM, Corp. 2013-2016 # # Code derived from Project Kimchi #
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

Reviewed-by: Paulo Vital <pvital@linux.vnet.ibm.com> On 01/13/2016 10:11 AM, Rodrigo Trujillo wrote:
Currently Wok is configured to keep up to 1000 log files of 10MB, this behavior makes Wok/Kimchi log space become huge (up to 20GB, for error and access logs). This patch changes the configuration, limiting the number of stored log files to 10. So space required in the system will be up to 200MB.
It also adds log_backup_count property to /etc/wok.conf, allowing users to change this value if necessary.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/wok.conf.in | 3 +++ src/wok/config.py.in | 2 ++ src/wok/server.py | 6 ++++-- src/wokd.in | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/wok.conf.in b/src/wok.conf.in index 60d826f..5e86ff8 100644 --- a/src/wok.conf.in +++ b/src/wok.conf.in @@ -43,6 +43,9 @@ # Logging level: debug, info, warning, error or critical #log_level = debug
+# Log files backup count. The number of old log files to keep in the system +# log_backup_count = 10 + [display] # Port for websocket proxy to listen on #display_proxy_port = 64667 diff --git a/src/wok/config.py.in b/src/wok/config.py.in index 0c83812..342e80b 100644 --- a/src/wok/config.py.in +++ b/src/wok/config.py.in @@ -29,6 +29,7 @@ __release__ = "@wokrelease@"
CACHEEXPIRES = 31536000 # expires is one year. DEFAULT_LOG_LEVEL = "debug" +DEFAULT_LOG_BACKUP_COUNT = 10
FONT_FILES = {'fontawesome': ['fontawesome-webfont.ttf'], 'opensans': ['OpenSans-ExtraBoldItalic.ttf', @@ -247,6 +248,7 @@ def _get_config(): config.add_section("logging") config.set("logging", "log_dir", paths.log_dir) config.set("logging", "log_level", DEFAULT_LOG_LEVEL) + config.set("logging", "log_backup_count", str(DEFAULT_LOG_BACKUP_COUNT)) config.add_section("display") config.set("display", "display_proxy_port", "64667")
diff --git a/src/wok/server.py b/src/wok/server.py index 59ecdc0..53af12a 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -101,7 +101,8 @@ class Server(object):
# Create handler to rotate access log file h = logging.handlers.RotatingFileHandler(options.access_log, 'a', - 10000000, 1000) + 10000000, + options.log_backup_count) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt)
@@ -110,7 +111,8 @@ class Server(object):
# Create handler to rotate error log file h = logging.handlers.RotatingFileHandler(options.error_log, 'a', - 10000000, 1000) + 10000000, + options.log_backup_count) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt)
diff --git a/src/wokd.in b/src/wokd.in index c5510fd..ac43df6 100644 --- a/src/wokd.in +++ b/src/wokd.in @@ -94,6 +94,8 @@ def main(options): setattr(options, 'ssl_key', config.config.get('server', 'ssl_key')) setattr(options, 'max_body_size', config.config.get('server', 'max_body_size')) + setattr(options, 'log_backup_count', + config.config.get('logging', 'log_backup_count'))
wok.server.main(options)

Hi Rodrigo, Is there an option to allow log compression? It would be good to have it too as requested in the issue https://github.com/kimchi-project/wok/issues/26 Or has it already been doing in some way? Regards, Aline Manera On 01/13/2016 10:11 AM, Rodrigo Trujillo wrote:
Currently Wok is configured to keep up to 1000 log files of 10MB, this behavior makes Wok/Kimchi log space become huge (up to 20GB, for error and access logs). This patch changes the configuration, limiting the number of stored log files to 10. So space required in the system will be up to 200MB.
It also adds log_backup_count property to /etc/wok.conf, allowing users to change this value if necessary.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/wok.conf.in | 3 +++ src/wok/config.py.in | 2 ++ src/wok/server.py | 6 ++++-- src/wokd.in | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/wok.conf.in b/src/wok.conf.in index 60d826f..5e86ff8 100644 --- a/src/wok.conf.in +++ b/src/wok.conf.in @@ -43,6 +43,9 @@ # Logging level: debug, info, warning, error or critical #log_level = debug
+# Log files backup count. The number of old log files to keep in the system +# log_backup_count = 10 + [display] # Port for websocket proxy to listen on #display_proxy_port = 64667 diff --git a/src/wok/config.py.in b/src/wok/config.py.in index 0c83812..342e80b 100644 --- a/src/wok/config.py.in +++ b/src/wok/config.py.in @@ -29,6 +29,7 @@ __release__ = "@wokrelease@"
CACHEEXPIRES = 31536000 # expires is one year. DEFAULT_LOG_LEVEL = "debug" +DEFAULT_LOG_BACKUP_COUNT = 10
FONT_FILES = {'fontawesome': ['fontawesome-webfont.ttf'], 'opensans': ['OpenSans-ExtraBoldItalic.ttf', @@ -247,6 +248,7 @@ def _get_config(): config.add_section("logging") config.set("logging", "log_dir", paths.log_dir) config.set("logging", "log_level", DEFAULT_LOG_LEVEL) + config.set("logging", "log_backup_count", str(DEFAULT_LOG_BACKUP_COUNT)) config.add_section("display") config.set("display", "display_proxy_port", "64667")
diff --git a/src/wok/server.py b/src/wok/server.py index 59ecdc0..53af12a 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -101,7 +101,8 @@ class Server(object):
# Create handler to rotate access log file h = logging.handlers.RotatingFileHandler(options.access_log, 'a', - 10000000, 1000) + 10000000, + options.log_backup_count) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt)
@@ -110,7 +111,8 @@ class Server(object):
# Create handler to rotate error log file h = logging.handlers.RotatingFileHandler(options.error_log, 'a', - 10000000, 1000) + 10000000, + options.log_backup_count) h.setLevel(logLevel) h.setFormatter(cherrypy._cplogging.logfmt)
diff --git a/src/wokd.in b/src/wokd.in index c5510fd..ac43df6 100644 --- a/src/wokd.in +++ b/src/wokd.in @@ -94,6 +94,8 @@ def main(options): setattr(options, 'ssl_key', config.config.get('server', 'ssl_key')) setattr(options, 'max_body_size', config.config.get('server', 'max_body_size')) + setattr(options, 'log_backup_count', + config.config.get('logging', 'log_backup_count'))
wok.server.main(options)
participants (4)
-
Aline Manera
-
Paulo Vital
-
Ramon Medeiros
-
Rodrigo Trujillo