|
1 | | -from collections import defaultdict |
2 | 1 | from datetime import datetime, timedelta, timezone |
3 | 2 | import operator |
4 | 3 | import os |
@@ -236,8 +235,8 @@ def _set_container(self, namespace, container_name, data, **kwargs): |
236 | 235 | self._set_container_default_env(data) |
237 | 236 | # list sorted by dict key name |
238 | 237 | data['env'].sort(key=operator.itemgetter('name')) |
| 238 | + data['lifecycle'] = data.get('lifecycle', {}) |
239 | 239 | self._set_health_checks(data, env, **kwargs) |
240 | | - self._set_lifecycle_hooks(data, env, **kwargs) |
241 | 240 |
|
242 | 241 | def _set_container_default_env(self, data): |
243 | 242 | # set fields env |
@@ -286,38 +285,6 @@ def _set_health_checks(self, container, env, **kwargs): |
286 | 285 | container.update( |
287 | 286 | self._default_container_readiness_probe(env.get('PORT', DEFAULT_CONTAINER_PORT))) |
288 | 287 |
|
289 | | - @staticmethod |
290 | | - def _set_lifecycle_hooks(container, env, **kwargs): |
291 | | - app_type = kwargs.get("app_type") |
292 | | - lifecycle_post_start = kwargs.get('lifecycle_post_start', {}) |
293 | | - lifecycle_post_start = lifecycle_post_start.get(app_type) |
294 | | - lifecycle_pre_stop = kwargs.get('lifecycle_pre_stop', {}) |
295 | | - lifecycle_pre_stop = lifecycle_pre_stop.get(app_type) |
296 | | - if lifecycle_post_start or lifecycle_pre_stop: |
297 | | - lifecycle = defaultdict(dict) |
298 | | - |
299 | | - if lifecycle_post_start: |
300 | | - lifecycle["postStart"] = { |
301 | | - 'exec': { |
302 | | - "command": [ |
303 | | - "/bin/bash", |
304 | | - "-c", |
305 | | - "{0}".format(lifecycle_post_start) |
306 | | - ] |
307 | | - } |
308 | | - } |
309 | | - if lifecycle_pre_stop: |
310 | | - lifecycle["preStop"] = { |
311 | | - 'exec': { |
312 | | - "command": [ |
313 | | - "/bin/bash", |
314 | | - "-c", |
315 | | - "{0}".format(lifecycle_pre_stop) |
316 | | - ] |
317 | | - } |
318 | | - } |
319 | | - container["lifecycle"] = dict(lifecycle) |
320 | | - |
321 | 288 | @staticmethod |
322 | 289 | def _default_container_readiness_probe(port, delay=5, timeout=5, period_seconds=5, |
323 | 290 | success_threshold=1, failure_threshold=1): |
|
0 commit comments