|
23 | 23 | from api.models.release import Release |
24 | 24 | from api.models.config import Config |
25 | 25 | from api.models.domain import Domain |
| 26 | +from api.models.appsettings import AppSettings |
26 | 27 |
|
27 | 28 | from scheduler import KubeHTTPException, KubeException |
28 | 29 |
|
@@ -178,7 +179,7 @@ def log(self, message, level=logging.INFO): |
178 | 179 |
|
179 | 180 | def create(self, *args, **kwargs): # noqa |
180 | 181 | """ |
181 | | - Create a application with an initial config, release, domain |
| 182 | + Create a application with an initial config, settings, release, domain |
182 | 183 | and k8s resource if needed |
183 | 184 | """ |
184 | 185 | try: |
@@ -220,6 +221,10 @@ def create(self, *args, **kwargs): # noqa |
220 | 221 |
|
221 | 222 | raise ServiceUnavailable('Kubernetes resources could not be created') from e |
222 | 223 |
|
| 224 | + try: |
| 225 | + self.appsettings_set.latest() |
| 226 | + except AppSettings.DoesNotExist: |
| 227 | + AppSettings.objects.create(owner=self.owner, app=self) |
223 | 228 | # Attach the platform specific application sub domain to the k8s service |
224 | 229 | # Only attach it on first release in case a customer has remove the app domain |
225 | 230 | if rel.version == 1 and not Domain.objects.filter(domain=self.id).exists(): |
@@ -389,6 +394,7 @@ def scale(self, user, structure): # noqa |
389 | 394 |
|
390 | 395 | def _scale_pods(self, scale_types): |
391 | 396 | release = self.release_set.latest() |
| 397 | + app_settings = self.appsettings_set.latest() |
392 | 398 | version = "v{}".format(release.version) |
393 | 399 | image = release.image |
394 | 400 | envs = self._build_env_vars(release.build.type, version, image, release.config.values) |
@@ -424,6 +430,7 @@ def _scale_pods(self, scale_types): |
424 | 430 | 'app_type': scale_type, |
425 | 431 | 'build_type': release.build.type, |
426 | 432 | 'healthcheck': healthcheck, |
| 433 | + 'annotations': {'maintenance': app_settings.maintenance}, |
427 | 434 | 'routable': routable, |
428 | 435 | 'deploy_batches': batches, |
429 | 436 | 'deploy_timeout': deploy_timeout, |
@@ -461,6 +468,8 @@ def deploy(self, release, force_deploy=False): |
461 | 468 | if release.build is None: |
462 | 469 | raise DeisException('No build associated with this release') |
463 | 470 |
|
| 471 | + app_settings = self.appsettings_set.latest() |
| 472 | + |
464 | 473 | # use create to make sure minimum resources are created |
465 | 474 | self.create() |
466 | 475 |
|
@@ -509,6 +518,7 @@ def deploy(self, release, force_deploy=False): |
509 | 518 | 'build_type': release.build.type, |
510 | 519 | 'healthcheck': healthcheck, |
511 | 520 | 'routable': routable, |
| 521 | + 'annotations': {'maintenance': app_settings.maintenance}, |
512 | 522 | 'deploy_batches': batches, |
513 | 523 | 'deploy_timeout': deploy_timeout, |
514 | 524 | 'deployment_history_limit': deployment_history, |
|
0 commit comments