From 5d47b9178cc754fb45d48862cd43122f1dadda95 Mon Sep 17 00:00:00 2001 From: Paulin Todev Date: Thu, 28 Nov 2024 16:02:01 +0000 Subject: [PATCH] `loki.source.podlogs`: Fix issue which disables clustering unintentionally. (#2187) * Fix issue which disables clustering unintentionally. --- CHANGELOG.md | 3 +++ internal/component/loki/source/podlogs/podlogs.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69beb3459..37655985ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,9 @@ Main (unreleased) - Fix a race condition where the ui service was dependent on starting after the remotecfg service, which is not guaranteed. (@dehaansa & @erikbaranowski) +- `loki.source.podlogs`: Fixed a bug which prevented clustering from working and caused duplicate logs to be sent. + The bug only happened when no `selector` or `namespace_selector` blocks were specified in the Alloy configuration. (@ptodev) + ### Other changes - Change the stability of the `livedebugging` feature from "experimental" to "generally available". (@wildum) diff --git a/internal/component/loki/source/podlogs/podlogs.go b/internal/component/loki/source/podlogs/podlogs.go index db1bca5d99..d903c5eaed 100644 --- a/internal/component/loki/source/podlogs/podlogs.go +++ b/internal/component/loki/source/podlogs/podlogs.go @@ -258,6 +258,10 @@ func (c *Component) updateTailer(args Arguments) error { // updateReconciler updates the state of the reconciler. This must only be // called after updateTailer. mut must be held when calling. func (c *Component) updateReconciler(args Arguments) error { + // The clustering settings should always be updated, + // even if the selectors haven't changed. + c.reconciler.SetDistribute(args.Clustering.Enabled) + var ( selectorChanged = !reflect.DeepEqual(c.args.Selector, args.Selector) namespaceSelectorChanged = !reflect.DeepEqual(c.args.NamespaceSelector, args.NamespaceSelector) @@ -276,7 +280,6 @@ func (c *Component) updateReconciler(args Arguments) error { } c.reconciler.UpdateSelectors(sel, nsSel) - c.reconciler.SetDistribute(args.Clustering.Enabled) // Request a reconcile so the new selectors get applied. c.controller.RequestReconcile()