diff --git a/rootfs/api/models/app.py b/rootfs/api/models/app.py index ecb0bb4c..60b5538c 100644 --- a/rootfs/api/models/app.py +++ b/rootfs/api/models/app.py @@ -923,6 +923,7 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits): def list_pods(self, *args, **kwargs): """Used to list basic information about pods running for a given application""" + autoscale = self.appsettings_set.latest().autoscale try: labels = self._scheduler_filter(**kwargs) @@ -935,7 +936,6 @@ def list_pods(self, *args, **kwargs): pods = [] data = [] - exist_pod_type = [] for p in pods: labels = p['metadata']['labels'] # specifically ignore run pods @@ -962,9 +962,9 @@ def list_pods(self, *args, **kwargs): else: started = str(datetime.utcnow().strftime(settings.DRYCC_DATETIME_FORMAT)) item['started'] = started - item['replicas'] = self.structure.get(labels['type']) - if labels['type'] not in exist_pod_type: - exist_pod_type.append(labels['type']) + replicas = str(autoscale[labels['type']]['min']) + '-' + str(autoscale[labels['type']]['max']) \ + if autoscale.get(labels['type']) is not None else self.structure.get(labels['type']) # noqa + item['replicas'] = str(replicas) data.append(item) # sorting so latest start date is first diff --git a/rootfs/api/serializers.py b/rootfs/api/serializers.py index a40e5308..1802b99b 100644 --- a/rootfs/api/serializers.py +++ b/rootfs/api/serializers.py @@ -574,7 +574,7 @@ class PodSerializer(serializers.BaseSerializer): type = serializers.CharField() release = serializers.CharField(required=False) started = serializers.DateTimeField(required=False) - replicas = serializers.IntegerField(required=False) + replicas = serializers.CharField(required=False) def to_representation(self, obj): return obj diff --git a/rootfs/api/views.py b/rootfs/api/views.py index cd3ca8f1..4db563b6 100644 --- a/rootfs/api/views.py +++ b/rootfs/api/views.py @@ -342,18 +342,23 @@ def list(self, *args, **kwargs): data = self.get_serializer(pods, many=True).data if not kwargs.get("type"): + autoscale = self.get_app().appsettings_set.latest().autoscale exist_pod_type = list(set([_["type"] for _ in data if _["type"]])) - for _ in self.get_app().structure.keys(): + structure = self.get_app().structure + procfile_structure = self.get_app().procfile_structure + for _ in structure.keys(): if _ not in exist_pod_type: + replicas = str(autoscale[_]['min']) + '-' + str(autoscale[_]['max']) \ + if (autoscale.get(_) is not None and structure[_] !=0) else structure[_] # noqa exist_pod_type.append(_) data.append({"type": _, - "replicas": self.get_app().structure[_], + "replicas": str(replicas), "state": "stopped"}) - for _ in self.get_app().procfile_structure.keys(): + for _ in procfile_structure: if _ not in exist_pod_type: data.append({"type": _, - "replicas": 0, + "replicas": str(0), "state": "started"}) # # fake out pagination for now