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

Fix Ruler not starting and incorrect mkdir path when Thanos Store is enabled #16555

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ringerc
Copy link

@ringerc ringerc commented Mar 5, 2025

What this PR does / why we need it:

As discussed in #16543, loki does not completely switch from using the ruler_storage configuration block when -use-thanos-objstore=true or storage_config.use_thanos_objstore: true is set.

It still uses the non-thanos-store config block ruler.storage to:

  • find the path to mkdir for local rules storage during startup; and
  • decide whether the ruler is configured and should be started in the all and backend targets

Fix both issues, so ruler.storage is completely ignored when in thanos mode.

Also add a warning when one of the config blocks is being overridden, but is non-empty, like:

level=warn ts=2025-03-05T03:42:56.185427635Z caller=modules.go:1320 msg="ruler.storage exists and is not empty, but will be ignored in favour of ruler_storage because storage_config.use_thanos_objstore is true."

and the inverse.

See also related docs change #16553

Fixes bug introduced in 8bca2e7 (#11713) per #16543 (comment)

This should be backported to v3.3.x and v3.4.x, possibly except the warning, since it's present in all releases containing the above commit.

Which issue(s) this PR fixes:

Fixes #16543

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@ringerc ringerc requested a review from a team as a code owner March 5, 2025 03:38
ringerc added 3 commits March 5, 2025 16:38
The ruler will fail to start in "all" or "backend" startup target
with message "Ruler storage is not configured; ruler will not be
started" if Loki is configured to use the Thanos object store.

The ruler configuration should be read from the 'ruler_storage' top
level config key when thanos object store is enabled (-use-thanos-objstore=true
or storage_config.use_thanos_objstore: true in the config file).

A bug in the ruler-storage module startup check meant that the
ruler.storage block that's supposed to be ignored in thanos storage
mode was still being used to check whether the ruler was configured.
So a placeholder ruler.storage block had to be provided to get the ruler
to start, even though it would be ignored by ruler itself.

Fix, so the ruler.storage block is completely ignored and can be
entirely removed when thanos client is in use.
When the ruler-storage module starts, it tries to mkdir the local
storage directory. This was not updated to use the path from
the ruler_storage block when the thanos object store is enabled,
and was still using the otherwise-ignored ruler.storage block instead.

Fix so it properly uses ruler_storage.filesystem.dir or
ruler_storage.local.directory when in thanos storage mode, ignoring
the non-thanos-store ruler.storage.local.directory.
Emit a warning if ruler.storage is defined but ignored because
object_store.use_thanos_client: true causes the ruler_storage block
to be used instead. And vice versa when the ruler_storage config only
used with the thanos client is present, but the thanos client is not
enabled.

This is particularly important for ruler, because the thanos object
store client setting affects which ruler storage block is used even
when ruler is just using the local file system as a store.

The new warning looks like this:

    level=warn msg="ruler.storage exists and is not empty, but will be ignored in favour of ruler_storage because storage_config.use_thanos_objstore is true."
@ringerc ringerc force-pushed the fix-thanos-store-ruler-config branch from 334c5bb to 2ab01c1 Compare March 5, 2025 03:45
@ringerc ringerc changed the title Fix thanos store ruler config Fix Ruler not starting and incorrect mkdir path when Thanos Store is enabled Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant