Skip to content

Commit f5363a9

Browse files
authored
Merge pull request #136 from Cryptophobia/master
feat(HPAs): resolves #135 recreate HPAs from db on load
2 parents 9346813 + 0440e56 commit f5363a9

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# If DEIS_REGISTRY is not set, try to populate it from legacy DEV_REGISTRY
22
DEIS_REGISTRY ?= $(DEV_REGISTRY)
3-
IMAGE_PREFIX ?= deis
3+
IMAGE_PREFIX ?= hephy
44
COMPONENT ?= controller
55
SHORT_NAME ?= $(COMPONENT)
66

rootfs/api/management/commands/healthchecks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
class Command(BaseCommand):
77
"""Management command for healthchecks"""
8+
89
def handle(self, *args, **options):
910
"""Ensure DB and other things are alive"""
1011
print("Checking if database is alive")

rootfs/api/management/commands/load_db_state_to_k8s.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from django.core.management.base import BaseCommand
22
from django.shortcuts import get_object_or_404
33

4-
from api.models import Key, App, Domain, Certificate, Service
4+
from api.models import Key, App, AppSettings, Domain, Certificate, Service
55
from api.exceptions import DeisException, AlreadyExists
66

77

88
class Command(BaseCommand):
99
"""Management command for publishing Deis platform state from the database
1010
to k8s.
1111
"""
12+
1213
def handle(self, *args, **options):
1314
"""Publishes Deis platform state from the database to kubernetes."""
1415
print("Publishing DB state to kubernetes...")
@@ -40,6 +41,16 @@ def handle(self, *args, **options):
4041
print('ERROR: There was a problem deploying {} '
4142
'due to {}'.format(application, str(error)))
4243

44+
# deploy autoscaling HPAs for application
45+
appsettings = AppSettings.objects.filter(app=application).order_by('-created')[0]
46+
if appsettings.autoscale:
47+
try:
48+
for proc_type in application.structure:
49+
application.autoscale(proc_type, appsettings.autoscale[proc_type])
50+
except Exception as error:
51+
print('ERROR: There was a problem deploying HPAs for this {} proc_type '
52+
'of {} app due to error: {}'.format(proc_type, application, error))
53+
4354
print("Done Publishing DB state to kubernetes.")
4455

4556
def save_apps(self):

0 commit comments

Comments
 (0)