Skip to content

Commit 3206ac0

Browse files
author
lijianguo
committed
chore(controller):check mount volume path
1 parent c864534 commit 3206ac0

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

rootfs/api/models/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import requests
1212
import string
1313
import time
14-
import uuid
1514
from urllib.parse import urljoin
1615

1716
from django.conf import settings

rootfs/api/views.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,22 @@ def path(self, request, *args, **kwargs):
669669
if container_types:
670670
raise DryccException("process type {} is not included in profile".
671671
format(','.join(container_types)))
672+
673+
if set(new_path.items()).issubset(set(obj.path.items())):
674+
raise DryccException("mount path not changed")
675+
676+
other_volumes = self.get_app().volume_set.exclude(name=obj.name)
677+
type_paths = {} # {'type1':[path1,path2], tyep2:[path3,path4]}
678+
for _ in other_volumes:
679+
for k, v in _.path.items():
680+
if k not in type_paths:
681+
type_paths[k] = [v]
682+
else:
683+
type_paths[k].append(k)
684+
repeat_path = [v for k, v in new_path.items() if v in type_paths.get(k, [])] # noqa
685+
if repeat_path:
686+
raise DryccException("path {} is used by another volume".
687+
format(','.join(repeat_path)))
672688
path = obj.path
673689
pre_path = deepcopy(path)
674690
# merge mount path

rootfs/scheduler/resources/deployment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def manifest(self, namespace, name, image, entrypoint, command, spec_annotations
3434
replicas = kwargs.get('replicas', 0)
3535
batches = kwargs.get('deploy_batches', None)
3636
tags = kwargs.get('tags', {})
37-
volumes = kwargs.get('volumes', [])
37+
3838
labels = {
3939
'app': namespace,
4040
'type': kwargs.get('app_type'),
@@ -107,6 +107,8 @@ def manifest(self, namespace, name, image, entrypoint, command, spec_annotations
107107
# set the old deployment spec annotations on this deployment
108108
manifest['spec']['template']['metadata']['annotations'] = spec_annotations
109109

110+
return manifest
111+
110112
def create(self, namespace, name, image, entrypoint, command, spec_annotations, **kwargs):
111113
manifest = self.manifest(namespace, name, image,
112114
entrypoint, command, spec_annotations, **kwargs)

0 commit comments

Comments
 (0)