Skip to content

Commit ac76c8b

Browse files
authored
[CLI-3745] Use default max ecku to scale limits when not set in CMK response (#3237)
1 parent ef76af7 commit ac76c8b

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

internal/kafka/utils.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ func getCmkClusterIngressAndEgressMbps(currentMaxEcku int32, limits *kafkausagel
8585
ingress, egress := limits.GetIngress(), limits.GetEgress()
8686

8787
// Scale limits by cluster's max eCKU when limits are set per eCKU
88-
if limits.GetMaxEcku() != nil && currentMaxEcku > 0 {
89-
return ingress * currentMaxEcku, egress * currentMaxEcku
88+
if limits.GetMaxEcku() != nil {
89+
if currentMaxEcku > 0 {
90+
return ingress * currentMaxEcku, egress * currentMaxEcku
91+
} else if limits.GetMaxEcku().Value > 0 {
92+
// Use default max ecku when currentMaxEcku is not set
93+
return ingress * limits.GetMaxEcku().Value, egress * limits.GetMaxEcku().Value
94+
}
9095
}
9196

9297
return ingress, egress
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
+----------------------+----------------------------+
2+
| Current | true |
3+
| ID | lkc-with-default-v2-limits |
4+
| Name | kafka-cluster |
5+
| Type | BASIC |
6+
| Ingress Limit (MB/s) | 250 |
7+
| Egress Limit (MB/s) | 750 |
8+
| Storage | 5000 GB |
9+
| Cloud | aws |
10+
| Region | us-west-2 |
11+
| Availability | single-zone |
12+
| Status | UP |
13+
| Endpoint | SASL_SSL://kafka-endpoint |
14+
| REST Endpoint | http://127.0.0.1:1025 |
15+
| Topic Count | 2 |
16+
+----------------------+----------------------------+

test/kafka_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func (s *CLITestSuite) TestKafka() {
103103

104104
{args: "kafka cluster describe lkc-describe-with-ecku-limits", fixture: "kafka/cluster/describe-basic-with-ecku-limits.golden"},
105105
{args: "kafka cluster describe lkc-with-usage-limits-error", fixture: "kafka/cluster/describe-with-usage-limits-error.golden"},
106+
{args: "kafka cluster describe lkc-with-default-v2-limits", fixture: "kafka/cluster/describe-basic-with-default-v2-limits.golden"},
106107

107108
{args: "kafka acl list --cluster lkc-acls", fixture: "kafka/acl/list-cloud.golden"},
108109
{args: "kafka acl list --cluster lkc-acls --all", fixture: "kafka/acl/list-cloud-all.golden"},

test/test-server/kafka_usage_limits_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func handleUsageLimits(t *testing.T) http.HandlerFunc {
4747
// Check for lkc_id query parameter to determine which limits to return
4848
lkcId := r.URL.Query().Get("lkc_id")
4949
switch lkcId {
50-
case "lkc-with-ecku-limits", "lkc-describe-with-ecku-limits":
50+
case "lkc-with-ecku-limits", "lkc-describe-with-ecku-limits", "lkc-with-default-v2-limits":
5151
handleGetUsageLimitsEckuLimits(t)(w, r)
5252
case "lkc-with-usage-limits-error":
5353
handleGetUsageLimitsWithError(t)(w, r)

0 commit comments

Comments
 (0)