Skip to content

Commit

Permalink
fix(config): when rolling a new config copy from the latest release i…
Browse files Browse the repository at this point in the history
…nstead of latest config for the app

This helps mitigate deis#798 for day to day use (quick fix) as the previous config is no longer pulled from the top of the application config stack and instead pulls the latest release config.
Doing that will prevent the logic from re-using a potentially broken Config object. When a Release object is deleted an Config object can be orphaned but still available.
  • Loading branch information
helgi committed Jun 9, 2016
1 parent 9d98a79 commit 5fb1bbb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rootfs/api/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5fb1bbb

Please sign in to comment.