Skip to content

Commit

Permalink
[AIRFLOW-1265] Fix celery executor parsing CELERY_SSL_ACTIVE
Browse files Browse the repository at this point in the history
Changed retrieval of celery/celery_ssl_active to
use configuration.getboolean()

Add correct except block and log warning if
celery/celery_ssl_active key is left undefined

Closes apache#2341 from holygits/master
  • Loading branch information
Jordan authored and saguziel committed Jun 29, 2017
1 parent e92d6bf commit d02e8eb
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions airflow/executors/celery_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from celery import Celery
from celery import states as celery_states

from airflow.exceptions import AirflowException
from airflow.exceptions import AirflowConfigException, AirflowException
from airflow.executors.base_executor import BaseExecutor
from airflow import configuration

Expand All @@ -48,18 +48,25 @@ class CeleryConfig(object):
CELERYD_CONCURRENCY = configuration.getint('celery', 'CELERYD_CONCURRENCY')
CELERY_DEFAULT_QUEUE = DEFAULT_QUEUE
CELERY_DEFAULT_EXCHANGE = DEFAULT_QUEUE
if configuration.getboolean('celery', 'CELERY_SSL_ACTIVE'):
try:

celery_ssl_active = False
try:
celery_ssl_active = configuration.getboolean('celery', 'CELERY_SSL_ACTIVE')
except AirflowConfigException as e:
logging.warning("Celery Executor will run without SSL")

try:
if celery_ssl_active:
BROKER_USE_SSL = {'keyfile': configuration.get('celery', 'CELERY_SSL_KEY'),
'certfile': configuration.get('celery', 'CELERY_SSL_CERT'),
'ca_certs': configuration.get('celery', 'CELERY_SSL_CACERT'),
'cert_reqs': ssl.CERT_REQUIRED}
except ValueError:
raise AirflowException('ValueError: CELERY_SSL_ACTIVE is True, please ensure CELERY_SSL_KEY, '
'CELERY_SSL_CERT and CELERY_SSL_CACERT are set')
except Exception as e:
raise AirflowException('Exception: There was an unknown Celery SSL Error. Please ensure you want to use '
'SSL and/or have all necessary certs and key.')
except AirflowConfigException as e:
raise AirflowException('AirflowConfigException: CELERY_SSL_ACTIVE is True, please ensure CELERY_SSL_KEY, '
'CELERY_SSL_CERT and CELERY_SSL_CACERT are set')
except Exception as e:
raise AirflowException('Exception: There was an unknown Celery SSL Error. Please ensure you want to use '
'SSL and/or have all necessary certs and key.')

app = Celery(
configuration.get('celery', 'CELERY_APP_NAME'),
Expand Down

0 comments on commit d02e8eb

Please sign in to comment.