Skip to content

Commit ff11510

Browse files
committed
fix(controller): manifest error
1 parent 050185d commit ff11510

29 files changed

Lines changed: 1649 additions & 943 deletions

.woodpecker/manifest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pipeline:
2323
-e PLUGIN_SPEC=.woodpecker/manifest.tmpl
2424
-e PLUGIN_USERNAME=$CONTAINER_USERNAME
2525
-e PLUGIN_PASSWORD=$CONTAINER_PASSWORD
26+
-e DRONE_TAG=$CI_COMMIT_TAG
2627
-v $(pwd):$(pwd)
2728
-w $(pwd)
2829
plugins/manifest

charts/controller/templates/controller-certificate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: Certificate
44
metadata:
55
name: drycc-controller
66
spec:
7-
secretName: drycc-controller-certificate-auto
7+
secretName: drycc-controller-auto-tls
88
issuerRef:
99
name: drycc-cluster-issuer
1010
kind: ClusterIssuer

charts/controller/templates/controller-ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
number: 80
3131
{{- if .Values.global.certManagerEnabled }}
3232
tls:
33-
- secretName: drycc-controller-certificate-auto
33+
- secretName: drycc-controller-auto-tls
3434
hosts:
3535
- drycc.{{ .Values.global.platformDomain }}
3636
{{- end }}

