Skip to content
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

Added a custom SASL config option to the Topic Operator #5473 #9606

Merged
merged 103 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
a07507f
Added a custom SASL config option to the Topic Operator
john-mcpeek Jan 27, 2024
b8bbe5f
Update CHANGELOG.md adding custom SASL support
john-mcpeek Jan 27, 2024
8faa578
Added back the else to ensure no null properties get set.
john-mcpeek Jan 28, 2024
3a50659
Allow reconciliation to continue when scale-down is blocked due to br…
scholzj Jan 28, 2024
cce0581
Merge branch 'main' into custom-topic-operator-sasl-config-5473
john-mcpeek Jan 28, 2024
68c576e
Cleanup SpotBugs issues.
john-mcpeek Jan 28, 2024
79427ab
Cleanup formatting issues.
john-mcpeek Jan 28, 2024
5ba77f5
Apply suggestions from code review
john-mcpeek Jan 29, 2024
e9f237d
Update CHANGELOG.md
john-mcpeek Jan 29, 2024
a2431bc
Update topic-operator/src/main/java/io/strimzi/operator/topic/Session…
john-mcpeek Jan 31, 2024
cdbb681
Update topic-operator/src/main/java/io/strimzi/operator/topic/v2/Topi…
john-mcpeek Jan 31, 2024
b2458fb
Update topic-operator/src/main/java/io/strimzi/operator/topic/v2/Topi…
john-mcpeek Jan 31, 2024
50b1a03
Update topic-operator/src/main/java/io/strimzi/operator/topic/Session…
john-mcpeek Feb 1, 2024
0cb145c
Update topic-operator/src/main/java/io/strimzi/operator/topic/Session…
john-mcpeek Feb 1, 2024
5c1605c
Update topic-operator/src/main/java/io/strimzi/operator/topic/Session…
john-mcpeek Feb 1, 2024
8d0de96
Update topic-operator/src/main/java/io/strimzi/operator/topic/Session…
john-mcpeek Feb 1, 2024
b03be6d
Update topic-operator/src/main/java/io/strimzi/operator/topic/v2/Topi…
john-mcpeek Feb 1, 2024
615517a
Used the SASL_TYPE_CUSTOM and update error message.
john-mcpeek Feb 1, 2024
c3b4fc0
Removed logs used during development.
john-mcpeek Feb 1, 2024
fbe94d1
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Feb 1, 2024
a4d5a55
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Feb 1, 2024
83b0895
Updated for error responses.
john-mcpeek Feb 1, 2024
de23ad1
Updated for error responses.
john-mcpeek Feb 2, 2024
c2e5682
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Feb 2, 2024
6dca372
Merge pull request #1 from strimzi/main
john-mcpeek Mar 11, 2024
52b045f
Merged latest from Strimzi
john-mcpeek Mar 12, 2024
c806183
Merge pull request #2 from strimzi/main
john-mcpeek Mar 13, 2024
a22e38b
Merged latest from Strimzi
john-mcpeek Mar 13, 2024
bd777a5
Merge pull request #3 from strimzi/main
john-mcpeek Mar 24, 2024
01c078d
Merged latest from Strimzi
john-mcpeek Mar 24, 2024
fa2742b
Updated to use SASL_CUSTOM_CONFIG_JSON
john-mcpeek Mar 25, 2024
7e56d0c
Updated documentation of SASL_CUSTOM_CONFIG_JSON for standalone topic…
john-mcpeek Mar 26, 2024
5a800b4
Added the missing STRIMZI_ to STRIMZI_SASL_CUSTOM_CONFIG_JSON
john-mcpeek Mar 26, 2024
421b58e
Allowed comments in the custom SASL config json.
john-mcpeek Mar 26, 2024
7be96f3
Added logic to skip the getClusterConfig() call when using custom SAS…
john-mcpeek Mar 26, 2024
1aa3155
Fixed an unused variable bug and updated CHANGELOG
john-mcpeek Mar 26, 2024
c05aa45
Fixed an unused variable bug and updated CHANGELOG
john-mcpeek Mar 26, 2024
d7efe95
Merge pull request #4 from strimzi/main
john-mcpeek Mar 26, 2024
e7d5b72
Merge branch 'strimzi:main' into main
john-mcpeek Mar 26, 2024
2a9a4cd
Cleaned up the documentation.
john-mcpeek Mar 27, 2024
b305f93
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Mar 27, 2024
4753583
Added CUSTOM_ALTERABLE_CONFIGURATIONS and SKIP_CLUSTER_CONFIG_REVIEW
john-mcpeek Mar 28, 2024
7af6b08
Merge branch 'custom-topic-operator-sasl-config-5473' of https://gith…
john-mcpeek Mar 28, 2024
9e158ee
Modified test
john-mcpeek Mar 28, 2024
3d742cb
Updated config property names and documentation.
john-mcpeek Mar 28, 2024
64920f6
Merge branch 'strimzi:main' into main
john-mcpeek Mar 28, 2024
bca3593
Catchup
john-mcpeek Mar 28, 2024
b0f9beb
Fixed an incorrect merge
john-mcpeek Mar 28, 2024
445b014
Added test for default values on new properties
john-mcpeek Mar 28, 2024
9f97fc4
Fixed updated packages
john-mcpeek Mar 28, 2024
55547c8
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Mar 28, 2024
3fbebcc
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Mar 29, 2024
5321b04
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Mar 29, 2024
a2d7d11
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 1, 2024
ca05d36
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 3, 2024
3f2c8fc
Added test for skipClusterConfigReview and alterableTopicConfig
john-mcpeek Apr 4, 2024
4516a23
Simplified the alterableTopicConfig test
john-mcpeek Apr 4, 2024
91521b1
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 4, 2024
9607ce5
Switched to using a constant for the topic name.
john-mcpeek Apr 4, 2024
51a5676
Update topic-operator/src/test/java/io/strimzi/operator/topic/Batchin…
john-mcpeek Apr 4, 2024
626f8ea
Update topic-operator/src/test/java/io/strimzi/operator/topic/Batchin…
john-mcpeek Apr 4, 2024
98f69cc
Update topic-operator/src/main/java/io/strimzi/operator/topic/Batchin…
john-mcpeek Apr 4, 2024
30d43c9
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 4, 2024
ebb1d76
Update toString and addressed PR comment
john-mcpeek Apr 4, 2024
2ab4b82
Merge branch 'custom-topic-operator-sasl-config-5473' of https://gith…
john-mcpeek Apr 4, 2024
b3bcbef
Addressed PR comments
john-mcpeek Apr 4, 2024
5fd072a
Addressed PR comments
john-mcpeek Apr 4, 2024
abab6c7
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 4, 2024
cac01a5
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 4, 2024
59c59ca
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 6, 2024
f2e3727
Added Conditions to status for the special case of alterableTopicConf…
john-mcpeek Apr 6, 2024
19eb604
Addressed PR comment
john-mcpeek Apr 6, 2024
5ed5401
Addressed PR comment
john-mcpeek Apr 6, 2024
a9fa314
Update topic-operator/src/main/java/io/strimzi/operator/topic/Batchin…
john-mcpeek Apr 8, 2024
9ef2abb
Switched to a single Warning message
john-mcpeek Apr 8, 2024
a76df7b
Added warning log and updated for null alterable topic config
john-mcpeek Apr 8, 2024
890f2c7
Fixed scope on constant
john-mcpeek Apr 9, 2024
a87c3cf
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 9, 2024
bb59d8c
Switched to using 'all' as the default for alterableTopicConfig
john-mcpeek Apr 9, 2024
255b2a5
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 9, 2024
1e7bd12
Updated to ALL and NONE for STRIMZI_ALTERABLE_TOPIC_CONFIG
john-mcpeek Apr 10, 2024
49bcfce
Merge branch 'custom-topic-operator-sasl-config-5473' of https://gith…
john-mcpeek Apr 10, 2024
7360541
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 10, 2024
0d63ccf
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 11, 2024
e1a2fde
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 11, 2024
86b1438
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 12, 2024
f5832d9
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
fef4ded
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
d1fc94b
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
4a5f20d
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
5a5c107
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
bd0b250
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
5942024
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
37632f3
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 12, 2024
149cb17
Merge branch 'strimzi:main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 12, 2024
299f2d9
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 15, 2024
9b6a206
Update documentation/modules/deploying/proc-deploy-topic-operator-sta…
john-mcpeek Apr 15, 2024
9794bc4
Updated the doc to clarify
john-mcpeek Apr 15, 2024
1f151cc
Merge branch 'main' into custom-topic-operator-sasl-config-5473
john-mcpeek Apr 17, 2024
da51009
Update BatchingTopicController.java
john-mcpeek Apr 17, 2024
98918ff
Update proc-deploy-topic-operator-standalone.adoc
john-mcpeek Apr 17, 2024
b3fb404
Update proc-deploy-topic-operator-standalone.adoc
john-mcpeek Apr 17, 2024
3a6afea
Update BatchingTopicController.java
john-mcpeek Apr 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Added support for configuring the `externalIPs` field in node port type services.
* The `UnidirectionalTopicOperator` feature gate moves to GA stage and is permanently enabled without the possibility to disable it.
If the topics whose names start with `strimzi-store-topic` and `strimzi-topic-operator` still exist, you can delete them.
* Added support for custom SASL config in standalone Topic Operator deployment to support alternate access controllers (i.e. `AWS_MSK_IAM`)

