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

Aline Manera alinefm at linux.vnet.ibm.com
Thu Sep 4 01:24:07 UTC 2014


On 09/03/2014 08:58 AM, lvroyce0210 at gmail.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          | 3 +++
>   4 files changed, 8 insertions(+)
>
> diff --git a/src/kimchi.conf.in b/src/kimchi.conf.in
> index 2be1a0e..82baa0c 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 bytes
> +#max_body_size = 4 * 1024 * 1024 * 1024
> +

What about use MB or GB and do the conversion to bytes internally?
It will be easier to user just specify a number.

# Max request body size in GB
#max_body_size = 4

>   [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")
>       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..08a9be7 100644
> --- a/src/kimchid.in
> +++ b/src/kimchid.in
> @@ -47,6 +47,7 @@ def main(options):
>       cherrypy_port = config.config.get("server", "cherrypy_port")
>       runningEnv = config.config.get("server", "environment")
>       federation = config.config.get("server", "federation")
> +    max_body_size = config.config.get("server", "max_body_size")
>       logDir = config.config.get("logging", "log_dir")
>       logLevel = config.config.get("logging", "log_level")
>
> @@ -72,6 +73,8 @@ def main(options):
>       parser.add_option('--federation', default=federation,
>                         help="Register and discover Kimchi peers at the same "
>                              "network using openSLP")

> +    parser.add_option('--max_body_size', default=max_body_size,
> +                      help="Max request body size accept by kimchi")

I think we don't need to allow it on command line. Only the config file 
should be enough in this case.

>       parser.add_option('--test', action='store_true',
>                         help="Run server in mock model")
>       (options, args) = parser.parse_args()




More information about the Kimchi-devel mailing list