From 2833383b87527e150ce124e9d2ac2aa857584df4 Mon Sep 17 00:00:00 2001 From: Yolean gle-qa Date: Mon, 19 Oct 2026 14:25:04 +0000 Subject: [PATCH] kafka: set log_retention_ms=-1 at broker start, not in bootstrap.yaml bootstrap.yaml's log_retention_ms: -1 (0fbe8e6) does not survive a restart on redpanda v24.2. At first start the bootstrap import serializes the cluster property through an unsigned 64 bit integer, so the controller log and config_cache.yaml get 18446744073709551615. Redpanda then rejects that value: `rpk cluster config status` lists log_retention_ms as INVALID, and at every restart the broker logs "Ignoring invalid property: log_retention_ms=18446744073709551615" and uses the 7 day default. Any negative value takes the same path, and a null is dropped by helm. So a cluster keeps records only until its first restart. The value is now set where it works, through the admin API: the chart's postStart.sh runs `rpk cluster config set log_retention_ms=-1` while the cluster has the 7 day default (604800000), and leaves any other value as it is. It runs before the chart's own hook, which never completes on this image: /bin/sh is dash, which has no `source`. Verified on a throwaway cluster with ghcr.io/yolean/redpanda:v24.2.14: a fresh start, a restart, an upgrade from a cluster bootstrapped with -1, and a cluster with log_retention_ms=86400000, which keeps its value. After the hook, `rpk cluster config get log_retention_ms` prints -9223372036854775808, status lists nothing INVALID, and a topic without its own retention shows retention.ms -1 DEFAULT_CONFIG. Applying this rolls no broker: it takes effect at the next broker start. To set it on a running cluster now: kubectl -n kafka exec redpanda-0 -c redpanda -- rpk cluster config set log_retention_ms=-1 Co-Authored-By: Claude Opus 5.5 --- kafka/redpanda.kafka.values.yaml | 7 +++++-- .../kafka/redpanda/templates/configmap.yaml | 1 - .../kafka/redpanda/templates/secrets.yaml | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/kafka/redpanda.kafka.values.yaml b/kafka/redpanda.kafka.values.yaml index 2799a567..d315b903 100644 --- a/kafka/redpanda.kafka.values.yaml +++ b/kafka/redpanda.kafka.values.yaml @@ -27,8 +27,11 @@ config: default_topic_partitions: 1 storage_min_free_bytes: 10485760 group_topic_partitions: 1 - # like Kafka brokers set up by Yolean/kubernetes-kafka: a topic deletes by age only when it says so - log_retention_ms: -1 + # log_retention_ms is not set here. Like Kafka brokers set up by Yolean/kubernetes-kafka, a topic + # deletes by age only when it says so, but redpanda v24.2 imports a negative log_retention_ms + # from bootstrap.yaml as 18446744073709551615, rejects that, and falls back to 7 days after the + # first restart. Instead the rendered postStart.sh (templates/secrets.yaml) sets -1 at each + # broker start, while the cluster has the 7 day default. tuning: tune_aio_events: false tls: diff --git a/kafka/redpanda/kafka/redpanda/templates/configmap.yaml b/kafka/redpanda/kafka/redpanda/templates/configmap.yaml index d5d7fe4d..a772206b 100644 --- a/kafka/redpanda/kafka/redpanda/templates/configmap.yaml +++ b/kafka/redpanda/kafka/redpanda/templates/configmap.yaml @@ -26,7 +26,6 @@ data: compacted_log_segment_size: 16777216 group_topic_partitions: 1 kafka_batch_max_bytes: 1048576 - log_retention_ms: -1 kafka_connection_rate_limit: 1000 log_segment_size: 16777216 log_segment_size_max: 33554432 diff --git a/kafka/redpanda/kafka/redpanda/templates/secrets.yaml b/kafka/redpanda/kafka/redpanda/templates/secrets.yaml index 6bbe3271..bdd757b5 100644 --- a/kafka/redpanda/kafka/redpanda/templates/secrets.yaml +++ b/kafka/redpanda/kafka/redpanda/templates/secrets.yaml @@ -54,6 +54,21 @@ stringData: touch /tmp/postStartHookFinished } + # Added to the chart's script, and independent of common.sh, which /bin/sh (dash) does not + # source: topics without their own retention.ms keep their records. Redpanda's default + # log_retention_ms deletes by age after 7 days, and bootstrap.yaml can not carry -1 (see + # redpanda.kafka.values.yaml). Any value other than the 7 day default is left as it is. + retentionDefault () { + for _ in 1 2 3 4 5 6 7 8 9 10; do + if retention=$(rpk cluster config get log_retention_ms); then + [ "$retention" = "604800000" ] || return 0 + rpk cluster config set log_retention_ms=-1 && return 0 + fi + sleep 2 + done + } + + retentionDefault postStartHook true