### Changes, deprecations and removals

Expand Down
john-mcpeek marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,69 @@ env:
<3> The keystore contains the private key for mTLS authentication.
<4> The password for accessing the keystore.

. If you need to configure custom SASL authentication, you can define the necessary authentication properties using the `STRIMZI_SASL_CUSTOM_CONFIG_JSON` environment variable for the standalone operator.
For example, this configuration may be used for accessing a Kafka cluster in a cloud provider with a custom login module like the link:https://github.com/aws/aws-msk-iam-auth[Amazon MSK Library for AWS Identity and Access Management^] (`aws-msk_iam-auth`).
+
The property `STRIMZI_ALTERABLE_TOPIC_CONFIG` defaults to `ALL`, allowing all `.spec.config` properties to be set in the `KafkaTopic` resource.
If this setting is not suitable for a managed Kafka service, do as follows:
+
--
* If only a subset of properties is configurable, list them as comma-separated values.
* If no properties are to be configured, use `NONE`, which is equivalent to an empty property list.
--
+
NOTE: Only Kafka configuration properties starting with `sasl.` can be set with the `STRIMZI_SASL_CUSTOM_CONFIG_JSON` environment variable.
+
.Example custom SASL configuration
[source,shell,subs=+quotes]
----
# ....
env:
john-mcpeek marked this conversation as resolved.
Show resolved Hide resolved
- name: STRIMZI_SASL_ENABLED
value: "true"
- name: STRIMZI_SECURITY_PROTOCOL
value: SASL_SSL
- name: STRIMZI_SKIP_CLUSTER_CONFIG_REVIEW # <1>
value: "true"
- name: STRIMZI_ALTERABLE_TOPIC_CONFIG # <2>
value: compression.type, max.message.bytes, message.timestamp.difference.max.ms, message.timestamp.type, retention.bytes, retention.ms
- name: STRIMZI_SASL_CUSTOM_CONFIG_JSON # <3>
value: |
{
"sasl.mechanism": "AWS_MSK_IAM",
"sasl.jaas.config": "software.amazon.msk.auth.iam.IAMLoginModule required;",
"sasl.client.callback.handler.class": "software.amazon.msk.auth.iam.IAMClientCallbackHandler"
}
- name: STRIMZI_PUBLIC_CA
value: "true"
- name: STRIMZI_TRUSTSTORE_LOCATION
value: /etc/pki/java/cacerts
- name: STRIMZI_TRUSTSTORE_PASSWORD
value: changeit
- name: STRIMZI_KAFKA_BOOTSTRAP_SERVERS
value: my-kafka-cluster-.kafka-serverless.us-east-1.amazonaws.com:9098
# ...
----
<1> Disables cluster configuration lookup for managed Kafka services that don't allow topic configuration changes.
<2> Defines the topic configuration properties that can be updated based on the limitations set by managed Kafka services.
<3> Specifies the SASL properties to be set in JSON format. Only properties starting with `sasl.` are allowed.
+
.Example Dockerfile with external jars
[source,shell,subs=+quotes]
----
FROM strimzi/operator:latest

USER root

RUN mkdir -p ${STRIMZI_HOME}/external-libs
RUN chmod +rx ${STRIMZI_HOME}/external-libs

COPY ./aws-msk-iam-auth-and-dependencies/* ${STRIMZI_HOME}/external-libs/
ENV JAVA_CLASSPATH=${STRIMZI_HOME}/external-libs/*

USER 1001
----

. Apply the changes to the `Deployment` configuration to deploy the Topic Operator.

. Check the status of the deployment:
Expand Down
6 changes: 6 additions & 0 deletions test/src/main/java/io/strimzi/test/executor/Exec.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
Expand Down Expand Up @@ -339,6 +340,11 @@ private void storeOutputsToFile() {
* @return true.false
*/
public static boolean isExecutableOnPath(String cmd) {
var osName = System.getProperty("os.name");
if (osName.toLowerCase(Locale.US).startsWith("windows")) {
cmd += ".exe";
}
scholzj marked this conversation as resolved.
Show resolved Hide resolved

for (String dir : PATH_SPLITTER.split(System.getenv("PATH"))) {
if (new File(dir, cmd).canExecute()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.io.InterruptedIOException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -104,13 +105,18 @@ public class BatchingTopicController {
this.selector = Objects.requireNonNull(selector);
this.useFinalizer = config.useFinalizer();
this.admin = admin;
// Get the config of some broker and check whether auto topic creation is enabled
Optional<String> autoCreateValue = getClusterConfig(admin, AUTO_CREATE_TOPICS_ENABLE);
if (autoCreateValue.isPresent() ? "true".equals(autoCreateValue.get()) : false) {
LOGGER.warnOp(
"It is recommended that " + AUTO_CREATE_TOPICS_ENABLE + " is set to 'false' " +
"to avoid races between the operator and Kafka applications auto-creating topics");

var skipClusterConfigReview = config.skipClusterConfigReview();
if (!skipClusterConfigReview) {
// Get the config of some broker and check whether auto topic creation is enabled
Optional<String> autoCreateValue = getClusterConfig(admin, AUTO_CREATE_TOPICS_ENABLE);
if (autoCreateValue.filter("true"::equals).isPresent()) {
LOGGER.warnOp(
"It is recommended that " + AUTO_CREATE_TOPICS_ENABLE + " is set to 'false' " +
"to avoid races between the operator and Kafka applications auto-creating topics");
}
}

this.kubeClient = kubeClient;
this.metrics = metrics;
this.namespace = config.namespace();
Expand Down Expand Up @@ -581,6 +587,11 @@ private PartitionedByError<ReconcilableTopic, CurrentState> findDifferentRf(Part
* @param reconcilableTopics Reconcilable topic.
*/
private void warnTooLargeMinIsr(List<ReconcilableTopic> reconcilableTopics) {
if (config.skipClusterConfigReview()) {
// This method is for internal configurations. So skipping.
return;
}

Optional<String> clusterMinIsr = getClusterConfig(admin, MIN_INSYNC_REPLICAS);
for (ReconcilableTopic reconcilableTopic : reconcilableTopics) {
var topicConfig = reconcilableTopic.kt().getSpec().getConfig();
Expand Down Expand Up @@ -709,7 +720,7 @@ private void accumulateResults(Map<ReconcilableTopic, Either<TopicOperatorExcept
replicasChangeResults.errors().forEach(pair -> putResult(results, pair.getKey(), Either.ofLeft(pair.getValue())));
}

private static List<Pair<ReconcilableTopic, Collection<AlterConfigOp>>> configChanges(Map<ReconcilableTopic, Either<TopicOperatorException, Object>> results, PartitionedByError<ReconcilableTopic, CurrentState> currentStatesOrError) {
private List<Pair<ReconcilableTopic, Collection<AlterConfigOp>>> configChanges(Map<ReconcilableTopic, Either<TopicOperatorException, Object>> results, PartitionedByError<ReconcilableTopic, CurrentState> currentStatesOrError) {
// Determine config changes
Map<Boolean, List<Pair<ReconcilableTopic, Collection<AlterConfigOp>>>> alterConfigs = currentStatesOrError.ok().map(pair -> {
var reconcilableTopic = pair.getKey();
Expand Down Expand Up @@ -1083,7 +1094,7 @@ private static Either<TopicOperatorException, NewPartitions> buildNewPartitions(
}
}

private static Collection<AlterConfigOp> buildAlterConfigOps(Reconciliation reconciliation, KafkaTopic kt, Config configs) {
private Collection<AlterConfigOp> buildAlterConfigOps(Reconciliation reconciliation, KafkaTopic kt, Config configs) {
Set<AlterConfigOp> alterConfigOps = new HashSet<>();
if (hasConfig(kt)) {
for (var specConfigEntry : kt.getSpec().getConfig().entrySet()) {
Expand All @@ -1109,6 +1120,9 @@ private static Collection<AlterConfigOp> buildAlterConfigOps(Reconciliation reco
new ConfigEntry(key, null),
AlterConfigOp.OpType.DELETE));
}

skipNonAlterableConfigs(alterConfigOps);

if (alterConfigOps.isEmpty()) {
LOGGER.debugCr(reconciliation, "No config change");
} else {
Expand All @@ -1117,24 +1131,89 @@ private static Collection<AlterConfigOp> buildAlterConfigOps(Reconciliation reco
return alterConfigOps;
}

/**
* <p>The Topic Operator {@code alterableTopicConfig} can be used to specify a comma separated list of Kafka
* topic configurations that can be altered by users through {@code .spec.config}. Keep in mind that if changes
* are applied directly in Kafka, the operator will try to revert them producing a warning.</p>
*
* <p>This is useful in standalone mode when you have a Kafka service that restricts alter operations
* to a subset of all the Kafka topic configurations.</p>
*
* <p>The default value is "all", which means no restrictions in changing {@code .spec.config}.
* The opposite is "none", which can be set to explicitly disable any change.</p>
*
* @param alterConfigOps Requested alter config operations.
*/
private void skipNonAlterableConfigs(Set<AlterConfigOp> alterConfigOps) {
var alterableConfigs = config.alterableTopicConfig();
ppatierno marked this conversation as resolved.
Show resolved Hide resolved
if (alterableConfigs != null && alterConfigOps != null && !alterableConfigs.isEmpty()) {
if (alterableConfigs.equalsIgnoreCase("none")) {
Copy link
Member

Choose a reason for hiding this comment

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

despite there is an ignore case, you are mentioning "none" (lower case) here but "NONE" (upper case) in the previous doc. I would stick with the same on both, i.e. "none" lower case.

Copy link
Contributor

@fvaleri fvaleri Apr 17, 2024

Choose a reason for hiding this comment

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

right, let's keep them aligned

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so, "none" everywhere including the documentation?

Copy link
Member

Choose a reason for hiding this comment

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

I would say yes

Copy link
Member

Choose a reason for hiding this comment

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

What do we do for other similar options? Didn't @fvaleri before suggest to use uppercase? This should be also consistent with the ALL I guess?

Copy link
Member

Choose a reason for hiding this comment

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

I am just for consistency so even the upper case is fine with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Guys, I just need an answer. Upper or lower? Please.

Copy link
Member

Choose a reason for hiding this comment

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

@john-mcpeek Well, it makes no sense to have none and ALL. So one way or another there will be another change needed. It was actually @tombentley who suggested upper case in #9606 (comment) and I think his logic makes sense. So if Paolo doesn't care you should go with uppercase everywhere.

Copy link
Contributor

@fvaleri fvaleri Apr 17, 2024

Choose a reason for hiding this comment

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

Tom originally suggested to have all uppercase as it is more evident comparing to regular configuration, which is lowercase. So let's use UPPERCASE (NONE and ALL).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I think we are NONE and ALL everywhere now.

alterConfigOps.clear();
} else if (!alterableConfigs.equalsIgnoreCase("all")) {
var alterablePropertySet = Arrays.stream(alterableConfigs.replaceAll("\\s", "").split(","))
.collect(Collectors.toSet());
alterConfigOps.removeIf(op -> !alterablePropertySet.contains(op.configEntry().name()));
}
}
}

private static boolean hasConfig(KafkaTopic kt) {
return kt.getSpec() != null
&& kt.getSpec().getConfig() != null;
}

private void updateStatusForSuccess(ReconcilableTopic reconcilableTopic) {
List<Condition> conditions = new ArrayList<>();
conditions.add(new ConditionBuilder()
.withType(TopicOperatorUtil.isPaused(reconcilableTopic.kt()) ? "ReconciliationPaused" : "Ready")
.withStatus("True")
.withLastTransitionTime(StatusUtils.iso8601Now())
.build());

addNonAlterableConfigsWarning(reconcilableTopic, conditions);

reconcilableTopic.kt().setStatus(
new KafkaTopicStatusBuilder(reconcilableTopic.kt().getStatus())
.withConditions(List.of(new ConditionBuilder()
.withType(TopicOperatorUtil.isPaused(reconcilableTopic.kt()) ? "ReconciliationPaused" : "Ready")
.withStatus("True")
.withLastTransitionTime(StatusUtils.iso8601Now())
.build()))
.withConditions(conditions)
.build());
updateStatus(reconcilableTopic);
metrics.successfulReconciliationsCounter(namespace).increment();
}


private void addNonAlterableConfigsWarning(ReconcilableTopic reconcilableTopic,
List<Condition> conditions) {
var readOnlyConfigs = new ArrayList<>();
ppatierno marked this conversation as resolved.
Show resolved Hide resolved
var alterableConfigs = config.alterableTopicConfig();

if (reconcilableTopic != null && reconcilableTopic.kt() != null
&& hasConfig(reconcilableTopic.kt()) && alterableConfigs != null) {
if (alterableConfigs.equalsIgnoreCase("NONE")) {
Copy link
Member

Choose a reason for hiding this comment

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

again despite the ignore case, why are you using "NONE" here instead of "none" as before? I would make consistency everywhere, even across the documentation part.

reconcilableTopic.kt().getSpec().getConfig().forEach((key, value) -> readOnlyConfigs.add(key));
} else if (!alterableConfigs.equalsIgnoreCase("ALL") && !alterableConfigs.isBlank()) {
var alterablePropertySet = Arrays.stream(alterableConfigs.replaceAll("\\s", "").split(","))
.collect(Collectors.toSet());
reconcilableTopic.kt().getSpec().getConfig().forEach((key, value) -> {
if (!alterablePropertySet.contains(key)) {
readOnlyConfigs.add(key);
}
});
}
}

if (!readOnlyConfigs.isEmpty()) {
var properties = String.join(", ", readOnlyConfigs.toArray(new String[0]));
var message = "These .spec.config properties are not configurable: [" + properties + "]";
LOGGER.warnCr(reconcilableTopic.reconciliation(), message);
conditions.add(new ConditionBuilder()
.withMessage(message)
.withReason("NotConfigurable")
.withStatus("True")
.withType("Warning")
.withLastTransitionTime(StatusUtils.iso8601Now())
.build());
}
}

private void updateStatusForException(ReconcilableTopic reconcilableTopic, Exception e) {
String reason;
if (e instanceof TopicOperatorException) {
Expand Down
Loading
Loading