Skip to content

Refactor CC capacity configuration classes #11615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

kyguy
Copy link
Member

@kyguy kyguy commented Jul 3, 2025

Type of change

  • Refactoring

Description

Refactors Cruise Control capacity configuration classes.

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

@kyguy kyguy added this to the 0.47.0 milestone Jul 3, 2025
@kyguy kyguy force-pushed the refactor-cc-capacity-config branch from 8d4f3a1 to 91694e1 Compare July 3, 2025 20:40
@kyguy kyguy marked this pull request as ready for review July 3, 2025 20:53
@kyguy kyguy force-pushed the refactor-cc-capacity-config branch 2 times, most recently from 8045600 to 5ab37d1 Compare July 7, 2025 18:57
@scholzj scholzj requested review from ppatierno and katheris July 8, 2025 06:41
Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

Some more small nits, but looks mostly good.

Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

One more nit. But LGTM otherwise.

One thing I do not want to be strict about, but maybe you can consider ... your code is very dense. Using some mepty lines on the right places can help the readability. Especially empty lines between some general statement and if and between end of if and the next statement. For example instead of:

        Map<Integer, BrokerCapacityOverride> overrideMap = new HashMap<>();
        if (brokerCapacity != null && brokerCapacity.getOverrides() != null && !brokerCapacity.getOverrides().isEmpty()) {
            for (BrokerCapacityOverride override : brokerCapacity.getOverrides()) {
                List<Integer> ids = override.getBrokers();
                for (int id : ids) {
                    if (overrideMap.containsKey(id)) {
                        LOGGER.warnCr(reconciliation, "Duplicate broker id {} found in overrides, using first occurrence.", id);
                    } else if (kafkaBrokerNodes.stream().noneMatch(node -> node.nodeId() == id)) {
                        LOGGER.warnCr(reconciliation, "Ignoring broker capacity override for unknown node ID {}", id);
                    } else {
                        overrideMap.put(id, override);
                    }
                }
            }
        }
        return overrideMap;

you could do:

        Map<Integer, BrokerCapacityOverride> overrideMap = new HashMap<>();

        if (brokerCapacity != null && brokerCapacity.getOverrides() != null && !brokerCapacity.getOverrides().isEmpty()) {
            for (BrokerCapacityOverride override : brokerCapacity.getOverrides()) {
                List<Integer> ids = override.getBrokers();

                for (int id : ids) {
                    if (overrideMap.containsKey(id)) {
                        LOGGER.warnCr(reconciliation, "Duplicate broker id {} found in overrides, using first occurrence.", id);
                    } else if (kafkaBrokerNodes.stream().noneMatch(node -> node.nodeId() == id)) {
                        LOGGER.warnCr(reconciliation, "Ignoring broker capacity override for unknown node ID {}", id);
                    } else {
                        overrideMap.put(id, override);
                    }
                }
            }
        }

        return overrideMap;

To better visually split the different parts of the code. But obviously, this is pretty subjective, so feel free to ignore it.

@scholzj
Copy link
Member

scholzj commented Jul 10, 2025

/azp run regression

1 similar comment
@scholzj
Copy link
Member

scholzj commented Jul 10, 2025

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scholzj scholzj modified the milestones: 0.47.0, 0.48.0 Jul 10, 2025
Copy link
Contributor

@katheris katheris left a comment

Choose a reason for hiding this comment

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

Had a couple of small comments/suggestions but overall looks good

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

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

LGTM. Great work!

@ppatierno
Copy link
Member

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kyguy kyguy force-pushed the refactor-cc-capacity-config branch from e8e574d to d932f10 Compare July 16, 2025 13:32
@kyguy
Copy link
Member Author

kyguy commented Jul 16, 2025

There were a few flakes in the regression tests. I’ve gone ahead and squashed and rebased the code just in case. Once the new build and unit tests pass, we can rerun the regression tests to see if the issue persists.

@ppatierno
Copy link
Member

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scholzj scholzj merged commit 267c449 into strimzi:main Jul 16, 2025
21 checks passed
@scholzj
Copy link
Member

scholzj commented Jul 16, 2025

Thanks for the PR @kyguy

Frawless pushed a commit to Frawless/strimzi-kafka-operator that referenced this pull request Jul 17, 2025
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.

4 participants