Skip to content

[CLI-1884] show total topic count of cluster when run kafka cluster describe/update #1438

Merged
MuweiHe merged 8 commits intomainfrom
CLI-1884-2
Sep 28, 2022
Merged

[CLI-1884] show total topic count of cluster when run kafka cluster describe/update #1438
MuweiHe merged 8 commits intomainfrom
CLI-1884-2

Conversation

@MuweiHe
Copy link
Contributor

@MuweiHe MuweiHe commented Sep 14, 2022

Checklist

  1. [CRUCIAL] Is the change for CP or CCloud functionalities that are already live in prod?
    • yes: ok

What

show total topic count of a cluster in an environment when run kafka cluster describe/update.

References

Test & Review

mhe@C02DV0KVMD6T cli % confluent kafka cluster describe
+-------------------+---------------------------------------------------------+
| ID                | lkc-k86dn6                                              |
| Name              | metrics-2                                               |
| Type              | DEDICATED                                               |
| Ingress           |                                                      50 |
| Egress            |                                                     150 |
| Storage           | Infinite                                                |
| Provider          | aws                                                     |
| Availability      | single-zone                                             |
| Region            | us-west-2                                               |
| Status            | UP                                                      |
| Endpoint          | SASL_SSL://pkc-qpg8d.us-west-2.aws.confluent.cloud:9092 |
| REST Endpoint     | https://pkc-qpg8d.us-west-2.aws.confluent.cloud:443     |
| Cluster Size      |                                                       1 |
| Total Topic Count |                                                       4 |
+-------------------+---------------------------------------------------------+

mhe@C02DV0KVMD6T cli % confluent kafka cluster describe lkc-v77zqz
+---------------+---------------------------------------------------------+
| ID            | lkc-v77zqz                                              |
| Name          | hello                                                   |
| Type          | STANDARD                                                |
| Ingress       |                                                     100 |
| Egress        |                                                     100 |
| Storage       | Infinite                                                |
| Provider      | aws                                                     |
| Availability  | single-zone                                             |
| Region        | us-west-2                                               |
| Status        | UP                                                      |
| Endpoint      | SASL_SSL://pkc-pgq85.us-west-2.aws.confluent.cloud:9092 |
| REST Endpoint | https://pkc-pgq85.us-west-2.aws.confluent.cloud:443     |
| Topic Count   |                                                      13 |
+---------------+---------------------------------------------------------+

mhe@C02DV0KVMD6T cli % confluent kafka cluster describe lkc-6kk97q --environment env-2mdy1  
+---------------+---------------------------------------------------------+
| ID            | lkc-6kk97q                                              |
| Name          | sales092020                                             |
| Type          | BASIC                                                   |
| Ingress       |                                                     100 |
| Egress        |                                                     100 |
| Storage       | 5 TB                                                    |
| Provider      | aws                                                     |
| Availability  | single-zone                                             |
| Region        | us-west-2                                               |
| Status        | UP                                                      |
| Endpoint      | SASL_SSL://pkc-pgq85.us-west-2.aws.confluent.cloud:9092 |
| REST Endpoint | https://pkc-pgq85.us-west-2.aws.confluent.cloud:443     |
| Topic Count   |                                                       1 |
+---------------+---------------------------------------------------------+

@MuweiHe MuweiHe marked this pull request as ready for review September 14, 2022 22:53
@MuweiHe MuweiHe requested a review from a team as a code owner September 14, 2022 22:53
@brianstrauch

Why are we putting this behind the --all flag? Why not show it all of the time? (Also, the --all flag is deprecated so we shouldn't add on to it)

@MuweiHe
Copy link
Contributor Author

MuweiHe commented Sep 14, 2022

Why are we putting this behind the --all flag? Why not show it all of the time? (Also, the --all flag is deprecated so we shouldn't add on to it)

would this be a breaking change? if not and if we don't mind the time consumed on one extra rest call, then sure we can show it all the time

@MuweiHe MuweiHe changed the title [CLI-1884] show total topic count of active cluster when run kafka cluster describe --all [CLI-1884] show total topic count of active cluster when run kafka cluster describe Sep 15, 2022
@MuweiHe
Copy link
Contributor Author

MuweiHe commented Sep 15, 2022

Why are we putting this behind the --all flag? Why not show it all of the time? (Also, the --all flag is deprecated so we shouldn't add on to it)

Updated to always print topic count.

func (c *clusterCommand) getTotalTopicCountForKafkaCluster(cluster *cmkv2.CmkV2Cluster) (int32, error) {
lkc := *cluster.Id
if kafkaREST, _ := c.GetKafkaREST(); kafkaREST != nil {
topicGetResp, httpResp, err := kafkaREST.CloudClient.ListKafkaTopics(lkc)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same endpoint we call for confluent kafka topic list? Maybe we should write a plugin called confluent-kafka-topic-count.sh that simply runs confluent kafka topic list -o json | grep name | wc -l.

I think it would be wise to avoid making more than one API call per command if we can avoid it, as you mentioned above. I'd like to see what Ethan Ruhe (@ethanruhe) thinks when he gets back.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked to David and Ethan. agreed that one more call is fine. Ideally we only want 1, and when we need ~5 calls it's better to make it a plugin

@MuweiHe MuweiHe changed the title [CLI-1884] show total topic count of active cluster when run kafka cluster describe [CLI-1884] show total topic count of cluster when run kafka cluster describe Sep 22, 2022
@MuweiHe MuweiHe changed the title [CLI-1884] show total topic count of cluster when run kafka cluster describe [CLI-1884] show total topic count of cluster when run kafka cluster describe/update Sep 28, 2022
@MuweiHe MuweiHe merged commit 96c856b into main Sep 28, 2022
@MuweiHe MuweiHe deleted the CLI-1884-2 branch September 28, 2022 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants