Skip to content

Commit 2708c94

Browse files
committed
fix(controller): class property have been deprecated in python 3.11
1 parent 63dc57c commit 2708c94

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

rootfs/api/models/app.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,22 @@ def _get_request_memory(size):
10721072
raise DryccException('Units are represented in Megabytes(M), or Gigabytes (G)')
10731073
return "{num}{unit}".format(num=math.ceil(num), unit=unit)
10741074

1075+
def _get_volumes_and_mounts(self, process_type, volumes):
1076+
k8s_volumes, k8s_volume_mounts = [], []
1077+
if volumes:
1078+
for volume in volumes:
1079+
k8s_volumes.append({
1080+
"name": volume.name,
1081+
"claimName": volume.name
1082+
})
1083+
k8s_volume_mounts.append({
1084+
"name": volume.name,
1085+
"mount_path": volume.path.get(process_type)
1086+
})
1087+
k8s_volumes.extend(json.loads(settings.KUBERNETES_POD_DEFAULT_VOLUMES))
1088+
k8s_volume_mounts.extend(json.loads(settings.KUBERNETES_POD_DEFAULT_VOLUME_MOUNTS))
1089+
return k8s_volumes, k8s_volume_mounts
1090+
10751091
def _gather_app_settings(self, release, app_settings, process_type, replicas, volumes=None):
10761092
"""
10771093
Gathers all required information needed in one easy place for passing into
@@ -1113,17 +1129,7 @@ def _gather_app_settings(self, release, app_settings, process_type, replicas, vo
11131129
healthcheck = config.get_healthcheck().get(process_type, {})
11141130
if not healthcheck and process_type == 'web':
11151131
healthcheck = config.get_healthcheck().get('web', {})
1116-
volumes_info = [{
1117-
"name": _.name,
1118-
"claimName": _.name,
1119-
} for _ in volumes] if volumes else []
1120-
volumes_info.extend(json.loads(settings.KUBERNETES_POD_DEFAULT_VOLUMES))
1121-
volume_mounts_info = [{
1122-
"name": _.name,
1123-
"mount_path": _.path.get(process_type),
1124-
} for _ in volumes] if volumes else []
1125-
volume_mounts_info.extend(json.loads(settings.KUBERNETES_POD_DEFAULT_VOLUME_MOUNTS))
1126-
1132+
volumes, volume_mounts = self._get_volumes_and_mounts(process_type, volumes)
11271133
return {
11281134
'memory': memory,
11291135
'cpu': cpu,
@@ -1151,7 +1157,7 @@ def _gather_app_settings(self, release, app_settings, process_type, replicas, vo
11511157
'pod_termination_grace_period_each': config.termination_grace_period,
11521158
'image_pull_secret_name': image_pull_secret_name,
11531159
'image_pull_policy': image_pull_policy,
1154-
'volumes': volumes_info,
1155-
'volume_mounts': volume_mounts_info,
1160+
'volumes': volumes,
1161+
'volume_mounts': volume_mounts,
11561162
'security_context': json.loads(settings.KUBERNETES_POD_DEFAULT_SECURITY_CONTEXT),
11571163
}

rootfs/api/models/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ class Meta:
1919
"""Mark :class:`AuditedModel` as abstract."""
2020
abstract = True
2121

22-
@classmethod
2322
@property
24-
def _scheduler(cls):
23+
def _scheduler(self):
2524
mod = importlib.import_module(settings.SCHEDULER_MODULE)
2625
return mod.SchedulerClient(settings.SCHEDULER_URL, settings.K8S_API_VERIFY_TLS)
2726

rootfs/api/models/resource.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ def save(self, *args, **kwargs):
3636
# Save to DB
3737
return super(Resource, self).save(*args, **kwargs)
3838

39-
@classmethod
4039
@property
41-
def services(cls):
40+
def services(self):
4241
services = []
43-
for serviceclass in cls._scheduler.svcat.get_serviceclasses().json()["items"]:
42+
for serviceclass in self._scheduler.svcat.get_serviceclasses().json()["items"]:
4443
services.append({
4544
"id": serviceclass["spec"]["externalID"],
4645
"name": serviceclass["spec"]["externalName"],

0 commit comments

Comments
 (0)