linkedin / cruise-control

Cruise-control is the first of its kind to fully automate the dynamic workload rebalance and self-healing of a Kafka cluster. It provides great value to Kafka users by simplifying the operation of Kafka clusters.
https://github.com/linkedin/cruise-control/tags
BSD 2-Clause "Simplified" License
2.77k stars 595 forks source link

bugfix: exclude transitive logback dependencies #2175

Closed robobario closed 4 months ago

robobario commented 4 months ago

Exclude logback from being depended on transitively (following established pattern for excluding log4j:log4j)

Why: A logback slf4j binding is being pulled in via zookeeper causing issues at runtime because we have two slf4j bindings available. Slf4j chooses one implementation and it can pick logback, which is unexpected.

To reproduce on main:

gradle clean build -q -x test && ./kafka-cruise-control-start.sh config/cruisecontrol.properties 2>&1 | grep SLF4J
... gradle noises ...
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/robeyoun/development/upstream/cruise-control/cruise-control/build/dependant-libs/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

This PR resolves #2174

mhratson commented 4 months ago

Tested locally, with patch the transitive dependencies aren't being picked up: Before

$ ./kafka-cruise-control-start.sh ./cruisecontrol.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/mhratson/src/cruise-control.3/cruise-control/build/dependant-libs/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/mhratson/src/cruise-control.3/cruise-control/build/dependant-libs/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

After (no multiple bindings logs)

$ ./kafka-cruise-control-start.sh ./cruisecontrol.properties 
[2024-07-24 16:27:26,064] INFO COMMIT INFO: 2.5.139-SNAPSHOT---f23332a2ec4f8f3f0d69cd6e6f3b7aa9e33fb873 (com.linkedin.kafka.cruisecontrol.KafkaCruiseControl)
[2024-07-24 16:27:26,069] INFO AdminClientConfig values: 
    auto.include.jmx.reporter = true