From 548259eceb08efc1de3c4c9598f5ad4dae912692 Mon Sep 17 00:00:00 2001 From: Piotr <17101802+thampiotr@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:41:20 +0100 Subject: [PATCH] Fix static mode file tailing race condition (#5317) * Upgrade loki dependency to k169 * Fix tests after removal of stream_lag_labels --- CHANGELOG.md | 2 ++ .../internal/promtailconvert/internal/build/loki_write.go | 8 -------- .../internal/promtailconvert/testdata/unsupported.diags | 4 +--- .../internal/promtailconvert/testdata/unsupported.yaml | 3 --- converter/internal/promtailconvert/validate.go | 8 -------- go.mod | 2 +- go.sum | 4 ++-- 7 files changed, 6 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd4c4d063f1d..020efbb2d787 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,6 +125,8 @@ Main (unreleased) - Fixed the `agent_prometheus_scrape_targets_gauge` incorrectly reporting all discovered targets instead of targets that belong to current instance when clustering is enabled. (@thampiotr) +- Fixed race condition in cleaning up metrics when stopping to tail files in static mode. (@thampiotr) + ### Other changes - Use Go 1.21.1 for builds. (@rfratto) diff --git a/converter/internal/promtailconvert/internal/build/loki_write.go b/converter/internal/promtailconvert/internal/build/loki_write.go index 76dc2d6555e4..d7016d3bbc8c 100644 --- a/converter/internal/promtailconvert/internal/build/loki_write.go +++ b/converter/internal/promtailconvert/internal/build/loki_write.go @@ -38,14 +38,6 @@ func toLokiWriteArguments(config *client.Config, diags *diag.Diagnostics) *lokiw ) } - // Also deprecated in promtail. - if len(config.StreamLagLabels) != 0 { - diags.Add( - diag.SeverityLevelWarn, - "stream_lag_labels is deprecated and the associated metric has been removed", - ) - } - return &lokiwrite.Arguments{ Endpoints: []lokiwrite.EndpointOptions{ { diff --git a/converter/internal/promtailconvert/testdata/unsupported.diags b/converter/internal/promtailconvert/testdata/unsupported.diags index 0fb47e2addab..f0c69dee70ae 100644 --- a/converter/internal/promtailconvert/testdata/unsupported.diags +++ b/converter/internal/promtailconvert/testdata/unsupported.diags @@ -1,5 +1,4 @@ (Error) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory -(Warning) stream_lag_labels is deprecated and the associated metric has been removed (Error) Promtail's WAL is currently not supported in Flow Mode (Error) limits_config is not yet supported in Flow Mode (Warning) If you have a tracing set up for Promtail, it cannot be migrated to Flow Mode automatically. Refer to the documentation on how to configure tracing in Flow Mode. @@ -8,5 +7,4 @@ (Warning) The Agent's Flow Mode metrics are different from the metrics emitted by Promtail. If you rely on Promtail's metrics, you must change your configuration, for example, your alerts and dashboards. (Warning) server.log_level is not supported - Flow mode components may produce different logs (Error) server.http_path_prefix is not supported -(Warning) server.health_check_target disabling is not supported in Flow mode -(Warning) stream_lag_labels is deprecated and the associated metric has been removed \ No newline at end of file +(Warning) server.health_check_target disabling is not supported in Flow mode \ No newline at end of file diff --git a/converter/internal/promtailconvert/testdata/unsupported.yaml b/converter/internal/promtailconvert/testdata/unsupported.yaml index c7bbabc25e06..b0d30300fce3 100644 --- a/converter/internal/promtailconvert/testdata/unsupported.yaml +++ b/converter/internal/promtailconvert/testdata/unsupported.yaml @@ -5,11 +5,8 @@ global: clients: - url: http://localhost/loki/api/v1/push drop_rate_limited_batches: true - stream_lag_labels: hare,tortoise positions: filename: /dev/urandom -options: - stream_lag_labels: hare,tortoise wal: enabled: true limits_config: diff --git a/converter/internal/promtailconvert/validate.go b/converter/internal/promtailconvert/validate.go index 3d65c5fed11f..472d3d4bdc37 100644 --- a/converter/internal/promtailconvert/validate.go +++ b/converter/internal/promtailconvert/validate.go @@ -17,14 +17,6 @@ func validateTopLevelConfig(cfg *promtailcfg.Config, diags *diag.Diagnostics) { ) } - // The global and per-client stream lag labels is deprecated and has no effect. - if len(cfg.Options.StreamLagLabels) > 0 { - diags.Add( - diag.SeverityLevelWarn, - "stream_lag_labels is deprecated and the associated metric has been removed", - ) - } - // WAL support is still work in progress and not documented. Enabling it won't work, so it's an error. if cfg.WAL.Enabled { diags.Add( diff --git a/go.mod b/go.mod index dff5da8a8771..5def1bf2ffd5 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 github.com/grafana/dskit v0.0.0-20230829141140-06955c011ffd github.com/grafana/go-gelf/v2 v2.0.1 - github.com/grafana/loki v1.6.2-0.20230904153656-e4cc2a4f5ec8 // k166 branch + github.com/grafana/loki v1.6.2-0.20230927083715-42fba5b19183 // k169 branch github.com/grafana/pyroscope-go/godeltaprof v0.1.3 github.com/grafana/pyroscope/api v0.2.0 github.com/grafana/pyroscope/ebpf v0.2.1 diff --git a/go.sum b/go.sum index 6af0244363d7..e10a9912a7d9 100644 --- a/go.sum +++ b/go.sum @@ -1587,8 +1587,8 @@ github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85/go.mod h1:crI9WX6p0IhrqB+DqIUHulRW853PaNFf7o4UprV//3I= github.com/grafana/gomemcache v0.0.0-20230316202710-a081dae0aba9 h1:WB3bGH2f1UN6jkd6uAEWfHB8OD7dKJ0v2Oo6SNfhpfQ= github.com/grafana/gomemcache v0.0.0-20230316202710-a081dae0aba9/go.mod h1:PGk3RjYHpxMM8HFPhKKo+vve3DdlPUELZLSDEFehPuU= -github.com/grafana/loki v1.6.2-0.20230904153656-e4cc2a4f5ec8 h1:ER13f09dUfAbAN+zQdKgUdRSrvUC97G3OX2y6/qrtII= -github.com/grafana/loki v1.6.2-0.20230904153656-e4cc2a4f5ec8/go.mod h1:qqOYLjJ9m92TqjWO5IOsEm6B7AodORoc9IZUC5Q4Caw= +github.com/grafana/loki v1.6.2-0.20230927083715-42fba5b19183 h1:klVM7g0Tl31QSd9dvypCe5XAQ49AM+acGAH2DwXdllA= +github.com/grafana/loki v1.6.2-0.20230927083715-42fba5b19183/go.mod h1:hiGUcnMCZ86m122rzu8xySnRiGDQ8TzPowVmCvWZAJ4= github.com/grafana/loki/pkg/push v0.0.0-20230904153656-e4cc2a4f5ec8 h1:yQK/dX7WBva5QvITvmIcbv4boLwSo65a8zjuZcucnko= github.com/grafana/loki/pkg/push v0.0.0-20230904153656-e4cc2a4f5ec8/go.mod h1:5ll3An1wAxYejo6aM04+3/lc6N4joYVYLY5U+Z4O6vI= github.com/grafana/mysqld_exporter v0.12.2-0.20201015182516-5ac885b2d38a h1:D5NSR64/6xMXnSFD9y1m1DPYIcBcHvtfeuI9/M/0qtI=