rootfs/api/migrations/0001_initial.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ class Migration(migrations.Migration):
204204
('updated', models.DateTimeField(auto_now=True)),
205205
('port', models.PositiveIntegerField(default=5000)),
206206
('protocol', models.TextField(default='TCP')),
207-
('target_port', models.PositiveIntegerField(default=5000)),
208-
('service_type', models.TextField()),
209207
('procfile_type', models.TextField()),
210208
('app', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.app')),
211209
('owner', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
@@ -282,7 +280,6 @@ class Migration(migrations.Migration):
282280
('created', models.DateTimeField(auto_now_add=True)),
283281
('updated', models.DateTimeField(auto_now=True)),
284282
('routable', models.BooleanField(null=True)),
285-
('allowlist', models.JSONField(default=None, null=True)),
286283
('autoscale', models.JSONField(blank=True, default=dict)),
287284
('label', models.JSONField(blank=True, default=dict)),
288285
('app', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.app')),

rootfs/api/models/app.py

Lines changed: 309 additions & 408 deletions
Large diffs are not rendered by default.

rootfs/api/models/appsettings.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class AppSettings(UuidAuditedModel):
1818

1919
owner = models.ForeignKey(User, on_delete=models.PROTECT)
2020
app = models.ForeignKey('App', on_delete=models.CASCADE)
21-
routable = models.BooleanField(null=True)
22-
# the default values is None to differentiate from user sending an empty allowlist
23-
# and user just updating other fields meaning the values needs to be copied from prev release
24-
allowlist = models.JSONField(default=None, null=True)
21+
routable = models.BooleanField(default=True)
2522
autoscale = models.JSONField(default=dict, blank=True)
2623
label = models.JSONField(default=dict, blank=True)
2724

@@ -37,15 +34,11 @@ def __init__(self, *args, **kwargs):
3734
def __str__(self):
3835
return "{}-{}".format(self.app.id, str(self.uuid)[:7])
3936

40-
def new(self, user, allowlist):
37+
def new(self, user):
4138
"""
42-
Create a new application appSettings using the provided allowlist
43-
on behalf of a user.
39+
Create a new application appSettings on behalf of a user.
4440
"""
45-
46-
app_settings = AppSettings.objects.create(
47-
owner=user, app=self.app, allowlist=allowlist)
48-
41+
app_settings = AppSettings.objects.create(owner=user, app=self.app)
4942
return app_settings
5043

5144
def _update_routable(self, previous_settings):
@@ -54,35 +47,12 @@ def _update_routable(self, previous_settings):
5447
# If no previous settings then assume it is the first record and default to true
5548
if previous_settings is None:
5649
setattr(self, 'routable', True)
57-
self.app.routable(True)
5850
# if nothing changed copy the settings from previous
5951
elif new is None and old is not None:
6052
setattr(self, 'routable', old)
6153
elif old != new:
62-
self.app.routable(new)
6354
self.summary += ["{} changed routablity from {} to {}".format(self.owner, old, new)]
6455

65-
def _update_allowlist(self, previous_settings):
66-
# If no previous settings then assume it is the first record and set as empty
67-
# to prevent from database constraint violation
68-
if not previous_settings:
69-
setattr(self, 'allowlist', [])
70-
old = getattr(previous_settings, 'allowlist', [])
71-
new = getattr(self, 'allowlist', None)
72-
# if nothing changed copy the settings from previous
73-
if new is None and old is not None:
74-
setattr(self, 'allowlist', old)
75-
elif set(old) != set(new):
76-
added = ', '.join(k for k in set(new)-set(old))
77-
added = 'added ' + added if added else ''
78-
deleted = ', '.join(k for k in set(old)-set(new))
79-
deleted = 'deleted ' + deleted if deleted else ''
80-
changes = ', '.join(i for i in (added, deleted) if i)
81-
if changes:
82-
if self.summary:
83-
self.summary += ' and '
84-
self.summary += "{} {}".format(self.owner, changes)
85-
8656
def _update_autoscale(self, previous_settings):
8757
data = getattr(previous_settings, 'autoscale', {}).copy()
8858
new = getattr(self, 'autoscale', {}).copy()
@@ -165,7 +135,6 @@ def save(self, *args, **kwargs):
165135

166136
try:
167137
self._update_routable(previous_settings)
168-
self._update_allowlist(previous_settings)
169138
self._update_autoscale(previous_settings)
170139
self._update_label(previous_settings)
171140
except (UnprocessableEntity, NotFound):
@@ -180,4 +149,3 @@ def save(self, *args, **kwargs):
180149
summary = ' '.join(self.summary)
181150
self.app.log('summary of app setting changes: {}'.format(summary), logging.DEBUG)
182151
super(AppSettings, self).save(**kwargs)
183-
self.app.refresh()

rootfs/api/models/base.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import uuid
2-
import morph
32
import importlib
43
from django.db import models
54
from django.conf import settings
65
from django.contrib.auth.models import AbstractUser
76
from django.utils.translation import gettext_lazy as _
8-
from scheduler.exceptions import KubeException
9-
from api.exceptions import ServiceUnavailable
10-
from api.utils import dict_merge
117

128

139
def get_anonymous_user_instance(user): return user(id=-1, username=settings.ANONYMOUS_USER_NAME)
@@ -29,58 +25,6 @@ def _scheduler(cls):
2925
mod = importlib.import_module(settings.SCHEDULER_MODULE)
3026
return mod.SchedulerClient(settings.SCHEDULER_URL, settings.K8S_API_VERIFY_TLS)
3127

32-
def _fetch_service_config(self, app, svc_name=None):
33-
try:
34-
# Get the service from k8s to attach the domain correctly
35-
if svc_name is None:
36-
svc_name = app
37-
svc = self._scheduler.svc.get(app, svc_name).json()
38-
except KubeException as e:
39-
raise ServiceUnavailable('Could not fetch Kubernetes Service {}'.format(app)) from e
40-
41-
# Get minimum structure going if it is missing on the service
42-
if 'metadata' not in svc or 'annotations' not in svc['metadata']:
43-
default = {'metadata': {'annotations': {}}}
44-
svc = dict_merge(svc, default)
45-
46-
if 'labels' not in svc['metadata']:
47-
default = {'metadata': {'labels': {}}}
48-
svc = dict_merge(svc, default)
49-
50-
return svc
51-
52-
def _load_service_config(self, app, component, svc_name=None):
53-
# fetch setvice definition with minimum structure
54-
svc = self._fetch_service_config(app, svc_name)
55-
56-
# always assume a .drycc.cc/ ending
57-
component = "%s.drycc.cc/" % component
58-
59-
# Filter to only include values for the component and strip component out of it
60-
# Processes dots into a nested structure
61-
config = morph.unflatten(morph.pick(svc['metadata']['annotations'], prefix=component))
62-
63-
return config
64-
65-
def _save_service_config(self, app, component, data, svc_name=None):
66-
if svc_name is None:
67-
svc_name = app
68-
# fetch setvice definition with minimum structure
69-
svc = self._fetch_service_config(app, svc_name)
70-
71-
# always assume a .drycc.cc ending
72-
component = "%s.drycc.cc/" % component
73-
74-
# add component to data and flatten
75-
data = {"%s%s" % (component, key): value for key, value in list(data.items()) if value}
76-
svc['metadata']['annotations'].update(morph.flatten(data))
77-
78-
# Update the k8s service for the application with new service information
79-
try:
80-
self._scheduler.svc.update(app, svc_name, svc)
81-
except KubeException as e:
82-
raise ServiceUnavailable('Could not update Kubernetes Service {}'.format(app)) from e
83-
8428

8529
class UuidAuditedModel(AuditedModel):
8630
"""Add a UUID primary key to an :class:`AuditedModel`."""

rootfs/api/models/domain.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ class Meta:
2828
@transaction.atomic
2929
def save(self, *args, **kwargs):
3030
super(Domain, self).save(*args, **kwargs)
31-
self.app.refresh()
3231

3332
@transaction.atomic
3433
def delete(self, *args, **kwargs):
3534
# Deatch cert, updates k8s
3635
if self.certificate:
3736
self.certificate.detach(domain=str(self.domain))
3837
super(Domain, self).delete(*args, **kwargs)
39-
self.app.refresh()
4038

4139
def __str__(self):
4240
return self.domain

0 commit comments

Comments
 (0)