start the container journal forwarder's collector from its secret fetch, with backoff
This commit is contained in:
parent
052c46ab25
commit
a0deb29e59
1 changed files with 51 additions and 7 deletions
|
|
@ -275,14 +275,29 @@ in
|
|||
# `RestartSec` is ours: the 100ms default burns the start-rate limit while
|
||||
# the secret is still on its way, leaving the unit failed instead of
|
||||
# retrying.
|
||||
systemd.services.opentelemetry-collector.serviceConfig = {
|
||||
LoadCredential = [ "${credentialId}:${credentialSource}" ];
|
||||
RestartSec = 15;
|
||||
};
|
||||
systemd.services.opentelemetry-collector = lib.mkMerge [
|
||||
{
|
||||
serviceConfig = {
|
||||
LoadCredential = [ "${credentialId}:${credentialSource}" ];
|
||||
RestartSec = 15;
|
||||
};
|
||||
}
|
||||
# With a fetched secret the collector is not part of the boot
|
||||
# transaction: `LoadCredential` refuses a missing file, and a unit that
|
||||
# failed on it before the secret landed is not started again by its
|
||||
# `Restart=`. The fetch starts the collector once it has written the
|
||||
# secret, so the guest reaches READY without waiting on the store.
|
||||
(lib.mkIf fetchesHere {
|
||||
wantedBy = lib.mkForce [ ];
|
||||
after = [ "${fetchUnit}.service" ];
|
||||
})
|
||||
];
|
||||
|
||||
# Reads the client secret with the container's own store identity. A store
|
||||
# or authelia that is not up yet is a failed run that retries
|
||||
# (../host-modules/lib/store-retry.nix), and a collector that restarts until the file lands.
|
||||
# that is not up yet fails the attempt in seconds, which keeps the guest's
|
||||
# boot short, and ../host-modules/lib/store-retry.nix starts it again with
|
||||
# a growing delay until the store answers. The attempt that succeeds
|
||||
# starts the collector.
|
||||
systemd.services.${fetchUnit} = lib.mkIf fetchesHere {
|
||||
description = "fetch this container's journal forwarder OIDC client secret from the swarm secret store";
|
||||
after = [ "network-online.target" ];
|
||||
|
|
@ -300,7 +315,13 @@ in
|
|||
# an active unit is a no-op.
|
||||
Type = "oneshot";
|
||||
SyslogIdentifier = fetchUnit;
|
||||
# Bounds one attempt, and so the guest's boot when the store is down.
|
||||
TimeoutStartSec = 30;
|
||||
# Each attempt is a store login: the delay grows from `RestartSec` to
|
||||
# `RestartMaxDelaySec` over `RestartSteps` restarts (systemd.service(5)).
|
||||
RestartSec = 5;
|
||||
RestartSteps = 6;
|
||||
RestartMaxDelaySec = 300;
|
||||
};
|
||||
environment = {
|
||||
BAO_ADDR = cfg.store.addr;
|
||||
|
|
@ -349,6 +370,10 @@ in
|
|||
# `LoadCredential` copies the file at start only: a rotated secret
|
||||
# reaches the collector by restarting it.
|
||||
refresh_unit opentelemetry-collector.service ${lib.escapeShellArg secretFile}
|
||||
|
||||
# Not in the boot transaction (`wantedBy` is forced empty above), so
|
||||
# nothing else starts it. A running collector is untouched by this.
|
||||
systemctl start --no-block opentelemetry-collector.service
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue