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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/loki: Implement configuration verification #311999

Merged
merged 1 commit into from
May 16, 2024

Conversation

jpds
Copy link
Contributor

@jpds jpds commented May 15, 2024

Description of changes

Fixes: #293088

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 馃憤 reaction to pull requests you find important.

@drupol drupol merged commit 84d184a into NixOS:master May 16, 2024
23 checks passed
@@ -99,9 +99,16 @@ in {
conf = if cfg.configFile == null
then prettyJSON cfg.configuration
else cfg.configFile;
validateConfig = file:
pkgs.runCommand "validate-loki-conf" {
nativeBuildInputs = [ pkgs.grafana-loki ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use cfg.package not pkgs.grafana-loki :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll provide the PR to fix this, I should have seen this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjm
Copy link
Contributor

mjm commented May 18, 2024

Can we make this optional? If you use -config.expand-env=true to expand environment variables in your config, the validation may end up failing even though it will be fine at runtime:

failed parsing config: /nix/store/85dzsqn3qjhzqfjmaiz95xgr4x9jag4c-loki-config.json: parse "http://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@garage.service.consul:3902": net/url: invalid userinfo. Use `-config.expand-env=true` flag if you want to expand environment variables in your config file

@emilylange
Copy link
Member

Thanks for reporting!

Taking a second look it's not just services.loki.extraFlags that breaks it.
The use of services.loki.configFile will error out as well.

services.loki.configFile is a string of a path that is not copied to the build sandbox.
It may only exist on the destination host, or only after the action script, etc.

I am tempted to add a conditional to only ever run that config validation/verification step if both cfg.extraFlags == [] and cfg.configFile == null are true.
I can't think of other cases were the validation step would fail.

Not sure if you are asking for a boolean option in services.loki.
But I think I would prefer it to have it somewhat "automagical".

Will open a PR with my proposed fix shortly.

@mjm
Copy link
Contributor

mjm commented May 19, 2024

I was thinking of a boolean option, similar to services.prometheus.checkConfig. But your automatic suggestion would work for me just as well.

@emilylange
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

services/loki: Configuration verification
4 participants