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

datadog-agent: fix extraIntegrations #63864

Merged
merged 1 commit into from Aug 12, 2019

Conversation

cransom
Copy link
Contributor

@cransom cransom commented Jun 27, 2019

The override that builds the custom python for integrations-core was overriding python, but pythonPackages was still being inherited from a call to datadog-integrations-core {}, causing service.datadog-agent.extraIntegrations to be ignored.

Motivation for this change

services.datadog-agent.extraIntegrations failed to include varnish related files from datadogs integration-core repo when I tried to include varnish.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

There isn't an integrated nixos test for datadog, but you can run the daemon and validate scripts without a functional API key or network access (assuming the checks don't need external network access). I used this snippet to validate my varnish change succeeded.

import <nixpkgs/nixos/tests/make-test.nix> ({ pkgs, ...} : {
  name = "datadog";

  nodes = {
    machine =
      { ... }:
      {
        imports = [ ../modules/profiles/minimal.nix ];
        services.datadog-agent.enable = true;
        users.groups.varnish.members = [ "datadog" ];
        services.datadog-agent.apiKeyFile = "/dev/null";
        services.datadog-agent.extraIntegrations = {
          varnish = (ps: [ ]);
        };
        services.datadog-agent.checks = {
          varnish = {
            init_config = {};
            instances = [{
              varnishstat = "${pkgs.varnish}/bin/varnishstat";
            }];
          };
        };
        services.varnish.enable = true;
        services.varnish.config = ''
          vcl 4.0;
          backend foo {
            .host = "127.0.0.1";
            .port = "8080";
          }
        '';
      };
    };

    testScript = ''
      startAll;
      $machine->waitForUnit("varnish.service");
      $machine->succeed("sleep 30");
      $machine->fail("journalctl -b -u datadog-agent | grep -q 'Error running check varnish'");
    '';
  })

@cransom cransom force-pushed the datadog-agent-integrations-fix branch from 37d45a8 to cf404c7 Compare July 1, 2019 15:27
@cransom
Copy link
Contributor Author

cransom commented Jul 1, 2019

@JohnAZoidberg I switched the doc string (python -> pythonPackages) and removed the comment about needing to override python. The python interpreter will come from the pythonPackages supplied rather than implying it should be something else.

@JohnAZoidberg
Copy link
Member

Ah yeah right, you can't remove the second line. But I think it doesn't need to be inside the derivation - you can move it up into the let expression.

The override that builds the custom python for integrations-core was
overriding python, but pythonPackages was still being inherited from a
call to `datadog-integrations-core {}`, causing
service.datadog-agent.extraIntegrations to be ignored.
@cransom cransom force-pushed the datadog-agent-integrations-fix branch from cf404c7 to 35d58c3 Compare July 1, 2019 15:45
@cransom
Copy link
Contributor Author

cransom commented Jul 1, 2019

shuffled python into the let.

@cransom
Copy link
Contributor Author

cransom commented Aug 5, 2019

anything else to address?

@grahamc grahamc merged commit 5d807f8 into NixOS:master Aug 12, 2019
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.

None yet

3 participants