ashb commented on a change in pull request #4859: [AIRFLOW-3917] Added config
to support running scheduler(with kuberne…
URL: https://github.com/apache/airflow/pull/4859#discussion_r263997364
##########
File path: airflow/contrib/kubernetes/kube_client.py
##########
@@ -46,6 +46,8 @@ def _load_kube_config(in_cluster, cluster_context,
config_file):
def get_kube_client(in_cluster=conf.getboolean('kubernetes', 'in_cluster'),
- cluster_context=None,
- config_file=None):
+ cluster_context=None if not conf.get('kubernetes',
'cluster_context') else
+ conf.get('kubernetes', 'cluster_context'),
+ config_file=None if not conf.get('kubernetes',
'config_file') else
+ conf.get('kubernetes', 'config_file')):
Review comment:
These defaults are a bit complex to read as they are. Two things:
1. Leave the default param on the function as None (so have `if
cluster_context is None:` in the fn body) - this is due to when Python
"evaluates" the default values (at import time) which I would like to not
depend on having parsed the config.
2. The condition `if not ... else` can be replaced with
`conf.get('kubernetes', 'cluster_context', fallback=None)` if you *don't*
specify values in the config. I.e `cluster_context =` becomes `#
cluster_context =`
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services