Skip to content

Commit f30ee5b

Browse files
authored
Hide unlimited quotas if they have associated Coral credits limit (#470)
Stop confusing users with both coral credits, and unlimited regular quotas.
1 parent e2702a0 commit f30ee5b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

api/azimuth/provider/dto.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import enum
66
from collections.abc import Mapping, Sequence
7-
from dataclasses import dataclass
7+
from dataclasses import dataclass, field
88
from datetime import datetime
99

1010

@@ -80,6 +80,9 @@ class Quota:
8080
used: int
8181
#: Category of quota for filtering in UI
8282
quota_type: QuotaType
83+
#: Openstack resource classes associated with the Coral credits quota which
84+
#: this quota is also controlled by
85+
related_resource_names: list = field(default_factory=list)
8386

8487

8588
@dataclass(frozen=True)

api/azimuth/provider/openstack/provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def quotas(self):
343343
compute_limits.total_cores,
344344
compute_limits.total_cores_used,
345345
dto.QuotaType.COMPUTE,
346+
related_resource_names=["VCPU", "PCPU"],
346347
),
347348
dto.Quota(
348349
"ram",
@@ -351,6 +352,7 @@ def quotas(self):
351352
compute_limits.total_ram,
352353
compute_limits.total_ram_used,
353354
dto.QuotaType.COMPUTE,
355+
related_resource_names=["MEMORY_MB"],
354356
),
355357
dto.Quota(
356358
"machines",

ui/src/components/pages/tenancy/quotas.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ const Quotas = ({ resourceData }) => {
7171
return [index >= 0 ? index : quotaOrdering.length, q.resource];
7272
}
7373
);
74+
7475
const containsCoralQuotas = sortedQuotas.some(q => q.quota_type == "CORAL_CREDITS")
76+
77+
// If quota is unlimited but has an associated Coral quota, hide it
78+
const resourceNames = sortedQuotas.map((q) => q.resource)
79+
sortedQuotas = sortedQuotas.filter((q) =>
80+
!(q.related_resource_names.some(r => resourceNames.includes(r))
81+
&& q.allocated < 0)
82+
)
83+
7584
return (
7685
// The volume service is optional, so quotas might not always be available for it
7786
<Row className="g-3 justify-content-center">

0 commit comments

Comments
 (0)