diff --git a/rootfs/api/models/config.py b/rootfs/api/models/config.py index 1294bb94c..ae6f45081 100644 --- a/rootfs/api/models/config.py +++ b/rootfs/api/models/config.py @@ -2,6 +2,7 @@ from django.db import models from jsonfield import JSONField +from api.models.release import Release from api.models import UuidAuditedModel, DeisException @@ -110,7 +111,14 @@ def set_tags(self, previous_config): def save(self, **kwargs): """merge the old config with the new""" try: - previous_config = self.app.config_set.latest() + # Get config from the latest available release + try: + previous_config = self.app.release_set.latest().config + except Release.DoesNotExist: + # If that doesn't exist then fallback on app config + # usually means a totally new app + previous_config = self.app.config_set.latest() + for attr in ['cpu', 'memory', 'tags', 'registry', 'values']: data = getattr(previous_config, attr, {}).copy() new_data = getattr(self, attr, {}).copy()