-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
8d4f3a1
to
91694e1
Compare
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/CruiseControl.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...ator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/ResourceCapacityType.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/ResourceRequirementsUtils.java
Outdated
Show resolved
Hide resolved
8045600
to
5ab37d1
Compare
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/test/java/io/strimzi/operator/cluster/model/CruiseControlTest.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CpuCapacity.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CpuCapacity.java
Outdated
Show resolved
Hide resolved
...ter-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/DiskCapacity.java
Outdated
Show resolved
Hide resolved
...ter-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/DiskCapacity.java
Outdated
Show resolved
Hide resolved
...or/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/InboundNetworkCapacity.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CpuCapacity.java
Show resolved
Hide resolved
...ter-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/DiskCapacity.java
Outdated
Show resolved
Hide resolved
...-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/NetworkCapacity.java
Outdated
Show resolved
Hide resolved
...src/test/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfigurationTest.java
Show resolved
Hide resolved
There was a problem hiding this 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.
...ter-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/DiskCapacity.java
Outdated
Show resolved
Hide resolved
/azp run regression |
1 similar comment
/azp run regression |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this 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
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Show resolved
Hide resolved
...tor/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfiguration.java
Outdated
Show resolved
Hide resolved
...ter-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/DiskCapacity.java
Show resolved
Hide resolved
...ter-operator/src/main/java/io/strimzi/operator/cluster/model/cruisecontrol/DiskCapacity.java
Show resolved
Hide resolved
...src/test/java/io/strimzi/operator/cluster/model/cruisecontrol/CapacityConfigurationTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Great work!
/azp run regression |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Kyle Liberti <[email protected]>
e8e574d
to
d932f10
Compare
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. |
/azp run regression |
Azure Pipelines successfully started running 1 pipeline(s). |
Thanks for the PR @kyguy |
Signed-off-by: Kyle Liberti <[email protected]>
Type of change
Description
Refactors Cruise Control capacity configuration classes.
Checklist
Please go through this checklist and make sure all applicable tasks have been done