swarm-otel: scrape the authenticated targets only once the collector has its client secret
An empty secret file made the prometheus receiver request a token for each published target every scrape; authelia's per-address limit then refused every client behind that address. Without a secret the collector starts on the config minus those jobs. full-setup asserts the limiter never fired.
This commit is contained in:
parent
9237948c2c
commit
480855dfaf
1 changed files with 157 additions and 4 deletions
|
|
@ -466,6 +466,44 @@ let
|
|||
&& lib.any (p: builtins.elem "otlphttp/victorialogs" p.exporters) ps
|
||||
&& lib.any (p: builtins.elem "otlphttp/victoriametrics" p.exporters) ps;
|
||||
}
|
||||
{
|
||||
# An empty secret file makes the prometheus receiver request a token
|
||||
# anyway, once per authenticated scrape target per minute. So the unit
|
||||
# starts through a wrapper that drops those jobs while the secret is
|
||||
# empty. Presence arms: every published job is in the full config, the
|
||||
# loopback job survives the drop, and the unit's start is the wrapper
|
||||
# (the same unit's `LoadCredential` is asserted by the cases above).
|
||||
name = "a swarm collector with no client secret yet does not scrape the targets that need one";
|
||||
ok =
|
||||
let
|
||||
scrapeWithoutJobs = import ../host-modules/lib/scrape-without-jobs.nix { inherit lib; };
|
||||
full = otelSettings otelNoStores;
|
||||
published = lib.attrNames otelNoStores.services.hyperhive.swarm.otel.publishedScrapeTargets;
|
||||
pipeline = "metrics/${otelNoStores.services.hyperhive.swarm.otel.producerName}";
|
||||
jobsOf = s: map (j: j.job_name) s.receivers.prometheus.config.scrape_configs;
|
||||
dropped = scrapeWithoutJobs {
|
||||
settings = full;
|
||||
jobs = published;
|
||||
inherit pipeline;
|
||||
};
|
||||
everything = scrapeWithoutJobs {
|
||||
settings = full;
|
||||
jobs = jobsOf full;
|
||||
inherit pipeline;
|
||||
};
|
||||
in
|
||||
published != [ ]
|
||||
&& lib.all (j: lib.elem j (jobsOf full)) published
|
||||
&& lib.all (j: !(lib.elem j (jobsOf dropped))) published
|
||||
&& lib.elem "collector" (jobsOf dropped)
|
||||
&& lib.elem pipeline (lib.attrNames dropped.service.pipelines)
|
||||
&& !(everything.receivers ? prometheus)
|
||||
&& !(everything.service.pipelines ? ${pipeline})
|
||||
&& lib.elem pipeline (lib.attrNames full.service.pipelines)
|
||||
&& lib.hasInfix "opentelemetry-collector-start" (
|
||||
toString otelNoStores.containers.swarm-otel.config.systemd.services.opentelemetry-collector.serviceConfig.ExecStart
|
||||
);
|
||||
}
|
||||
];
|
||||
in
|
||||
runGroup "swarm-otel-core" cases
|
||||
|
|
|
|||
Loading…
Reference in a new issue