Skip to content

Commit c864534

Browse files
author
lijianguo
committed
feat(controller):drycc run cmd add --mount para
1 parent 8faa5dc commit c864534

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

rootfs/api/models/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ def deploy(self, release, force_deploy=False, rollback_on_failure=True): # noqa
583583
volumes = self.volume_set.all()
584584
deploys = {}
585585
for scale_type, replicas in self.structure.items():
586-
volumes = [_ for _ in volumes if scale_type in _.path.keys()]
587-
deploys[scale_type] = self._gather_app_settings(release, app_settings, scale_type, replicas, volumes=volumes) # noqa
586+
scale_type_volumes = [_ for _ in volumes if scale_type in _.path.keys()]
587+
deploys[scale_type] = self._gather_app_settings(release, app_settings, scale_type, replicas, volumes=scale_type_volumes) # noqa
588588

589589
# Sort deploys so routable comes first
590590
deploys = OrderedDict(sorted(deploys.items(), key=lambda d: d[1].get('routable')))
@@ -823,7 +823,7 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits):
823823
if volumes:
824824
volume_objs = Volume.objects.filter(app=release.app, name__in=volumes.keys())
825825
for _ in volume_objs:
826-
_.path["{}-{}".format(self.app.id, str(uuid.uuid4())[:7])] = volumes.get(_.name, None) # noqa
826+
_.path["run"] = volumes.get(_.name, None) # noqa
827827
volume_list.append(_)
828828
data = self._gather_app_settings(release, app_settings, process_type='run', replicas=1, volumes=volume_list) # noqa
829829

rootfs/scheduler/resources/deployment.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,6 @@ 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-
# set volumes
111-
if volumes:
112-
exist_volumes = manifest['spec']['template']['spec'].get("volumes", []) # noqa
113-
for volume in volumes:
114-
exist_volumes.append(
115-
{"name": volume.get('name'),
116-
"persistentVolumeClaim": {
117-
"claimName": volume.get('claimName')
118-
}})
119-
manifest['spec']['template']['spec']['volumes'] = exist_volumes
120-
121-
return manifest
122-
123110
def create(self, namespace, name, image, entrypoint, command, spec_annotations, **kwargs):
124111
manifest = self.manifest(namespace, name, image,
125112
entrypoint, command, spec_annotations, **kwargs)

rootfs/scheduler/resources/pod.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def state(self, pod):
9999
def manifest(self, namespace, name, image, **kwargs):
100100
app_type = kwargs.get('app_type')
101101
build_type = kwargs.get('build_type')
102+
volumes = kwargs.get('volumes')
102103

103104
# labels that represent the pod(s)
104105
labels = {
@@ -147,7 +148,15 @@ def manifest(self, namespace, name, image, **kwargs):
147148
'mountPath': '/var/run/secrets/drycc/objectstore/creds',
148149
'readOnly': True
149150
}]
150-
151+
if volumes:
152+
exist_volumes = spec.get('volumes', [])
153+
for volume in volumes:
154+
exist_volumes.append(
155+
{"name": volume.get('name'),
156+
"persistentVolumeClaim": {
157+
"claimName": volume.get('claimName')
158+
}})
159+
spec['volumes'] = exist_volumes
151160
# create the base container
152161
container = {}
153162

0 commit comments

Comments
 (0)