Skip to content

Commit d04fb84

Browse files
authored
fix(controller): list_deployments status info error
1 parent 180ad9b commit d04fb84

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

rootfs/api/models/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ def list_deployments(self, *args, **kwargs):
484484
'name': labels['type'],
485485
'release': labels['version'],
486486
'ready': "%s/%s" % (
487-
p["status"]["readyReplicas"],
488-
p["status"]["replicas"],
487+
p["status"].get("readyReplicas", 0),
488+
p["status"].get("replicas", 0),
489489
),
490-
'up_to_date': p["status"]["updatedReplicas"],
491-
'available_replicas': p["status"]["availableReplicas"],
490+
'up_to_date': p["status"].get("updatedReplicas", 0),
491+
'available_replicas': p["status"].get("availableReplicas", 0),
492492
'started': started
493493
}
494494
data.append(item)

rootfs/api/tests/test_pods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_release(self, mock_requests):
259259
# describe no exists pod
260260
pod_name = "no-exists-pod-name"
261261
response = self.client.get(f"/v2/apps/{app_id}/pods/{pod_name}/describe/")
262-
self.assertEqual(response.status_code, 404, response.data)
262+
self.assertEqual(response.status_code, 400, response.data)
263263

264264
def test_container_errors(self, mock_requests):
265265
app_id = self.create_app()

rootfs/api/tests/test_ptypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_ptype(self, mock_requests):
7373

7474
ptype_name = "no-exists-ptype-name"
7575
response = self.client.get(f"/v2/apps/{app_id}/ptypes/{ptype_name}/describe/")
76-
self.assertEqual(response.status_code, 404, response.data)
76+
self.assertEqual(response.status_code, 400, response.data)
7777

7878
def test_restart_ptypes(self, mock_requests):
7979
app_id = self.create_app()

rootfs/api/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def describe(self, *args, **kwargs):
437437
pod_name = kwargs["name"]
438438
data = self.get_object().describe_pod(pod_name)
439439
if len(data) == 0:
440-
return Response(status=status.HTTP_404_NOT_FOUND)
440+
raise DryccException("this process not found")
441441
# fake out pagination for now
442442
pagination = {'results': data, 'count': len(data)}
443443
return Response(pagination, status=status.HTTP_200_OK)
@@ -468,7 +468,7 @@ def describe(self, *args, **kwargs):
468468
deployment_name = kwargs["name"]
469469
data = self.get_object().describe_deployment(deployment_name)
470470
if len(data) == 0:
471-
return Response(status=status.HTTP_404_NOT_FOUND)
471+
raise DryccException("this ptype not found")
472472
# fake out pagination for now
473473
pagination = {'results': data, 'count': len(data)}
474474
return Response(pagination, status=status.HTTP_200_OK)

0 commit comments

Comments
 (0)