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

[FLINK-36278] Reduce log size #119

Merged
merged 6 commits into from
Sep 23, 2024
Merged

Conversation

AHeise
Copy link
Contributor

@AHeise AHeise commented Sep 16, 2024

Currently, container logs appear under an o.a.f logger and thus are visible on CI. This results in compressed log size >40MB for a run and often leads to download errors.

This PR reroutes container logs to a special container logger. It also uses a custom format to significantly reduce the size of each log line. The logs for containers are disabled by default.

Here is the original log of an ITCase (308 KB)
old.log

2794 [docker-java-stream--2048098242] INFO  org.apache.flink.streaming.connectors.kafka.KafkaTestEnvironmentImpl [] - [Kafka-0] STDOUT: [2024-09-16 08:26:53,236] INFO Server environment:java.library.path=/usr/java/packages/lib:/lib:/usr/lib:/usr/lib64:/lib64 (org.apache.zookeeper.server.ZooKeeperServer)
2794 [docker-java-stream--2048098242] INFO  org.apache.flink.streaming.connectors.kafka.KafkaTestEnvironmentImpl [] - [Kafka-0] STDOUT: [2024-09-16 08:26:53,236] INFO Server environment:java.io.tmpdir=/tmp (org.apache.zookeeper.server.ZooKeeperServer)
2794 [docker-java-stream--2048098242] INFO  org.apache.flink.streaming.connectors.kafka.KafkaTestEnvironmentImpl [] - [Kafka-0] STDOUT: [2024-09-16 08:26:53,236] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)

New formatter, same level (199 KB)
with container.log

[Kafka-0] [2024-09-16 08:18:25,496] INFO Server environment:java.library.path=/usr/java/packages/lib:/lib:/usr/lib:/usr/lib64:/lib64 (org.apache.zookeeper.server.ZooKeeperServer)
[Kafka-0] [2024-09-16 08:18:25,496] INFO Server environment:java.io.tmpdir=/tmp (org.apache.zookeeper.server.ZooKeeperServer)
[Kafka-0] [2024-09-16 08:18:25,496] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)

Disabled container log (113 KB)
no container.log

@fapaul
Copy link
Contributor

fapaul commented Sep 16, 2024

Looking at the current test failures of this PR the log size (https://github.com/apache/flink-connector-kafka/actions/runs/10881066111/job/30189211552?pr=119) is still 50MB+. I wonder if this PR fixes the issue.

@fapaul fapaul self-requested a review September 16, 2024 14:30
@AHeise AHeise force-pushed the FLINK-36278-reduce-log-size branch 3 times, most recently from 61b0c89 to 6501a1e Compare September 19, 2024 06:15
@AHeise AHeise force-pushed the FLINK-36278-reduce-log-size branch from 6501a1e to 25a2828 Compare September 19, 2024 07:42
Currently, container logs appear under an o.a.f logger and thus are visible on CI. This results in compressed log size >40MB for a run and often leads to download errors.

This PR reroutes container logs to a special container logger. It also uses a custom format to significantly reduce the size of each log line. The logs for containers are disabled by default.
We should never use INFO for tracking records on the hotpath. Ideally, we would use trace but for this commit I just decreased to DEBUG to minimize the impact on production settings (is it even possible to leave production on INFO currently?).
@AHeise AHeise force-pushed the FLINK-36278-reduce-log-size branch from 25a2828 to 0454a0f Compare September 19, 2024 07:52
@AHeise AHeise changed the title [FLINK-36278] Reduce log size by avoiding container logs by default [FLINK-36278] Reduce log size Sep 19, 2024
Copy link
Contributor

@fapaul fapaul left a comment

Choose a reason for hiding this comment

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

Thanks for driving the investigation to an end. Only one minor comment regarding the APi of the KafkaUtil

return LoggerFactory.getLogger("container." + containerName);
}

public static Logger getLogger(String type, Class<?> testClass) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Afaict this method is always called with "flink" as a first parameter. WDY about removing the type parameter and always set it to flink when called with a testClass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I'll rename to getFlinkLogger then.

Comment on lines 40 to 41
# For old school kafka test that spawn the test server in the same JVM
logger.kafka2.name = kafka
Copy link
Contributor

Choose a reason for hiding this comment

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

Which tests still spawn kafka in the same JVM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Errr it seems none. Good catch.

We still have test dependencies on kafka server and zookeeper that I can probably remove and with it these log confs.

@AHeise AHeise force-pushed the FLINK-36278-reduce-log-size branch from aebc234 to 0f95d4c Compare September 19, 2024 20:52
Reduce the information that Kafka consumer and producer is logging + Kafka server for old school tests.
Keep INFO only for connector related logs. This will avoid all the different JM and TM logs that deal with task life-cycles. Exceptional things still bubble up as warnings.
…ithCancellation

Make a copy of AbstractPartitionDiscoverer#getAllTopics before modifying it.
@AHeise AHeise force-pushed the FLINK-36278-reduce-log-size branch from b052d72 to ffa72b4 Compare September 20, 2024 07:20
@AHeise AHeise merged commit 9b97c51 into apache:main Sep 23, 2024
13 checks passed
@AHeise AHeise deleted the FLINK-36278-reduce-log-size branch September 23, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants