KyleJamesWalker edited a comment on issue #4931: [AIRFLOW-4109] Added support 
for passing the airflow fernet key to th…
URL: https://github.com/apache/airflow/pull/4931#issuecomment-547254353
 
 
   I'm having the same issue but if I set the following:
   ``` 
   AIRFLOW__KUBERNETES_ENVIRONMENT_VARIABLES__AIRFLOW__CORE__FERNET_KEY: "xxx="
   AIRFLOW__KUBERNETES_ENVIRONMENT_VARIABLES__FERNET_KEY: "xxx="
   ```
   
   The worker gets the variables set, but the key is lowercase, so it's not 
being picked up...
   So airflow doesn't pick them up:
   ```
   fernet_key: xxx=
   airflow__core__fernet_key: xxx=
   ```
   
   Note: Previous env values did not have the `S` at the end of `VARIABLES`
   
   For now, I added a hack and my DAG and it works just fine:
   
   ``` python
   if os.getenv('fernet_key'):
       os.environ['FERNET_KEY'] = os.environ['fernet_key']
   ```
   
   Does anyone know how to get these to be set with uppercase values?
   
   I'm assuming it's from here: 
https://github.com/apache/airflow/blob/88989200a66291580088188f06a6db503ac823e2/airflow/configuration.py#L336-L339
   
   Honestly, I think this code should have a special check for the k8s env 
section, something like: 
   ``` python
           section_prefix = 'AIRFLOW__{S}__'.format(S=section.upper())
           for env_var in sorted(os.environ.keys()):
               if env_var.startswith(section_prefix):
                   if section == "kubernetes_environment_variables":
                       key = env_var.replace(section_prefix, '')
                   else:
                       key = env_var.replace(section_prefix, '').lower()
                   _section[key] = self._get_env_var_option(section, key)
   ```
   
   
   Update we had to add the following for our k8s setup and it worked!!! the 
config map has FERNET_KEY, and now the workers are happy <3
   ```
   AIRFLOW__KUBERNETES__ENV_FROM_CONFIGMAP_REF: "airflow-env"
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to