Flower: Environment parsing causes issues in Kubernetes

Created on 19 Sep 2017  路  3Comments  路  Source: mher/flower

When deploying Flower in Kubernetes and naming the Kubernetes deployment e.g. "flower" it causes Kubernetes to set environment variables that clashes with the scheme that Flower uses, namely environment variables with the form FLOWER_x_y_z.

Symptom

ValueError: invalid literal for int() with base 10: 'tcp://a.b.c.d:5555'

Problem
The code that breaks is in the apply_env_options function.

Line 74 breaks when Kubernetes sets the environment variable FLOWER_PORT=tcp://a.b.c.d:5555 and Flower tries to set option.type to the string tcp://a.b.c.d:5555.

There needs to be some more error handling here. Simply doing something like

    def apply_env_options(self):
        "apply options passed through environment variables"
        env_options = filter(self.is_flower_envvar, os.environ)
        for env_var_name in env_options:
            name = env_var_name.replace(self.ENV_VAR_PREFIX, '', 1).lower()
            value = os.environ[env_var_name]
            try:
                option = options._options[name]
            except:
                option = options._options[name.replace('_', '-')]
            if option.multiple:
                value = [option.type(i) for i in value.split(',')]
            else:
                try:
                   value = option.type(value)
                except:
                  continue
            setattr(options, name, value)

Would fix it, but may not satisfy the intention of the code.

A workaround is to rename the Kubernetes deployment to something not containing flower.

Most helpful comment

just hit that today.. you need to name your service and other objects something else than 'flower'. I think best is to have a cmdline option to ignore env options.

All 3 comments

just hit that today.. you need to name your service and other objects something else than 'flower'. I think best is to have a cmdline option to ignore env options.

just wanted to say thanks for reporting this issue; i googled the error on the off-chance of finding someone with the same issue; didn't really expect to! :)

i think this is the issue: https://github.com/puckel/docker-airflow/issues/46
The solution (FLOWER_PORT: 5555 variable in the deployment config) did work for me

Was this page helpful?
0 / 5 - 0 ratings