Skip to content

Commit 803da90

Browse files
committed
chore(release): check deploy release ptypes
1 parent 1eee52a commit 803da90

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

rootfs/api/models/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def save(self, *args, **kwargs):
151151
def ptypes(self):
152152
return list(self.structure.keys())
153153

154-
def check_ptypes(self, ptypes):
154+
def check_ptypes(self, ptypes: set):
155155
"""
156156
check available procfile types
157157
"""

rootfs/api/models/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def save(self, **kwargs):
131131
)
132132

133133
# spin down any proc type removed between the last procfile and the newest one
134-
if remove_procs and previous_release.build is not None:
134+
if remove_procs and previous_release.build is not None and \
135+
self.app.appsettings_set.latest().autodeploy:
135136
removed = {}
136137
for proc in previous_release.ptypes:
137138
if proc not in self.ptypes and self.app.structure.get(proc, 0) > 0:

rootfs/api/views.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,17 @@ def get_object(self, **kwargs):
620620
def deploy(self, request, **kwargs):
621621
"""Deploy the latest release"""
622622
latest_release = self.get_app().release_set.latest()
623+
623624
force_deploy = request.data.get("force", False)
624625
ptypes = set(
625626
[ptype for ptype in request.data.get("ptypes", "").split(",") if ptype])
626-
ptypes = latest_release.app.check_ptypes(ptypes)
627+
if not ptypes:
628+
ptypes = latest_release.ptypes
629+
else:
630+
invalid_ptypes = ptypes.difference(
631+
latest_release.ptypes + [d["name"] for d in self.get_app().list_deployments()])
632+
if len(invalid_ptypes) != 0:
633+
raise DryccException(f"process type {','.join(invalid_ptypes)} is not exists")
627634
latest_release.deploy(ptypes, force_deploy)
628635
return Response(status=status.HTTP_204_NO_CONTENT)
629636

0 commit comments

Comments
 (0)