[Kimchi-devel] [PATCHv4 4/7] Storage volume upload: Control request body size of kimchi

Aline Manera alinefm at linux.vnet.ibm.com
Thu Sep 4 14:44:56 UTC 2014


On 09/04/2014 06:25 AM, lvroyce at linux.vnet.ibm.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> This patch control request body size to be 4G,
> when request size exceed, kimchi will response with 413.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi.conf.in      | 3 +++
>   src/kimchi/config.py.in | 1 +
>   src/kimchi/server.py    | 1 +
>   src/kimchid.in          | 1 +
>   4 files changed, 6 insertions(+)
>
> diff --git a/src/kimchi.conf.in b/src/kimchi.conf.in
> index 2be1a0e..ea39292 100644
> --- a/src/kimchi.conf.in
> +++ b/src/kimchi.conf.in
> @@ -30,6 +30,9 @@
>   # at the same network
>   #federation = off
>
> +# Max request body size in KB, default value is 4GB
> +#max_body_size = 4 * 1024 * 1024
> +
>   [logging]
>   # Log directory
>   #log_dir = @localstatedir@/log/kimchi
> diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
> index d403827..48b43d7 100644
> --- a/src/kimchi/config.py.in
> +++ b/src/kimchi/config.py.in
> @@ -255,6 +255,7 @@ def _get_config():
>       config.set("server", "ssl_key", "")
>       config.set("server", "environment", "production")
>       config.set("server", "federation", "off")

> +    config.set("server", "max_body_size", "4*1024*1024*1024")

You should use the same value from config file, ie, 4 * 1024 * 1024.
Otherwise, if user remove the "max_body_value" from config file you will 
use this value as default and then multiply by 1024 again which would 
result in a big number.

>       config.add_section("logging")
>       config.set("logging", "log_dir", paths.log_dir)
>       config.set("logging", "log_level", DEFAULT_LOG_LEVEL)
> diff --git a/src/kimchi/server.py b/src/kimchi/server.py
> index 10f5dff..1c3b360 100644
> --- a/src/kimchi/server.py
> +++ b/src/kimchi/server.py
> @@ -87,6 +87,7 @@ class Server(object):
>           # directly. You must go through the proxy.
>           cherrypy.server.socket_host = '127.0.0.1'
>           cherrypy.server.socket_port = options.cherrypy_port
> +        cherrypy.server.max_request_body_size = eval(options.max_body_size)
>
>           cherrypy.log.screen = True
>           cherrypy.log.access_file = options.access_log
> diff --git a/src/kimchid.in b/src/kimchid.in
> index 3ed087f..6e2d9b7 100644
> --- a/src/kimchid.in
> +++ b/src/kimchid.in
> @@ -86,6 +86,7 @@ def main(options):
>       # Add non-option arguments
>       setattr(options, 'ssl_cert', config.config.get('server', 'ssl_cert'))
>       setattr(options, 'ssl_key', config.config.get('server', 'ssl_key'))
> +    setattr(options, 'max_body_size', config.config.get('server', 'max_body_size')*1024)
>
>       kimchi.server.main(options)
>




More information about the Kimchi-devel mailing list