diff --git a/CHANGELOG.md b/CHANGELOG.md index 0947c06dd100..2731aa559354 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ internal API changes are not present. Main (unreleased) ----------------- +### Bugfixes + +- `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 Agent configuration. (@ptodev) + ### Enhancements - Upgrade `github.com/goccy/go-json` to v0.10.4, which reduces the memory consumption of an Agent instance by 20MB. diff --git a/internal/component/loki/source/podlogs/podlogs.go b/internal/component/loki/source/podlogs/podlogs.go index c7f28202d193..3516a5243148 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()