nixos: comin deploys only signed commits
All checks were successful
nixos / nixos (push) Successful in 20s
All checks were successful
nixos / nixos (push) Successful in 20s
The head of main must carry the admin's GPG signature or Renovate's SSH signature (nixos/keys), so write access to the repository alone, such as renovate-bot's API token, no longer reaches root on the hosts. comin skips an unsigned head without a metric of its own, so a timer exports whether the head is signed and whether it still waits for evaluation; both alert. Assisted-by: Claude:opus-5-5
This commit is contained in:
parent
29dcc8915a
commit
0137dec4fb
4 changed files with 127 additions and 1 deletions
|
|
@ -198,6 +198,38 @@ groups:
|
|||
for: 15m
|
||||
labels: { severity: warning }
|
||||
annotations: { summary: "{{ $labels.host }}: {{ $labels.__name__ }} (comin status on the host)" }
|
||||
- uid: deploy-unsigned
|
||||
title: "Deploy waiting: main not signed"
|
||||
condition: C
|
||||
data:
|
||||
- refId: A
|
||||
relativeTimeRange: { from: 900, to: 0 }
|
||||
datasourceUid: prometheus
|
||||
model: { refId: A, expr: "comin_main_signed", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
||||
- refId: C
|
||||
datasourceUid: __expr__
|
||||
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: lt, params: [1] } } ] }
|
||||
noDataState: OK
|
||||
execErrState: Error
|
||||
for: 5m
|
||||
labels: { severity: warning }
|
||||
annotations: { summary: "{{ $labels.host }}: the head of main is not signed by a trusted key; comin skips it. Push a signed commit on top (or fast-forward merge Renovate's)." }
|
||||
- uid: deploy-pending
|
||||
title: "Deploy waiting"
|
||||
condition: C
|
||||
data:
|
||||
- refId: A
|
||||
relativeTimeRange: { from: 900, to: 0 }
|
||||
datasourceUid: prometheus
|
||||
model: { refId: A, expr: "comin_main_pending", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
||||
- refId: C
|
||||
datasourceUid: __expr__
|
||||
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
||||
noDataState: OK
|
||||
execErrState: Error
|
||||
for: 30m
|
||||
labels: { severity: warning }
|
||||
annotations: { summary: "{{ $labels.host }}: main has a commit comin has not evaluated for 30 minutes (comin status on the host)" }
|
||||
- uid: replica-stale
|
||||
title: "Bucket replica stale"
|
||||
condition: C
|
||||
|
|
|
|||
1
nixos/keys/allowed_signers
Normal file
1
nixos/keys/allowed_signers
Normal file
|
|
@ -0,0 +1 @@
|
|||
renovate-bot@noreply.git.asxp.io namespaces="git" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGNU5oWCoNXWbakm9ebBcN6ZO2X504tcPl7i7Xcy6lKX
|
||||
51
nixos/keys/asxpi.asc
Normal file
51
nixos/keys/asxpi.asc
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBGPRz1EBEADKNilYX6XWSSqKrPUcOzCkJXeipBJKckzV3AuYB4iJv3TsdKUb
|
||||
z65fP2El3nRfGKtNe0nth9tHq52pNlqsyykPhwgLPrOU23cP+IhrZINVY6ORYK+O
|
||||
NctnL9rOrFj/i34dtSNzr8GSIdzBmtU/EHbRSqi2lV9YeoH1boBnMUzpu70FhMZ7
|
||||
BnMbJsYla8lfCtJSdO8Ja5QlWzwgNBDh2ZwObpnbW1xQ9moN8KNrVOIK2yV3gb5n
|
||||
DOb4MQWomEobZfc7596jTM7YR+s6Ymx6nC8cjmyMBHNdkd5JB/TRndtEJlsvazGR
|
||||
aQtlR1/a6FsvCRrrlwRiIjf7Mw2c3t5eBd6kV3NmlTAXAEoAKpbjIzVUm6ZiOukf
|
||||
Y/ShxWgEXzwpFwq1b64s3u4lLSH6bpcD/Zw7unphscQmRNe8jdaq2UU5UJGqHqzx
|
||||
y7vt57mwXGgrz2plQvy9izoYTslwuPlqI13J2DOQ6TufpdWfgVVSxUolwMscoRXl
|
||||
y0wSzb12rsSoSsaJHqL04AGRS2Q3czXP9j6Jc4rMNaD1Pj0WcABhhimCVhvbCFOg
|
||||
NPsYULp+I1h1YvGEycpoHFu/eIQIuazO+YiQ5V9m+Gg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Ukw6aSsIzkbe6v60jk/r46ecr5KUluFJQofrDdSK
|
||||
jxN/Ebncx4kY6Lu37s58u8CpEuUK9/W5jRoOmsS2J1onOGu9a2jQVcRHsQFwYJ/y
|
||||
wTmYMHNyIOnLzdVk/cqylISW1JgtQeAEX2gHEC/NKzAxNi8ePxEMM/3hcTxBk9vZ
|
||||
jmJIEEy4CPSU+LibzoOmPIJQpaCtxcMLnQEfNi0O06gHCG6pkbY8AmeZ8TMMnB0r
|
||||
3ldrATVPIbZJEbbArkyUIQ1TCJio9AdeJuCGAwVuWvQyy2MDuoypJqBWm1Ais6X3
|
||||
PxQfxvRSS8GgqnjrY1ov7JYG6AwWO5QbjcoM/5KhfQpVjv8Yvpj0uY0P/W95MVwx
|
||||
22pOAoO2mrASW3K+ckkXNHai5nWCeUy5t08b6rhzZ4AOpppuPSPE1B4fbhqmW8Pz
|
||||
=AeW/
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
|
|
@ -3,7 +3,18 @@
|
|||
# evaluates. A branch testing-<hostname> on top of main is applied with
|
||||
# `test` (not the boot default) to that host alone: try a change there,
|
||||
# then merge it. `comin status` on the host shows what it is doing.
|
||||
{ config, ... }:
|
||||
#
|
||||
# Only a signed head is deployed: the admin's GPG key or Renovate's SSH
|
||||
# key (../keys). Anything else on main waits, and alerts (comin.prom).
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
textfile = "/var/lib/node_exporter/textfile";
|
||||
in
|
||||
{
|
||||
services.comin = {
|
||||
enable = true;
|
||||
|
|
@ -14,6 +25,8 @@
|
|||
}
|
||||
];
|
||||
repositorySubdir = "nixos";
|
||||
gpgPublicKeyPaths = [ "${../keys/asxpi.asc}" ];
|
||||
sshAllowedSignersPath = "${../keys/allowed_signers}";
|
||||
# Prometheus on ops scrapes it over the private network
|
||||
exporter = {
|
||||
listen_address = config.asxpio.privateIPv4;
|
||||
|
|
@ -21,5 +34,34 @@
|
|||
};
|
||||
};
|
||||
|
||||
# What comin's own metrics leave out: whether the head of main is
|
||||
# signed, and whether it is still waiting to be evaluated
|
||||
systemd.services.comin-metrics = {
|
||||
description = "comin state for Prometheus";
|
||||
after = [ "comin.service" ];
|
||||
path = [
|
||||
config.services.comin.package
|
||||
pkgs.jq
|
||||
];
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
comin status --json | jq -r '
|
||||
.fetcher.repository_status as $r
|
||||
| ([$r.remotes[] | select(.name == "origin") | .main.commit_id][0]) as $head
|
||||
| "# HELP comin_main_signed Head of main carries a trusted signature (1) or not (0).",
|
||||
"# TYPE comin_main_signed gauge",
|
||||
"comin_main_signed \(if ($r.selected_commit_should_be_signed | not) or $r.selected_commit_signed then 1 else 0 end)",
|
||||
"# HELP comin_main_pending Head of main differs from the last evaluated commit.",
|
||||
"# TYPE comin_main_pending gauge",
|
||||
"comin_main_pending \(if $head == .builder.generation.selected_commit_id then 0 else 1 end)"
|
||||
' > ${textfile}/comin.prom.tmp
|
||||
mv ${textfile}/comin.prom.tmp ${textfile}/comin.prom
|
||||
'';
|
||||
};
|
||||
systemd.timers.comin-metrics = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig.OnCalendar = "*:0/2";
|
||||
};
|
||||
|
||||
asxpio.security.ports = [ "tcp/4243/comin" ];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue