SOLR-18062: Support arbitrary Kafka properties via env and sysprops #4185
Quick update: I rebased/restacked this branch on top of the latest main, and the PR now contains only the SOLR-18062 commit.
No functional changes from the original intent, just branch hygiene to make review easier.
Quick follow-up on this one: the branch is now cleanly restacked on current and the diff is focused on SOLR-18062 only. If there’s a preferred area/committer to tag for review, I can do that.
Small correction to my note above: this is rebased on current main and the PR is scoped to SOLR-18062 only. Happy to adjust anything needed for review.
Force-pushed after author cleanup; latest commit is 91c9549294f and is authored as openworld-maker.
@dsmiley @epugh could you please review when you have a moment?
We have a class called EnvUtils that I think handles a lot of this... Can you shed any light on if there is something about the cross dc stuff that prevents us from using EnvUtils? It feels like IF we can use EnvUtils, then this could be made a lot simpler?
@gsingh-code can you review the CI checks? And then whne they pass ping me and I'll merge.
We have a class calledEnvUtilsthat I think handles a lot of this... Can you shed any light on if there is something about the cross dc stuff that prevents us from usingEnvUtils?
We should use it - I believe the reason was that the original crossdc contribution was developed a long time ago in the sandbox, before the introduction of EnvUtils, and then never refactored.
> We have a class calledEnvUtilsthat I think handles a lot of this... Can you shed any light on if there is something about the cross dc stuff that prevents us from usingEnvUtils?
> We should use it - I believe the reason was that the original crossdc contribution was developed a long time ago in the sandbox, before the introduction of EnvUtils, and then never refactored.
Thanks for confirming the EnvUtils use. Any thing else on this PR jump out to you @sigram ? I'm hoping @gsingh-code will get tests to pass or confirm they are just flaky ones.
Looks good to me.
I did a bit of spelunking, and looked at the the text added to the ref guide:
Property names from environment variables are normalized by stripping the prefix, converting to lowercase, and replacing `_` with `.`.
Values from `solr.crossdc.kafka.` system properties override values from `SOLR_CROSSDC_KAFKA_` environment variables when they map to the same Kafka key.
Already-populated explicit CrossDC settings are preserved and are not overridden by pass-through values.
Blank values and empty normalized keys are ignored
So, without some more work, EnvUtils doesn't work as a direct swap.... It doesn't replicate two of our four documented guarantees — it doesn't drop blank values/empty keys, and it has no notion of preserving already-set explicit CrossDC settings — so swapping it in would silently change behavior.
I don't know if I want to tackle makign those changes since I don't know this area very well...
@sigram if you can weigh in, then I think we can get this to done...
@gsingh-code can you add a changelog for this nice feature?
@sigram if you can weigh in, then I think we can get this to done...
Ping... I'd love to see this go in.. But haven't worked in this area much, so would love a +1 from you.
sigram
gsingh-code
Description
This PR completes SOLR-18062 by hardening and clarifying CrossDC Kafka pass-through property behavior.
Jira: https://issues.apache.org/jira/browse/SOLR-18062
mainalready included the core SOLR-18062 support for arbitrary Kafka properties via:SOLR_CROSSDC_KAFKA_environment variablessolr.crossdc.kafka.system propertiesThis change focuses on missing edge-case handling, precedence clarity, and testability.
What Changed
1) Hardened pass-through extraction in
ConfUtil-
addAdditionalKafkaProperties(Map<String,Object> properties, Map<String,String> env, Properties sysProps)properties.-
solr.crossdc.kafka.system properties overrideSOLR_CROSSDC_KAFKA_env values for the same normalized Kafka key.- ignore blank / empty values
- ignore empty normalized keys (for example bare prefixes)
2) Added focused unit coverage in
ConfUtilTestSOLR_CROSSDC_KAFKA_FOO_BAR->foo.bar)solr.crossdc.kafka.foo.bar->foo.bar)KafkaCrossDcConf.getAdditionalProperties()3) Updated CrossDC documentation
sysprop > envfor same pass-through key)Behavior / Compatibility
getAdditionalProperties()use remains as-is).Validation
Ran locally:
./gradlew :solr:modules:cross-dc:test --tests org.apache.solr.crossdc.common.ConfUtilTest./gradlew tidy :solr:modules:cross-dc:check -x test :solr:solr-ref-guide:check -x test