@@ -121,9 +121,29 @@ class AirflowConfigParser(ConfigParser):
121
121
('core' , 'sql_alchemy_conn' ),
122
122
('core' , 'fernet_key' ),
123
123
('celery' , 'broker_url' ),
124
- ('celery' , 'result_backend' )
124
+ ('celery' , 'result_backend' ),
125
+ # Todo: remove this in Airflow 1.11
126
+ ('celery' , 'celery_result_backend' ),
125
127
}
126
128
129
+ # A two-level mapping of (section -> new_name -> old_name). When reading
130
+ # new_name, the old_name will be checked to see if it exists. If it does a
131
+ # DeprecationWarning will be issued and the old name will be used instead
132
+ deprecated_options = {
133
+ 'celery' : {
134
+ # Remove these keys in Airflow 1.11
135
+ 'worker_concurrency' : 'celeryd_concurrency' ,
136
+ 'broker_url' : 'celery_broker_url' ,
137
+ 'ssl_active' : 'celery_ssl_active' ,
138
+ 'ssl_cert' : 'celery_ssl_cert' ,
139
+ 'ssl_key' : 'celery_ssl_key' ,
140
+ }
141
+ }
142
+ deprecation_format_string = (
143
+ 'The {old} option in [{section}] has been renamed to {new} - the old '
144
+ 'setting has been used, but please update your config.'
145
+ )
146
+
127
147
def __init__ (self , default_config = None , * args , ** kwargs ):
128
148
super (AirflowConfigParser , self ).__init__ (* args , ** kwargs )
129
149
@@ -181,22 +201,42 @@ def get(self, section, key, **kwargs):
181
201
section = str (section ).lower ()
182
202
key = str (key ).lower ()
183
203
204
+ deprecated_name = self .deprecated_options .get (section , {}).get (key , None )
205
+
184
206
# first check environment variables
185
207
option = self ._get_env_var_option (section , key )
186
208
if option is not None :
187
209
return option
210
+ if deprecated_name :
211
+ option = self ._get_env_var_option (section , deprecated_name )
212
+ if option is not None :
213
+ self ._warn_deprecate (section , key , deprecated_name )
214
+ return option
188
215
189
216
# ...then the config file
190
217
if super (AirflowConfigParser , self ).has_option (section , key ):
191
218
# Use the parent's methods to get the actual config here to be able to
192
219
# separate the config from default config.
193
220
return expand_env_var (
194
221
super (AirflowConfigParser , self ).get (section , key , ** kwargs ))
222
+ if deprecated_name :
223
+ if super (AirflowConfigParser , self ).has_option (section , deprecated_name ):
224
+ self ._warn_deprecate (section , key , deprecated_name )
225
+ return expand_env_var (super (AirflowConfigParser , self ).get (
226
+ section ,
227
+ deprecated_name ,
228
+ ** kwargs
229
+ ))
195
230
196
231
# ...then commands
197
232
option = self ._get_cmd_option (section , key )
198
233
if option :
199
234
return option
235
+ if deprecated_name :
236
+ option = self ._get_cmd_option (section , deprecated_name )
237
+ if option :
238
+ self ._warn_deprecate (section , key , deprecated_name )
239
+ return option
200
240
201
241
# ...then the default config
202
242
if self .defaults .has_option (section , key ):
@@ -352,6 +392,17 @@ def load_test_config(self):
352
392
# then read any "custom" test settings
353
393
self .read (TEST_CONFIG_FILE )
354
394
395
+ def _warn_deprecate (self , section , key , deprecated_name ):
396
+ warnings .warn (
397
+ self .deprecation_format_string .format (
398
+ old = deprecated_name ,
399
+ new = key ,
400
+ section = section ,
401
+ ),
402
+ DeprecationWarning ,
403
+ stacklevel = 3 ,
404
+ )
405
+
355
406
356
407
def mkdir_p (path ):
357
408
try :
0 commit comments