From 42b985e07bcffdf642ff4e0e6ac7b55a9727b1f4 Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 4 Dec 2026 00:15:47 -0500 Subject: [PATCH 01/10] ci(backup): build a pinned backup-tools image (rsync/ssh/bash/kubectl baked in) The three nightly backups (grafana-backup, cluster-backup, leadgen-backup) installed rsync + openssh-client with apk at container start, so every run depended on the Alpine CDN (Fastly anycast 151.101.x.132:443) and moved the egress-new-dst alert whenever that anycast address rotated. This adds the build only; the CronJob pins land in the next commit. Base image python:3.12-alpine pinned by digest, kubectl v1.36.4 from dl.k8s.io with its release sha256, amd64 only (all three jobs are nodeSelector'd to siriussec). --- .forgejo/workflows/backup-image.yml | 80 +++++++++++++++++++++++++++++ images/backup/Dockerfile | 49 ++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 .forgejo/workflows/backup-image.yml create mode 100644 images/backup/Dockerfile diff --git a/.forgejo/workflows/backup-image.yml b/.forgejo/workflows/backup-image.yml new file mode 100644 index 0000000..c55aadd --- /dev/null +++ b/.forgejo/workflows/backup-image.yml @@ -0,0 +1,80 @@ +name: backup-image +# Builds the backup tooling image used by the three nightly CronJobs +# (monitoring/grafana-backup, forgejo/cluster-backup, sirius-growth/leadgen-backup). +# +# Why this is a CI build at all (card t_9d0428d8): the jobs used to run +# `apk add rsync openssh-client` at container start, so the backup depended on +# the Alpine CDN at run time. Everything is baked here instead, from a base +# image pinned by digest, and the manifests pin the resulting image by digest. +# +# CI has no cluster credentials: this job only pushes an immutable :$sha tag to +# the in-cluster Forgejo registry and prints the digest to pin. The operator +# copies that digest into the three CronJob manifests in this same repo. +# +# amd64 only, on purpose: all three Jobs are nodeSelector'd to siriussec and +# the baked kubectl release checksum is amd64. Nothing here runs on rpi. + +on: + push: + branches: [master] + paths: + - 'images/backup/**' + - '.forgejo/workflows/backup-image.yml' + workflow_dispatch: + +jobs: + build: + runs-on: docker-amd64 + steps: + - uses: actions/checkout@v4 + + # The job image (node:20-bullseye) has no docker CLI of its own; the + # runner mounts the dind sidecar's client and cli-plugins. Verify both + # instead of assuming, and fail loudly rather than half-pushing. + - name: Verify docker CLI + buildx + run: | + set -euo pipefail + command -v docker + docker version + docker buildx version + + - name: Build and push (amd64, no attestation manifests) + env: + REG_USER: ${{ secrets.REGISTRY_USER }} + REG_PASS: ${{ secrets.REGISTRY_TOKEN }} + run: | + set -euo pipefail + sha=$(git rev-parse HEAD) + image=forgejo.siriusdevops.com/sirius/backup-tools + user="${REG_USER:-sirius}" + pass="${REG_PASS:-${{ github.token }}}" + echo "$pass" | docker login forgejo.siriusdevops.com -u "$user" --password-stdin + # --provenance=false --sbom=false: the tag must resolve to the single + # amd64 image manifest, so the digest a CronJob pins is exactly the + # image the pod runs (an index digest would resolve per-arch). + docker buildx build --platform linux/amd64 \ + --provenance=false --sbom=false \ + -t "$image:$sha" \ + --push images/backup + echo "pushed $image:$sha" + + - name: Print the digest to pin + env: + REG_USER: ${{ secrets.REGISTRY_USER }} + REG_PASS: ${{ secrets.REGISTRY_TOKEN }} + run: | + set -euo pipefail + sha=$(git rev-parse HEAD) + image=forgejo.siriusdevops.com/sirius/backup-tools + user="${REG_USER:-sirius}" + pass="${REG_PASS:-${{ github.token }}}" + echo "$pass" | docker login forgejo.siriusdevops.com -u "$user" --password-stdin + digest=$(docker buildx imagetools inspect "$image:$sha" --format '{{.Manifest.Digest}}') + echo "BACKUP_TOOLS_DIGEST=$digest" + { + echo "### Pin this in the three backup CronJob manifests" + echo "" + echo '```' + echo "$image@$digest" + echo '```' + } | tee -a "${GITHUB_STEP_SUMMARY:-/dev/stdout}" diff --git a/images/backup/Dockerfile b/images/backup/Dockerfile new file mode 100644 index 0000000..66b6bd6 --- /dev/null +++ b/images/backup/Dockerfile @@ -0,0 +1,49 @@ +# Backup tooling image for the three nightly state-backup CronJobs +# (monitoring/grafana-backup, forgejo/cluster-backup, sirius-growth/leadgen-backup). +# +# Why this exists (card t_9d0428d8): every one of those jobs used to run +# `apk add --no-cache rsync openssh-client` at container start, which dialled +# dl-cdn.alpinelinux.org (Fastly anycast 151.101.x.132:443) on every run. That +# made the nightly backup depend on the public internet, tripped the +# `egress-new-dst` flow alert whenever Fastly rotated an address, and put a +# package install on the one pod that carries the Grafana PVC and an SSH key. +# The toolchain is baked in at build time instead, and the pods get an egress +# NetworkPolicy that admits DNS + the backup host only. +# +# Base image is pinned by digest (multi-arch index digest; this build is +# linux/amd64 because all three jobs are nodeSelector'd to siriussec). +FROM python:3.12-alpine@sha256:c5ba3deef00c7758561a0f03c26f44f10589263d40e732b8748e0d1f38f6dd89 + +# kubectl is needed by forgejo/cluster-backup only (CNPG `get cluster` + +# `exec` pg_dump); the cluster runs v1.36.4, so the client is pinned to the +# same minor and its release checksum is verified at build time. +ARG KUBECTL_VERSION=v1.36.4 +ARG KUBECTL_SHA256=8b8f088da2dab964f853b38464033b1be15ede2839eca751482357c45abdd05a + +LABEL org.opencontainers.image.title="backup-tools" \ + org.opencontainers.image.description="python3.12-alpine + rsync + openssh-client + bash + kubectl for the nightly state backups" \ + org.opencontainers.image.source="https://forgejo.siriusdevops.com/sirius/homek8s" + +RUN set -eux; \ + # bash: cluster-backup and leadgen-backup use arrays, `set -o pipefail` + # and `tee >(...)` process substitution, so /bin/sh (busybox ash) is not + # enough -- the CronJob entrypoints stay /bin/bash, unchanged. + apk add --no-cache rsync openssh-client bash; \ + test "${TARGETARCH:-amd64}" = "amd64" || { echo "kubectl pin is amd64-only; the backup jobs run on siriussec" >&2; exit 1; }; \ + apk add --no-cache --virtual .fetch curl ca-certificates; \ + curl -fsSL -o /usr/local/bin/kubectl \ + "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"; \ + echo "${KUBECTL_SHA256} /usr/local/bin/kubectl" | sha256sum -c -; \ + chmod 0755 /usr/local/bin/kubectl; \ + apk del .fetch; \ + rm -rf /var/cache/apk/* + +# Build-time proof that nothing has to be installed at run time. +RUN set -eux; \ + rsync --version | head -1; \ + ssh -V; \ + bash --version | head -1; \ + python3 --version; \ + kubectl version --client + +CMD ["/bin/sh"] From d44ca50dd1722200e6bef745ca08a6e17484848d Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 4 Dec 2026 00:19:06 -0500 Subject: [PATCH 02/10] ci(backup): take the pushed digest from buildx metadata, not imagetools Forgejo's /v2/token answers 403 to the scope set buildx imagetools uses (measured on this registry), while push and kubelet pull work. The metadata file is the authoritative digest of the manifest the registry just accepted. --- .forgejo/workflows/backup-image.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.forgejo/workflows/backup-image.yml b/.forgejo/workflows/backup-image.yml index c55aadd..6be2909 100644 --- a/.forgejo/workflows/backup-image.yml +++ b/.forgejo/workflows/backup-image.yml @@ -52,24 +52,18 @@ jobs: # --provenance=false --sbom=false: the tag must resolve to the single # amd64 image manifest, so the digest a CronJob pins is exactly the # image the pod runs (an index digest would resolve per-arch). + # --metadata-file carries the pushed manifest digest. Do NOT read it + # back with `buildx imagetools inspect`: Forgejo's /v2/token answers + # 403 to that scope set (measured), while push and kubelet pull are + # fine. docker buildx build --platform linux/amd64 \ --provenance=false --sbom=false \ -t "$image:$sha" \ - --push images/backup + --push --metadata-file /tmp/build-meta.json images/backup echo "pushed $image:$sha" - - - name: Print the digest to pin - env: - REG_USER: ${{ secrets.REGISTRY_USER }} - REG_PASS: ${{ secrets.REGISTRY_TOKEN }} - run: | - set -euo pipefail - sha=$(git rev-parse HEAD) - image=forgejo.siriusdevops.com/sirius/backup-tools - user="${REG_USER:-sirius}" - pass="${REG_PASS:-${{ github.token }}}" - echo "$pass" | docker login forgejo.siriusdevops.com -u "$user" --password-stdin - digest=$(docker buildx imagetools inspect "$image:$sha" --format '{{.Manifest.Digest}}') + digest=$(tr -d '\n' < /tmp/build-meta.json \ + | sed -n 's/.*"containerimage\.digest": *"\(sha256:[a-f0-9]*\)".*/\1/p') + [ -n "$digest" ] || { echo "::error::no containerimage.digest in build metadata"; cat /tmp/build-meta.json; exit 1; } echo "BACKUP_TOOLS_DIGEST=$digest" { echo "### Pin this in the three backup CronJob manifests" From 0acc089dc33a6f675961c5ee7fe2163fb3328ae9 Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 4 Dec 2026 00:20:34 -0500 Subject: [PATCH 03/10] feat(backup): run the three nightly backups from a pinned image with an egress allow list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit monitoring/grafana-backup, forgejo/cluster-backup and sirius-growth/leadgen-backup all ran `apk add --no-cache rsync openssh-client` at container start. Every night that dialled dl-cdn.alpinelinux.org (Fastly anycast 151.101.x.132:443), which is what `egress-new-dst` kept reporting, and made the backups depend on the public internet at 03:00 UTC. - image: forgejo.siriusdevops.com/sirius/backup-tools, built in CI from python:3.12-alpine (pinned by digest) + rsync + openssh-client + bash + kubectl v1.36.4 (release sha256 verified at build). Pinned by digest in all three CronJobs, no apk in any backup path. - egress: CiliumNetworkPolicy per backup pod — cluster DNS and 10.10.0.5:22 for all three, plus kube-apiserver 6443/443 for cluster-backup only, with an explicit deny for `world` (Cilium unions namespace policies, so the allow list alone would not restrict a pod inside `forgejo`/`sirius-growth`). - monitoring gains the registry pull secret it never needed before; the job now keeps imagePullSecrets: forgejo-pull (SOPS-encrypted in git). Schedules, retention, destination paths, entrypoints and RBAC are unchanged. --- apps/base/forgejo/cluster-backup.yaml | 22 ++++--- apps/base/forgejo/kustomization.yaml | 4 ++ apps/base/forgejo/networkpolicy-backup.yaml | 64 +++++++++++++++++++ apps/base/sirius-growth/kustomization.yaml | 4 ++ apps/base/sirius-growth/leadgen-backup.yaml | 16 +++-- .../sirius-growth/networkpolicy-backup.yaml | 49 ++++++++++++++ .../home/grafana-backup-networkpolicy.yaml | 54 ++++++++++++++++ .../controllers/home/grafana-backup.yaml | 21 ++++-- .../controllers/home/kustomization.yaml | 7 ++ .../home/secret-forgejo-pull.sops.yaml | 23 +++++++ 10 files changed, 242 insertions(+), 22 deletions(-) create mode 100644 apps/base/forgejo/networkpolicy-backup.yaml create mode 100644 apps/base/sirius-growth/networkpolicy-backup.yaml create mode 100644 monitoring/controllers/home/grafana-backup-networkpolicy.yaml create mode 100644 monitoring/controllers/home/secret-forgejo-pull.sops.yaml diff --git a/apps/base/forgejo/cluster-backup.yaml b/apps/base/forgejo/cluster-backup.yaml index 5b1518d..5834af7 100644 --- a/apps/base/forgejo/cluster-backup.yaml +++ b/apps/base/forgejo/cluster-backup.yaml @@ -87,12 +87,10 @@ data: # (the node runs close to DiskPressure and `local-path` lives on it). set -euo pipefail - # alpine/k8s ships kubectl/bash but not rsync/ssh; install them per run - # (~2 s). Nothing else is needed: the DB dumps run inside the CNPG pod. - if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then - echo "== installing rsync + openssh-client" - apk add --no-cache rsync openssh-client >/dev/null - fi + # No package install here on purpose: rsync/openssh-client/bash/kubectl are + # baked into the pinned image (images/backup/Dockerfile) and this pod's + # egress policy admits DNS, 10.10.0.5:22 and the API only, so a runtime + # fetch would fail rather than silently dial the Alpine CDN (t_9d0428d8). BACKUP_HOST=${BACKUP_HOST:-root@10.10.0.5} BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup} @@ -246,16 +244,20 @@ spec: spec: restartPolicy: Never serviceAccountName: cluster-backup + # Pulled from the in-cluster Forgejo registry (which requires auth). + imagePullSecrets: + - name: forgejo-pull # The forgejo-data PVC is local-path on siriussec; the pod must run # where the volume is. nodeSelector: kubernetes.io/hostname: siriussec containers: - name: backup - # alpine/k8s carries kubectl 1.36.4 (== cluster version) so the - # CNPG dumps can be taken through the exec API; rsync + openssh - # are added at start (the pod has normal egress). - image: alpine/k8s:1.36.4 + # python3.12-alpine + rsync + openssh-client + bash + kubectl + # v1.36.4 (== cluster version, so the CNPG dumps can be taken + # through the exec API), all baked at build time and pinned by + # digest. Nothing is installed at run time. + image: forgejo.siriusdevops.com/sirius/backup-tools@sha256:cc8dc1645111b3a80b7c4d5168f6bce3002cae7417b3725683c057976f6e379a imagePullPolicy: IfNotPresent command: ["/bin/bash", "/scripts/backup.sh"] env: diff --git a/apps/base/forgejo/kustomization.yaml b/apps/base/forgejo/kustomization.yaml index 0e4facb..d992e95 100644 --- a/apps/base/forgejo/kustomization.yaml +++ b/apps/base/forgejo/kustomization.yaml @@ -8,6 +8,10 @@ resources: - httproute.yaml # Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919). - networkpolicy.yaml + # Egress lockdown for the cluster-backup pod: DNS + 10.10.0.5:22 + the API + # only. The allow list above cannot be narrowed per pod, so the deny for + # `world` in this policy is what applies to the job (card t_9d0428d8). + - networkpolicy-backup.yaml - pvc.yaml - cluster.yaml - podmonitor.yaml diff --git a/apps/base/forgejo/networkpolicy-backup.yaml b/apps/base/forgejo/networkpolicy-backup.yaml new file mode 100644 index 0000000..b658990 --- /dev/null +++ b/apps/base/forgejo/networkpolicy-backup.yaml @@ -0,0 +1,64 @@ +# Egress lockdown for the nightly cluster-backup CronJob (card t_9d0428d8). +# +# Why: the job used to `apk add --no-cache rsync openssh-client` at container +# start, so each run depended on the Alpine CDN (Fastly 151.101.x.132:443) and +# tripped `egress-new-dst` whenever that anycast address rotated. rsync/ssh/ +# bash/kubectl are baked into images/backup/Dockerfile now. +# +# `forgejo-allow` (networkpolicy.yaml) selects every pod in this namespace and +# allows `world`, so a pod-scoped allow list alone would NOT restrict the job — +# Cilium unions multiple policies. The `egressDeny` for `world` below is what +# actually closes it (deny always beats allow), and it is scoped to this pod by +# the endpointSelector, so Forgejo's own webhooks/mirror/avatar egress is +# untouched. +# +# Allow list, and nothing else: +# * cluster DNS; +# * root@10.10.0.5:22 — the Linode node's InternalIP, so `remote-node`, not +# `world` (the rsync target and every ssh_r call); +# * kube-apiserver on 6443/443 — `kubectl get cluster` for the CNPG primary +# and `kubectl exec ... pg_dump` for both CNPG and the plain Postgres +# Deployment. Port-scoped on purpose: the apiserver shares its host IP with +# the internal Gateway listeners on 8081/8084-8087. +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: cluster-backup-egress + namespace: forgejo + labels: + app: cluster-backup +spec: + description: >- + cluster-backup pod: cluster DNS, SSH to the backup host (10.10.0.5:22) and + the API (6443/443) only; no internet egress at run time. + endpointSelector: + matchLabels: + app: cluster-backup + egress: + - toEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: kube-system + k8s-app: kube-dns + toPorts: + - ports: + - port: "53" + protocol: UDP + - port: "53" + protocol: TCP + - toEntities: + - remote-node + toPorts: + - ports: + - port: "22" + protocol: TCP + - toEntities: + - kube-apiserver + toPorts: + - ports: + - port: "6443" + protocol: TCP + - port: "443" + protocol: TCP + egressDeny: + - toEntities: + - world diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index 6772488..489a444 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -16,6 +16,10 @@ resources: - httproute.yaml # Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919). - networkpolicy.yaml + # Egress lockdown for the leadgen-backup pod: DNS + 10.10.0.5:22 only. The + # allow list above cannot be narrowed per pod, so the deny for `world` in + # this policy is what applies to the job (card t_9d0428d8). + - networkpolicy-backup.yaml # The WAL archive store must exist before the Cluster references it. - objectstore-portal-wal.yaml - cluster.yaml diff --git a/apps/base/sirius-growth/leadgen-backup.yaml b/apps/base/sirius-growth/leadgen-backup.yaml index 70aa0cf..01d3c47 100644 --- a/apps/base/sirius-growth/leadgen-backup.yaml +++ b/apps/base/sirius-growth/leadgen-backup.yaml @@ -20,10 +20,10 @@ data: # Snapshot mirror of /src -> $BACKUP_DIR/leadgen-data// + `latest`. set -euo pipefail - if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then - echo "== installing rsync + openssh-client" - apk add --no-cache rsync openssh-client >/dev/null - fi + # No package install here on purpose: rsync/openssh-client/bash are baked + # into the pinned image (images/backup/Dockerfile) and this pod's egress + # policy admits DNS + 10.10.0.5:22 only, so a runtime fetch would fail + # rather than silently dial the Alpine CDN (card t_9d0428d8). BACKUP_HOST=${BACKUP_HOST:-root@10.10.0.5} BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup} @@ -102,12 +102,18 @@ spec: app: leadgen-backup spec: restartPolicy: Never + # Pulled from the in-cluster Forgejo registry (which requires auth). + imagePullSecrets: + - name: forgejo-pull # The PVC is local-path on siriussec. nodeSelector: kubernetes.io/hostname: siriussec containers: - name: backup - image: alpine/k8s:1.36.4 + # rsync + openssh-client + bash baked at build time, pinned by + # digest (images/backup/Dockerfile). Nothing is installed at run + # time. + image: forgejo.siriusdevops.com/sirius/backup-tools@sha256:cc8dc1645111b3a80b7c4d5168f6bce3002cae7417b3725683c057976f6e379a imagePullPolicy: IfNotPresent command: ["/bin/bash", "/scripts/backup.sh"] env: diff --git a/apps/base/sirius-growth/networkpolicy-backup.yaml b/apps/base/sirius-growth/networkpolicy-backup.yaml new file mode 100644 index 0000000..f13c903 --- /dev/null +++ b/apps/base/sirius-growth/networkpolicy-backup.yaml @@ -0,0 +1,49 @@ +# Egress lockdown for the nightly leadgen-backup CronJob (card t_9d0428d8). +# +# Why: the job used to `apk add --no-cache rsync openssh-client` at container +# start, so each run depended on the Alpine CDN (Fastly 151.101.x.132:443). +# rsync/ssh/bash (+kubectl, unused here) are baked into +# images/backup/Dockerfile now. +# +# `sirius-growth-allow` (networkpolicy.yaml) selects every pod in this +# namespace and allows `world` (Telegram Bot API, the leadgen crawlers), so a +# pod-scoped allow list alone would NOT restrict this job — Cilium unions +# policies. The `egressDeny` for `world` closes it for this pod only; the app +# pods keep their internet access. +# +# Allow list, and nothing else: cluster DNS, and root@10.10.0.5:22 (the Linode +# node's InternalIP — `remote-node`, not `world`) for the rsync mirror. +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: leadgen-backup-egress + namespace: sirius-growth + labels: + app: leadgen-backup +spec: + description: >- + leadgen-backup pod: cluster DNS + SSH to the backup host (10.10.0.5:22) + only; no internet egress at run time. + endpointSelector: + matchLabels: + app: leadgen-backup + egress: + - toEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: kube-system + k8s-app: kube-dns + toPorts: + - ports: + - port: "53" + protocol: UDP + - port: "53" + protocol: TCP + - toEntities: + - remote-node + toPorts: + - ports: + - port: "22" + protocol: TCP + egressDeny: + - toEntities: + - world diff --git a/monitoring/controllers/home/grafana-backup-networkpolicy.yaml b/monitoring/controllers/home/grafana-backup-networkpolicy.yaml new file mode 100644 index 0000000..a2a427b --- /dev/null +++ b/monitoring/controllers/home/grafana-backup-networkpolicy.yaml @@ -0,0 +1,54 @@ +# Egress lockdown for the nightly Grafana sqlite snapshot (card t_9d0428d8). +# +# Why: grafana-backup used to run `apk add --no-cache rsync openssh-client` at +# container start, so every night it dialled the Alpine CDN +# (dl-cdn.alpinelinux.org -> Fastly 151.101.x.132:443) and kept firing the +# `egress-new-dst` flow alert whenever that anycast address rotated. The +# toolchain is now baked into the image (images/backup/Dockerfile) and this +# policy makes any future runtime fetch fail loudly instead of silently +# reaching the internet. +# +# `monitoring` has no namespace-wide default-deny, so selecting the backup pod +# here isolates it on its own: the rules below are the complete egress allow +# list and everything else (including `world`) is dropped. `egressDeny` is +# stated explicitly so the intent survives a future namespace-wide allow being +# added — Cilium deny always beats allow. +# +# Needs: cluster DNS (the script resolves nothing itself, but the image and any +# `ssh` target lookup would), and root@10.10.0.5:22 — that is the Linode node's +# InternalIP, so Cilium classifies it `remote-node`, not `world`. The registry +# pull and the Grafana PVC access are not pod traffic and are unaffected. +apiVersion: cilium.io/v2 +kind: CiliumNetworkPolicy +metadata: + name: grafana-backup-egress + namespace: monitoring + labels: + app: grafana-backup +spec: + description: >- + grafana-backup pod: cluster DNS + SSH to the backup host (10.10.0.5:22) + only; no internet egress at run time. + endpointSelector: + matchLabels: + app: grafana-backup + egress: + - toEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: kube-system + k8s-app: kube-dns + toPorts: + - ports: + - port: "53" + protocol: UDP + - port: "53" + protocol: TCP + - toEntities: + - remote-node + toPorts: + - ports: + - port: "22" + protocol: TCP + egressDeny: + - toEntities: + - world diff --git a/monitoring/controllers/home/grafana-backup.yaml b/monitoring/controllers/home/grafana-backup.yaml index 2da83fb..bf233b3 100644 --- a/monitoring/controllers/home/grafana-backup.yaml +++ b/monitoring/controllers/home/grafana-backup.yaml @@ -27,10 +27,10 @@ data: # T480's root filesystem, the only local file is a ~3 MB copy in /tmp. set -eu - if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then - echo "== installing rsync + openssh-client" - apk add --no-cache rsync openssh-client >/dev/null - fi + # No package install here on purpose: rsync/openssh-client/python3 are + # baked into the pinned image (images/backup/Dockerfile) and this pod's + # egress policy admits DNS + 10.10.0.5:22 only, so a runtime fetch would + # fail rather than silently dial the Alpine CDN (card t_9d0428d8). BACKUP_HOST=${BACKUP_HOST:-root@10.10.0.5} BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup} @@ -128,15 +128,22 @@ spec: app: grafana-backup spec: restartPolicy: Never + # Pulled from the in-cluster Forgejo registry (which requires auth); + # monitoring had no registry pull secret before this job needed one. + imagePullSecrets: + - name: forgejo-pull # The grafana PVC is local-path on siriussec; RWO still allows a # second pod on the same node. nodeSelector: kubernetes.io/hostname: siriussec containers: - name: backup - # python3 alpine: the sqlite backup API is the only consistent - # way to copy a live database without a shell inside Grafana. - image: python:3.12-alpine + # python3.12-alpine + rsync + openssh-client, baked at build time + # and pinned by digest (images/backup/Dockerfile, CI workflow + # .forgejo/workflows/backup-image.yml). The sqlite backup API is + # the only consistent way to copy a live database without a shell + # inside Grafana. Nothing is installed at run time. + image: forgejo.siriusdevops.com/sirius/backup-tools@sha256:cc8dc1645111b3a80b7c4d5168f6bce3002cae7417b3725683c057976f6e379a imagePullPolicy: IfNotPresent command: ["/bin/sh", "/scripts/backup.sh"] env: diff --git a/monitoring/controllers/home/kustomization.yaml b/monitoring/controllers/home/kustomization.yaml index d8c7b27..265058f 100644 --- a/monitoring/controllers/home/kustomization.yaml +++ b/monitoring/controllers/home/kustomization.yaml @@ -17,6 +17,9 @@ resources: - rosenpass.yaml # Nightly consistent sqlite snapshot of Grafana's dashboards/alerts/users. - grafana-backup.yaml + # Egress lockdown for that backup pod: DNS + the backup host only, so no + # run-time package fetch (card t_9d0428d8). + - grafana-backup-networkpolicy.yaml - dashboards # Secrets, SOPS/age-encrypted in git (decrypted by the `monitoring` # Kustomization; key = flux-system/sops-age). See docs/secrets-sops.md. @@ -24,6 +27,10 @@ resources: - secret-grafana-secret-key.sops.yaml - secret-alertmanager-telegram.sops.yaml - secret-cluster-backup-ssh.sops.yaml + # Registry pull credential for this namespace. Added because grafana-backup + # now runs an image from the in-cluster Forgejo registry instead of + # python:3.12-alpine from Docker Hub (card t_9d0428d8). + - secret-forgejo-pull.sops.yaml configMapGenerator: - name: kube-prometheus-stack-values diff --git a/monitoring/controllers/home/secret-forgejo-pull.sops.yaml b/monitoring/controllers/home/secret-forgejo-pull.sops.yaml new file mode 100644 index 0000000..f70f79e --- /dev/null +++ b/monitoring/controllers/home/secret-forgejo-pull.sops.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +data: + .dockerconfigjson: ENC[AES256_GCM,data:c7NwYAKS00RAzkEW3z1IA2XP24cdIJgQAaBjg7+WcsxLMEs2h42cg/fdtW6UYrrsQtq7X/T4wgfpzUjHq8aMI2lyiVhJa9vxHknpK32i2mP63YQ7o2axI2p5eGPQpB+uuLPr3e1A6I939co6LQCBrY1ueK9+9atCcSEflv/wJyXwrwvlV5EL20PTLTM/y8gGN9cXXfgk6aYV7F5mowQCcUIUDvCbj7cHIonumMfCANQgGjQHrACf0+2ko853nBwLQK1AtIP+U/NS1wDSbFmxqyO6OstF10Sq5t+8dY8baIt73RWN0BqB/7i08TsMpnNUXH4XJcP6WhP0FM+X3M5goJr80DNy2uG3fxTHwRSAeWGzIo2GuuK9qlMtIjjnU97K,iv:xPgSzx6+EEJRnTGYG+QZWJ7G3MUf6Ajd+CXpl8+XIxs=,tag:alsSmEFhXW46SeoVzdqyFA==,type:str] +kind: Secret +metadata: + name: forgejo-pull + namespace: monitoring +type: kubernetes.io/dockerconfigjson +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA1eU8ydkR5SmF2UG9ZQWNY + TWdKTFJkdjFlWWtBSW4wdmFDWXA0akNSSFI4CmVpL3dMKy91b1JTUTRyV1QyRXlI + YnlQZVJhL0hNRENNdlM1cDZKZmRUN0kKLS0tIEZOVHBLOUsvbFp6VjJXbW1tVmhK + Y1M4a2VyL0Z2MDhLeGJZUCtHRnQ2cmMKU9Q4m7ZuZDYbNQgsvOXEAKBE1hW1pa7m + 7/pmRAP43OjXfsjWUbnPmORcHSrVDtRrBxQZ2d1svVdwd6vMUPPjqw== + -----END AGE ENCRYPTED FILE----- + recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp + encrypted_regex: ^(data|stringData)$ + lastmodified: "2026-12-04T05:16:30Z" + mac: ENC[AES256_GCM,data:yYt1AWNi+Ts4c/p3OwrknVVPMPf9PEeYvgz/LckFqsJweSq36b6gzinMcLxJGnenmCokftUA4RvMMF2f0Lcpo3+RqmpPGnCzpAVQ0ypuS2+n+bET7tF/tu9icuwZaTu0sNW+/j8VK5T5nlrrw+aLf3O9yIuP7XVLXyjodJqbH7c=,iv:jSMmP96DHN6qLmpHoisVQu1DYlMVehxdXNWkzh5GZwk=,tag:b98z963bBjpM5gGZnKHqBg==,type:str] + version: 3.13.3 From 9248f34bd0bbd107975cae0f76685ac1299c3c8c Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 4 Dec 2026 00:30:16 -0500 Subject: [PATCH 04/10] fix(backup): add the registry pull secret that forgejo/cluster-backup now needs The namespace never pulled from the in-cluster registry before (its job used alpine/k8s from Docker Hub), so the new image reference had no credential and the pod sat in ErrImagePull. Same SOPS-encrypted dockerconfigjson as the other namespaces; deviating only in metadata.namespace. --- apps/base/forgejo/kustomization.yaml | 4 ++++ .../forgejo/secret-forgejo-pull.sops.yaml | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 apps/base/forgejo/secret-forgejo-pull.sops.yaml diff --git a/apps/base/forgejo/kustomization.yaml b/apps/base/forgejo/kustomization.yaml index d992e95..8a4ccd0 100644 --- a/apps/base/forgejo/kustomization.yaml +++ b/apps/base/forgejo/kustomization.yaml @@ -48,3 +48,7 @@ resources: - secret-forgejo-runner-amd64-token.sops.yaml - secret-forgejo-runner-deploy-arm64-token.sops.yaml - secret-cluster-backup-ssh.sops.yaml + # Registry pull credential: cluster-backup now runs an image from the + # in-cluster Forgejo registry instead of alpine/k8s from Docker Hub + # (card t_9d0428d8). + - secret-forgejo-pull.sops.yaml diff --git a/apps/base/forgejo/secret-forgejo-pull.sops.yaml b/apps/base/forgejo/secret-forgejo-pull.sops.yaml new file mode 100644 index 0000000..84ba7a2 --- /dev/null +++ b/apps/base/forgejo/secret-forgejo-pull.sops.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +data: + .dockerconfigjson: ENC[AES256_GCM,data:QS5gZUJ0zi3YYSaCpJWSCA/JakeknWmlQ8WVKlyxh2k4zo/Ul33lhH5iQP27Z3ec6FyEtV8TUSdhkq1wGSCF7cRu00ze4qljMuviU35x2Dl5aMc7JEWvRPnypoBYNmTRulPZh5E3GdiR9VUzok643P0igJyHlQBjO8HkLiuZ41Zd7JYordQRPTH4tXlDbiJPEPfkMEyFHY/6XdEEUNv5eIUyb004d1xZccnGaMwliVNBL5xIbJpb4Bza9/Z8NYsq70cmjHH/hFq7uotnSt3B53vPnwf6Rsq9j44i3M0xQjHQf+QYa34mFncHznwxPczLo8wcmKFmZYkNZNXxzc/NryeC4w950GUZ+cSO1UKLhS8IGIal8S05IWmeIuda1k9V,iv:AN7Fn/JmSYqiERsqneSOMeV3kMRGcawgV4Y9iJrjF7E=,tag:XwEZy+ULOGiFTW1diodMgg==,type:str] +kind: Secret +metadata: + name: forgejo-pull + namespace: forgejo +type: kubernetes.io/dockerconfigjson +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBjTmlMUDZOdnc1U3RGM1Jh + TTNmU3pRV3M1Y2lkNitqMkE0WHRZdXNOSlRJCnZ2eDB3ZXpvWDR6dHJBeWJpdElI + a24xelp4dGluNXNGUzJYOWlPNzdwM0EKLS0tIGJuUk1CUEEvZlVWYlFKTnVwWVRS + M2o5LzBJSEpXaklKc0ZMZ0FDa3NlV0UKmNVnlKd/Xqbisox3hrAeK45sbLJW5yS3 + Y6KfweCLwk6edQ9YflAvmk2FWVi0PIMdmloObXVSvB/ZY+jeLlK4lA== + -----END AGE ENCRYPTED FILE----- + recipient: age12zdn7x72zrgu9cdv8wdj7xfx42nz09nrwpc2g09cwx5fwdm0ry6qp5h4jp + encrypted_regex: ^(data|stringData)$ + lastmodified: "2026-12-04T05:28:22Z" + mac: ENC[AES256_GCM,data:goW5PeSFtc0ga5gTDAZpYFQ8xBTXA2dgOomUK9t9GX3T7nswhu6fmfXJ2zjqyYLKJ5wnVEY4pvwx9RThEpU0khcP8iBqyrzUvIEXUsoQ5lTegRxgyuowPKWBkQcrJPx5GEgHSJr5J6XlDKbbCeOW0SxnerPhpJ03ueh3yULPgKw=,iv:Z/hm3jpUXzWeabPXuecuAIm+bemjluy/xjas8dg7bUY=,tag:3coZnG6p2v6ZT0raG7b1IQ==,type:str] + version: 3.13.3 From 668011809f5537d39fcda31d709ff64314ab7015 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 4 Dec 2026 14:25:37 -0500 Subject: [PATCH 05/10] fix(netpol): allow cnpg-system operator to read instance status on :8000 The CNPG operator dials each instance's HTTPS status endpoint (https://:8000/pg/status) to derive the system ID and drive switchover. The tenant isolation added in t_fed52919 opened only gateway/node/health entities, same-namespace pods and monitoring:9187, so cnpg-system was denied: forgejo/pg and sirius-growth/portal sat at Ready=False / ConsistentSystemID=False ('Instance Status Extraction Error: HTTP communication issue') while their pods served traffic and automated failover was effectively disabled. Add one ingress rule to each CNP, scoped to the operator pod label (app.kubernetes.io/name=cloudnative-pg in cnpg-system) and to TCP 8000 only. Not world, not the whole cluster, not 5432. --- apps/base/forgejo/networkpolicy.yaml | 18 +++++++++++++++++- apps/base/sirius-growth/networkpolicy.yaml | 20 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/apps/base/forgejo/networkpolicy.yaml b/apps/base/forgejo/networkpolicy.yaml index 1984aa5..5600b1b 100644 --- a/apps/base/forgejo/networkpolicy.yaml +++ b/apps/base/forgejo/networkpolicy.yaml @@ -9,7 +9,10 @@ # so they arrive through the Gateway as `reserved:ingress` too and no # cross-namespace rule is needed. Node/health entities cover kubelet # probes; Prometheus in `monitoring` is allowed on 9187 only (the -# `cnpg-pg` PodMonitor scrapes the CNPG instance manager). +# `cnpg-pg` PodMonitor scrapes the CNPG instance manager), and the +# CNPG operator in `cnpg-system` on 8000 only — the instance +# manager's HTTPS status endpoint the operator reads to derive the +# system ID and drive failover (card t_4210edec). # egress: cluster DNS; its own pods (forgejo -> pg-rw:5432); `world` for # outbound HTTPS (Forgejo webhooks, avatar/mirror fetches, the # public-URL callbacks the runner flow needs); node IPs on 22, which @@ -54,6 +57,19 @@ spec: - fromEndpoints: - matchLabels: io.kubernetes.pod.namespace: forgejo + # The CNPG operator (`cnpg-system`) reads the instance manager's HTTPS + # status endpoint to derive the system ID and drive switchover/promotion. + # Without it the Cluster reports `Instance Status Extraction Error` and + # Ready=False while the pods serve traffic, and automated failover is dead + # (card t_4210edec). Scoped to 8000: not 5432, not the whole namespace. + - fromEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: cnpg-system + app.kubernetes.io/name: cloudnative-pg + toPorts: + - ports: + - port: "8000" + protocol: TCP # Prometheus scrapes the CNPG `pg` instance manager on 9187. - fromEndpoints: - matchLabels: diff --git a/apps/base/sirius-growth/networkpolicy.yaml b/apps/base/sirius-growth/networkpolicy.yaml index 4f989c6..8a7ddb5 100644 --- a/apps/base/sirius-growth/networkpolicy.yaml +++ b/apps/base/sirius-growth/networkpolicy.yaml @@ -6,8 +6,11 @@ # ingress: Cilium Gateway proxy (`reserved:ingress`) for # siriusgrowthsolutions.com -> site:80 / contact:8090 / # portal-gate:8080 / portal:8091 / blog:8092, node entities for -# kubelet probes, and Prometheus in `monitoring` on 9187 only (the -# `cnpg-portal` PodMonitor scrapes the CNPG instance manager). +# kubelet probes, Prometheus in `monitoring` on 9187 only (the +# `cnpg-portal` PodMonitor scrapes the CNPG instance manager), and +# the CNPG operator in `cnpg-system` on 8000 only — the instance +# manager's HTTPS status endpoint the operator reads to derive the +# system ID and drive failover (card t_4210edec). # egress: cluster DNS; its own pods (blog/portal -> portal-1:5432, # portal-gate -> portal:8091); `world` for the Telegram Bot API # (contact + portal) and the leadgen crawlers; the node IPs on 3900 @@ -53,6 +56,19 @@ spec: - fromEndpoints: - matchLabels: io.kubernetes.pod.namespace: sirius-growth + # The CNPG operator (`cnpg-system`) reads the instance manager's HTTPS + # status endpoint to derive the system ID and drive switchover/promotion. + # Without it the Cluster reports `Instance Status Extraction Error` and + # Ready=False while the pods serve traffic, and automated failover is dead + # (card t_4210edec). Scoped to 8000: not 5432, not the whole namespace. + - fromEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: cnpg-system + app.kubernetes.io/name: cloudnative-pg + toPorts: + - ports: + - port: "8000" + protocol: TCP # Prometheus scrapes the CNPG `portal` instance manager on 9187. - fromEndpoints: - matchLabels: From 398f9e0ae3dc5b999d5a9eecd855cb7458ba61c9 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 4 Dec 2026 14:36:34 -0500 Subject: [PATCH 06/10] site(lab): pin siriusdevops-site to the /lab rewrite image The lab.html rewrite merged as 3ac9870aa7637cffb789edcc16b9512d7567886d (sirius/siriusdevops PR #29); deploy-site run 68 built siriusdevops-site:3ac9870aa7637cffb789edcc16b9512d7567886d green on that sha. CI has no cluster credentials, so this pin is what rolls the site Deployment. deployment-api.yaml is untouched: the API code did not change. --- apps/base/siriusdevops/deployment-site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/base/siriusdevops/deployment-site.yaml b/apps/base/siriusdevops/deployment-site.yaml index a6d11de..30ff7b1 100644 --- a/apps/base/siriusdevops/deployment-site.yaml +++ b/apps/base/siriusdevops/deployment-site.yaml @@ -77,7 +77,7 @@ spec: memory: 128Mi containers: - name: nginx - image: forgejo.siriusdevops.com/sirius/siriusdevops-site:399c421f51a2fd74a87e810641226d58e4e22690 + image: forgejo.siriusdevops.com/sirius/siriusdevops-site:3ac9870aa7637cffb789edcc16b9512d7567886d imagePullPolicy: IfNotPresent ports: - containerPort: 80 From b355e8c16cba4a37429c5ef1d650e307e6443dd0 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Fri, 4 Dec 2026 23:04:26 -0500 Subject: [PATCH 07/10] fix(osint): pin summarizer to a model that still exists meituan/longcat-2.5:free was retired from the Nous Portal; every map/reduce call returned 404, chat() swallowed it, and the analyst produced no briefs after 2025-11-25 (last daily_recap 11-23). The :free ids now demand a user tag and answer 503 anyway, so pin deepseek/deepseek-v4.1-flash-1017 ($0.03/ $0.12 per Mtok, json_object verified) instead. --- apps/base/osint/README.md | 7 +++++-- apps/base/osint/configmap.yaml | 14 +++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index a3f838d..f9676ee 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -133,8 +133,11 @@ it can actually parse. ## Analyst model -`SUMMARY_MODEL=meituan/longcat-2.5:free` (free tier on the Nous Portal, -1M context, verified to honour `response_format: json_object`). It is set in +`SUMMARY_MODEL=deepseek/deepseek-v4.1-flash-1017` (Nous Portal, 1M context, +verified to honour `response_format: json_object`; the previous free +`meituan/longcat-2.5:free` id was retired and 404'd every call). When picking a +replacement, confirm it is in `GET /v1/models` — a stale id fails silently +because `chat()` swallows non-200s and returns an empty string. It is set in `configmap.yaml`; changing it in the UI (`PUT /api/settings`) only takes effect when the env var is empty, because `resolve_model()` prefers the env. diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index fa58991..1ef4fab 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -66,13 +66,17 @@ data: # never see https here: this flag is what puts `Secure` on the session cookie. ADMIN_COOKIE_SECURE: "1" - # ── news summarizer (analyst) — Nous Portal, free tier model ──────────── + # ── news summarizer (analyst) — Nous Portal ───────────────────────────── NOUS_BASE_URL: https://inference-api.nousresearch.com/v1 - SUMMARY_MODEL: meituan/longcat-2.5:free + # Meituan LongCat was retired from the portal (every call 404'd from 11/25 + # onward, silently producing no briefs). The :free ids now require a user + # tag and 503 anyway; pin the cheapest model that answers normally and + # honours response_format: json_object (~$0.03/$0.12 per Mtok). + SUMMARY_MODEL: deepseek/deepseek-v4.1-flash-1017 # 4, not the upstream default 50: the map phase runs with a hard 60 s httpx - # timeout (news/summerizer/nous_client.py, json_mode=False), and this free - # model needs ~30 s for 8 articles, so bigger batches time out and silently - # contribute nothing to the reduce phase. + # timeout (news/summerizer/nous_client.py, json_mode=False), so bigger + # batches risk timing out and silently contributing nothing to the reduce + # phase. BATCH_SIZE: "4" # Map-phase grading (PR #53): the map call scores every article 0-100 against # a rubric and only blocks >= SUMMARY_MIN_SCORE reach the brief. When nothing From e4b1ac59a95d78f13a4120ed684860147b362ad4 Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Fri, 4 Dec 2026 23:18:20 -0500 Subject: [PATCH 08/10] feat(osint): alert when the analyst stops writing briefs The 2026-11-25..12-04 outage was invisible: deploy/osint-news-summarizer stayed Running with restarts 0 and INFO batch lines while article_summaries froze for nine days, and the scraper kept articles fresh (61.5k rows, newest within minutes). The app has no /metrics endpoint, so add a small read-only Postgres exporter and two Prometheus rules. - osint-analyst-exporter (ns osint): stdlib HTTP server on :9187 serving osint_analyst_last_success_timestamp_seconds (max article_summaries. batch_timestamp), osint_ingest_last_article_timestamp_seconds (max articles.timestamp) and osint_analyst_exporter_up. Runs the pinned summarizer image (python3 + psycopg2), non-root, read-only rootfs, clusterIP Service + ServiceMonitor (release=kube-prometheus-stack). - NetworkPolicy: one port-scoped ingress rule, monitoring -> :9187. Nothing else in monitoring can reach osint. - monitoring/controllers/home/osint-analyst.yaml: OsintAnalystStale (>1h, 30m, warning, with an absent() arm so a dead exporter cannot read as healthy) and OsintIngestAliveButNoBrief (articles <2h old while summaries >2h old, 10m, warning). Both route through the default Telegram receiver. --- apps/base/osint/analyst-exporter.yaml | 328 ++++++++++++++++++ apps/base/osint/kustomization.yaml | 5 + apps/base/osint/networkpolicy.yaml | 14 +- .../controllers/home/kustomization.yaml | 3 + .../controllers/home/osint-analyst.yaml | 87 +++++ 5 files changed, 436 insertions(+), 1 deletion(-) create mode 100644 apps/base/osint/analyst-exporter.yaml create mode 100644 monitoring/controllers/home/osint-analyst.yaml diff --git a/apps/base/osint/analyst-exporter.yaml b/apps/base/osint/analyst-exporter.yaml new file mode 100644 index 0000000..0c975e1 --- /dev/null +++ b/apps/base/osint/analyst-exporter.yaml @@ -0,0 +1,328 @@ +# Freshness exporter for the osint analyst (card t_22334588). +# +# The summarizer (deploy/osint-news-summarizer) wrote no article_summaries rows +# from 2026-11-25 to 2026-12-04 while the scraper kept the articles table fresh +# (61.5k rows, newest within minutes). Nothing paged: the container was Running +# with restarts 0 and only INFO batch lines in the log, so "analyst wedged" and +# "analyst idle" looked identical from every signal the cluster had. +# +# The app has no /metrics endpoint (POST /metrics -> 404 on osint-app), so this +# is a tiny read-only exporter that answers the only question that matters: +# *when* did each side last write a row? It reads two timestamps from +# osint_data and serves them on :9187/metrics: +# +# osint_analyst_last_success_timestamp_seconds max(article_summaries.batch_timestamp) +# osint_ingest_last_article_timestamp_seconds max(articles.timestamp) +# osint_analyst_exporter_up 1 when the last DB read succeeded +# +# PromQL rules live in monitoring/controllers/home/osint-analyst.yaml +# (OsintAnalystStale, OsintIngestAliveButNoBrief). +# +# Why the summarizer image: it is the only image in this namespace that already +# ships psycopg2 and a python3, and it is pinned by tag (no floating base). The +# script uses the stdlib HTTP server, so nothing is installed at runtime and no +# new image build is needed. Revisit if that image is ever replaced. +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: osint-analyst-exporter + namespace: osint +data: + exporter.py: | + #!/usr/bin/env python3 + """Read-only freshness exporter for the osint analyst. + + Serves /metrics on :9187. Two timestamps, nothing else: + + osint_analyst_last_success_timestamp_seconds + epoch of max(article_summaries.batch_timestamp) -- when the analyst + last wrote a brief. 0 means the table is empty (stale by definition). + osint_ingest_last_article_timestamp_seconds + epoch of max(articles.timestamp) -- when the scraper last ingested. + osint_analyst_exporter_up + 1 when the last database read succeeded, 0 otherwise. + + On a database error the last good values are kept and `up` drops to 0, so + the timestamps keep ageing and a broken exporter escalates through the same + OsintAnalystStale alert instead of hiding behind missing series. + """ + import logging + import os + import threading + import time + from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer + + import psycopg2 + + LOG = logging.getLogger("osint-analyst-exporter") + logging.basicConfig( + level=os.getenv("LOG_LEVEL", "INFO"), + format="%(asctime)s %(levelname)s %(name)s: %(message)s", + ) + + PORT = int(os.getenv("EXPORTER_PORT", "9187")) + # One scrape interval (30 s) of cache: Prometheus + probes hitting the + # endpoint together must not each open a database connection. + CACHE_TTL = float(os.getenv("CACHE_TTL_SECONDS", "10")) + + DB_CONFIG = { + "host": os.getenv("DB_HOST", "osint-db"), + "port": int(os.getenv("DB_PORT", "5432")), + "dbname": os.getenv("DB_NAME", "osint_data"), + "user": os.getenv("DB_USER", "osint"), + "password": os.getenv("DB_PASSWORD", ""), + "connect_timeout": 5, + } + + ANALYST_SQL = ( + "SELECT COALESCE(EXTRACT(EPOCH FROM max(batch_timestamp))::bigint, 0) " + "FROM article_summaries" + ) + INGEST_SQL = ( + "SELECT COALESCE(EXTRACT(EPOCH FROM max(timestamp))::bigint, 0) " + "FROM articles" + ) + + _lock = threading.Lock() + _state = {"analyst": 0, "ingest": 0, "up": 0, "last_attempt": 0.0} + + + def collect() -> tuple[int, int]: + conn = psycopg2.connect(**DB_CONFIG) + try: + conn.autocommit = True + with conn.cursor() as cur: + cur.execute("SET statement_timeout = 5000") + cur.execute(ANALYST_SQL) + analyst = int(cur.fetchone()[0] or 0) + cur.execute(INGEST_SQL) + ingest = int(cur.fetchone()[0] or 0) + finally: + conn.close() + return analyst, ingest + + + def ensure_fresh() -> None: + now = time.time() + with _lock: + if now - _state["last_attempt"] < CACHE_TTL: + return + _state["last_attempt"] = now + try: + analyst, ingest = collect() + except Exception as exc: # noqa: BLE001 - never kill the endpoint + with _lock: + _state["up"] = 0 + LOG.warning("collect failed: %s", exc) + return + with _lock: + _state.update(analyst=analyst, ingest=ingest, up=1) + + + def render() -> str: + with _lock: + analyst = _state["analyst"] + ingest = _state["ingest"] + up = _state["up"] + return ( + "# HELP osint_analyst_last_success_timestamp_seconds " + "Epoch of the newest article_summaries.batch_timestamp (last brief " + "written by the analyst); 0 = no row.\n" + "# TYPE osint_analyst_last_success_timestamp_seconds gauge\n" + f"osint_analyst_last_success_timestamp_seconds {analyst}\n" + "# HELP osint_ingest_last_article_timestamp_seconds " + "Epoch of the newest articles.timestamp (last row ingested by the " + "scraper); 0 = no row.\n" + "# TYPE osint_ingest_last_article_timestamp_seconds gauge\n" + f"osint_ingest_last_article_timestamp_seconds {ingest}\n" + "# HELP osint_analyst_exporter_up 1 when the last database read " + "succeeded.\n" + "# TYPE osint_analyst_exporter_up gauge\n" + f"osint_analyst_exporter_up {up}\n" + ) + + + class Handler(BaseHTTPRequestHandler): + server_version = "osint-analyst-exporter/1.0" + + def do_GET(self): # noqa: N802 - BaseHTTPRequestHandler API + path = self.path.split("?", 1)[0] + if path not in ("/metrics", "/healthz"): + self.send_error(404) + return + ensure_fresh() + body = render().encode() + self.send_response(200) + self.send_header("Content-Type", "text/plain; version=0.0.4; charset=utf-8") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def log_message(self, fmt, *args): # noqa: A003 - stdlib hook + LOG.debug("%s - %s", self.address_string(), fmt % args) + + + def main() -> None: + # Prime the cache so the first scrape has data, but never refuse to + # start on a database blip. + ensure_fresh() + server = ThreadingHTTPServer(("0.0.0.0", PORT), Handler) + LOG.info("listening on 0.0.0.0:%s (db=%s/%s)", PORT, DB_CONFIG["host"], DB_CONFIG["dbname"]) + server.serve_forever() + + + if __name__ == "__main__": + main() +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: osint-analyst-exporter + namespace: osint + labels: + app: osint-analyst-exporter +spec: + replicas: 1 + selector: + matchLabels: + app: osint-analyst-exporter + template: + metadata: + labels: + app: osint-analyst-exporter + spec: + imagePullSecrets: + - name: forgejo-pull + # Same placement policy as the other stateless amd64 loops here: prefer + # linode (where osint-db runs) but do not strand if it is absent. + nodeSelector: + kubernetes.io/arch: amd64 + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - linode + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + seccompProfile: + type: RuntimeDefault + containers: + - name: exporter + # Pinned summarizer image: python3 + psycopg2, see header comment. + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0 + imagePullPolicy: IfNotPresent + command: ["python", "/opt/exporter/exporter.py"] + env: + - name: PYTHONDONTWRITEBYTECODE + value: "1" + - name: EXPORTER_PORT + value: "9187" + - name: DB_HOST + valueFrom: + configMapKeyRef: + name: osint-env + key: DB_HOST + - name: DB_PORT + valueFrom: + configMapKeyRef: + name: osint-env + key: DB_PORT + - name: DB_NAME + valueFrom: + configMapKeyRef: + name: osint-env + key: DB_NAME + - name: DB_USER + valueFrom: + configMapKeyRef: + name: osint-env + key: DB_USER + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: osint-db + key: password + ports: + - name: metrics + containerPort: 9187 + protocol: TCP + readinessProbe: + httpGet: + path: /healthz + port: metrics + periodSeconds: 10 + livenessProbe: + httpGet: + path: /healthz + port: metrics + initialDelaySeconds: 10 + periodSeconds: 30 + resources: + requests: + cpu: 10m + memory: 64Mi + limits: + cpu: 100m + memory: 128Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL + volumeMounts: + - name: script + mountPath: /opt/exporter + readOnly: true + volumes: + - name: script + configMap: + name: osint-analyst-exporter +--- +apiVersion: v1 +kind: Service +metadata: + name: osint-analyst-exporter + namespace: osint + labels: + app: osint-analyst-exporter +spec: + type: ClusterIP + selector: + app: osint-analyst-exporter + ports: + - name: metrics + port: 9187 + targetPort: metrics + protocol: TCP +--- +# Prometheus (monitoring ns) scrapes this; the ServiceMonitor selector is +# namespace-wide (spec.serviceMonitorNamespaceSelector = {}), so the label is +# what matters. Ingress from monitoring to :9187 is opened in networkpolicy.yaml. +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: osint-analyst-exporter + namespace: osint + labels: + release: kube-prometheus-stack +spec: + namespaceSelector: + matchNames: + - osint + selector: + matchLabels: + app: osint-analyst-exporter + endpoints: + - port: metrics + path: /metrics + interval: 30s + scrapeTimeout: 10s diff --git a/apps/base/osint/kustomization.yaml b/apps/base/osint/kustomization.yaml index 0c6b75e..7d66655 100644 --- a/apps/base/osint/kustomization.yaml +++ b/apps/base/osint/kustomization.yaml @@ -18,6 +18,11 @@ resources: - titiler-service.yaml - news-scraper-deployment.yaml - news-summarizer-deployment.yaml + # Freshness exporter for the analyst (max(article_summaries.batch_timestamp) + # and max(articles.timestamp) -> :9187/metrics) + its ServiceMonitor. The + # summarizer has no /metrics and a wedged analyst is invisible otherwise + # (card t_22334588). + - analyst-exporter.yaml - httproute.yaml # Default-deny ingress+egress + the namespace allow list (audit F3 / t_fed52919). - networkpolicy.yaml diff --git a/apps/base/osint/networkpolicy.yaml b/apps/base/osint/networkpolicy.yaml index f617fff..7379108 100644 --- a/apps/base/osint/networkpolicy.yaml +++ b/apps/base/osint/networkpolicy.yaml @@ -21,7 +21,9 @@ # * kube-apiserver egress — no workload here calls the API; the audit's # `SA token mounted` observation is a separate finding and denying the path # does not depend on removing the token. -# * monitoring ingress — no PodMonitor/ServiceMonitor selects osint pods. +# * monitoring ingress — apart from the one port-scoped rule for the analyst +# freshness exporter below (Prometheus -> osint-analyst-exporter:9187), +# nothing in `monitoring` reaches this namespace. apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: @@ -56,6 +58,16 @@ spec: - fromEndpoints: - matchLabels: io.kubernetes.pod.namespace: osint + # Prometheus (namespace `monitoring`) scrapes the analyst freshness exporter + # on 9187 (apps/base/osint/analyst-exporter.yaml). Port-scoped: no other + # monitoring -> osint traffic is opened. + - fromEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: monitoring + toPorts: + - ports: + - port: "9187" + protocol: TCP egress: - toEndpoints: - matchLabels: diff --git a/monitoring/controllers/home/kustomization.yaml b/monitoring/controllers/home/kustomization.yaml index 265058f..b994dba 100644 --- a/monitoring/controllers/home/kustomization.yaml +++ b/monitoring/controllers/home/kustomization.yaml @@ -15,6 +15,9 @@ resources: # Series come from a host textfile exporter (infrastructure/networking/rosenpass/), # so silently missing data is itself an alert. - rosenpass.yaml + # Analyst freshness: OsintAnalystStale + OsintIngestAliveButNoBrief, built on + # the osint-analyst-exporter timestamps (card t_22334588). + - osint-analyst.yaml # Nightly consistent sqlite snapshot of Grafana's dashboards/alerts/users. - grafana-backup.yaml # Egress lockdown for that backup pod: DNS + the backup host only, so no diff --git a/monitoring/controllers/home/osint-analyst.yaml b/monitoring/controllers/home/osint-analyst.yaml new file mode 100644 index 0000000..6c144d3 --- /dev/null +++ b/monitoring/controllers/home/osint-analyst.yaml @@ -0,0 +1,87 @@ +# osint analyst freshness -> Prometheus (card t_22334588) +# +# On 2026-11-25 the analyst (deploy/osint-news-summarizer) silently stopped +# writing article_summaries and stayed dead for nine days. The scraper kept +# ingesting normally (61.5k rows in articles, newest within minutes), the pod +# stayed Running with restarts 0, and the log carried nothing but INFO batch +# lines and 404s at INFO level -- so every signal the cluster already had said +# "healthy". These two rules are built on the timestamps the exporter in +# apps/base/osint/analyst-exporter.yaml reads straight out of Postgres +# (SeriesMonitor osint-analyst-exporter, ns osint, :9187/metrics): +# +# osint_analyst_last_success_timestamp_seconds max(article_summaries.batch_timestamp) +# osint_ingest_last_article_timestamp_seconds max(articles.timestamp) +# osint_analyst_exporter_up 1 when the last DB read worked +# +# OsintAnalystStale is the general "no brief in over an hour" gate; the +# summarizer loops every 15 min, so an hour of silence cannot be a slow batch. +# OsintIngestAliveButNoBrief is the sharper one: a fresh article row plus a +# summary table frozen for two hours names the exact failure -- ingest fine, +# analyst dark -- without waiting for the read path or the API to be down. +# +# The absent() arm on OsintAnalystStale is deliberate: if the exporter, its +# ServiceMonitor or its scrape disappears, the series vanishes and "no data" +# would otherwise read as "no problem", which is the same invisible-failure +# shape this card exists to kill. Routes through the default Alertmanager +# receiver (Telegram @Siriusdevops_alert_bot). +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: osint-analyst + namespace: monitoring + labels: + release: kube-prometheus-stack +spec: + groups: + - name: osint-analyst + rules: + - alert: OsintAnalystStale + expr: | + ( + time() - osint_analyst_last_success_timestamp_seconds > 3600 + ) + or + absent(osint_analyst_last_success_timestamp_seconds) + for: 30m + labels: + severity: warning + annotations: + summary: >- + osint analyst has written no brief for over an hour + description: >- + The newest article_summaries.batch_timestamp is more than an hour + old (the summarizer loops every 15 minutes), or the freshness + series is missing entirely. The container can still be Running + with restarts 0: a wedged analyst looks exactly like an idle one. + Check `kubectl -n osint logs deploy/osint-news-summarizer --tail=50` + for the interval rc, confirm the exporter target is UP in + Prometheus (job osint-analyst-exporter), and test the analyst + query directly: + `kubectl -n osint exec deploy/osint-db -- psql -U osint -d osint_data -c "select max(batch_timestamp), count(*) from article_summaries"`. + A silently dead model/API key is the usual cause. + - alert: OsintIngestAliveButNoBrief + expr: | + ( + time() - osint_analyst_last_success_timestamp_seconds > 7200 + ) + and + ( + time() - osint_ingest_last_article_timestamp_seconds < 7200 + ) + for: 10m + labels: + severity: warning + annotations: + summary: >- + osint scraper is ingesting but the analyst has written no brief for 2h + description: >- + `articles` has a row younger than two hours while + `article_summaries` has nothing newer than two hours. Ingest fine + + analyst dark is the shape of the 2026-11-25..12-04 outage, where + the pipeline looked healthy for nine days because only the ingest + side was moving. Confirm the scraper is genuinely alive + (`kubectl -n osint logs deploy/osint-news-scraper --tail=20`) and + then debug the analyst side: summarizer logs, NEWS_SUMMARIZE_* + env, the resolved SUMMARY_MODEL and the Nous API key/inference + endpoint (a dead model or a 404 on every map call writes zero + rows while the loop keeps logging rc=0). From 81fe55b0fd4c0ce9ad1cdb12824d7cb3a72141ab Mon Sep 17 00:00:00 2001 From: sirius Date: Sat, 5 Dec 2026 00:18:13 -0500 Subject: [PATCH 09/10] fix(forgejo): allow ci-runners -> forgejo:3000 so CI image pushes work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `forgejo-allow` claimed no cross-namespace rule was needed because the CI runners in `ci-runners` "register/poll over the public URL and therefore arrive as reserved:ingress". That holds for registration only. Every image-building workflow pushes to the in-cluster ClusterIP (`PUSH_REGISTRY: forgejo.forgejo.svc.cluster.local:3000`) from the dind sidecar of the runner pod — pod->pod, which `default-deny` dropped, so every build since the policy landed (2026-11-27 07:13Z) died at `Get "http://forgejo.forgejo.svc.cluster.local:3000/v2/": request canceled ... Client.Timeout exceeded`. Add one port-scoped ingress rule: fromEndpoints `io.kubernetes.pod.namespace: ci-runners` -> 3000/TCP (runner container and its dind sidecar share the pod identity, so a single namespace selector covers both). Nothing else in `forgejo` is widened. Rewrite the stale comment paragraph so the next isolation audit does not re-remove it. --- apps/base/forgejo/networkpolicy.yaml | 42 ++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/apps/base/forgejo/networkpolicy.yaml b/apps/base/forgejo/networkpolicy.yaml index 5600b1b..e0a6826 100644 --- a/apps/base/forgejo/networkpolicy.yaml +++ b/apps/base/forgejo/networkpolicy.yaml @@ -3,12 +3,20 @@ # `default-deny` (stock NetworkPolicy, podSelector {}, both directions) is the # deny. `forgejo-allow` (CiliumNetworkPolicy) re-adds what this namespace uses: # ingress: the Cilium Gateway proxy (`reserved:ingress`) for -# forgejo.siriusdevops.com -> forgejo:3000. The CI runners live in -# `ci-runners` and register/poll over the PUBLIC URL -# (runner-amd64.yaml: `--instance https://forgejo.siriusdevops.com`), -# so they arrive through the Gateway as `reserved:ingress` too and no -# cross-namespace rule is needed. Node/health entities cover kubelet -# probes; Prometheus in `monitoring` is allowed on 9187 only (the +# forgejo.siriusdevops.com -> forgejo:3000; the CI runners in +# `ci-runners` on 3000 only (they register/poll over the PUBLIC URL, +# so THAT traffic arrives as `reserved:ingress` — but their image +# pushes go pod->pod to the internal ClusterIP +# `forgejo.forgejo.svc.cluster.local:3000` +# (`PUSH_REGISTRY` in each repo's `.forgejo/workflows/build.yml`, +# docker daemon in the dind sidecar of the runner pod). Pod->pod is +# not `reserved:ingress`, so `default-deny` dropped it and every +# image build failed 2026-11-27 .. 2026-12-05 with +# `Get "http://forgejo.forgejo.svc.cluster.local:3000/v2/": request +# canceled ... Client.Timeout exceeded` — the cross-namespace rule IS +# required; do not delete it as redundant. Node/health entities +# cover kubelet probes; Prometheus in `monitoring` is allowed on +# 9187 only (the # `cnpg-pg` PodMonitor scrapes the CNPG instance manager), and the # CNPG operator in `cnpg-system` on 8000 only — the instance # manager's HTTPS status endpoint the operator reads to derive the @@ -22,7 +30,8 @@ # `kubectl exec` DB dumps. # # The CI runner pods themselves are NOT in this namespace (they moved to -# `ci-runners` for `enforce: privileged`) and are out of scope for this card. +# `ci-runners` for `enforce: privileged`); `forgejo-allow` only grants them +# forgejo:3000, which is the registry push path the builds depend on. apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: @@ -41,8 +50,9 @@ metadata: namespace: forgejo spec: description: >- - forgejo: gateway + kubelet + Prometheus ingress; egress to own namespace, - cluster DNS, the internet, SSH on node IPs and the API. + forgejo: gateway + kubelet + Prometheus + ci-runners registry-push ingress; + egress to own namespace, cluster DNS, the internet, SSH on node IPs and the + API. endpointSelector: {} ingress: - fromEntities: @@ -57,6 +67,20 @@ spec: - fromEndpoints: - matchLabels: io.kubernetes.pod.namespace: forgejo + # CI runners (`ci-runners`) push images to the in-cluster registry at + # forgejo.forgejo.svc.cluster.local:3000 (PUSH_REGISTRY in each repo's + # build workflow; the docker daemon lives in the dind sidecar of the same + # pod, so one namespace selector covers runner + sidecar). Registration and + # polling use the public URL and arrive as `reserved:ingress`, but the push + # is pod -> pod and default-deny drops it without this rule. Port-scoped on + # purpose: the registry API only, nothing else in the namespace. + - fromEndpoints: + - matchLabels: + io.kubernetes.pod.namespace: ci-runners + toPorts: + - ports: + - port: "3000" + protocol: TCP # The CNPG operator (`cnpg-system`) reads the instance manager's HTTPS # status endpoint to derive the system ID and drive switchover/promotion. # Without it the Cluster reports `Instance Status Extraction Error` and From 2f613e4f11ff9ed5218f70dc68958aaa7b59167a Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Sat, 5 Dec 2026 00:29:11 -0500 Subject: [PATCH 10/10] fix(osint): run the PR #72 summarizer (fail-loudly + concurrent map phase) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The resilience fix sirius/osint-dashboard@fb5285d (PR #72) was merged but never deployed: ns osint still ran the 11/19 image amd64-fe2b5df369d0, which has neither the concurrent map phase nor NousAPIError, so a non-retryable Nous rejection was swallowed as an empty completion and the analyst idled for nine days without a single signal. * pin deploy/osint-news-summarizer to the CI-built amd64-fb5285df7f38 (build run 1497 / job 2165, manifest sha256:e2387f90...4de52) * pin osint-analyst-exporter to the same tag — it borrows the summarizer image for python3 + psycopg2, and two tags for one image read as drift * SUMMARY_MAP_CONCURRENCY=16 next to BATCH_SIZE: ~20 s per map call, the 746-batch recap measured 951 s at 16 (8 projects to ~98 min) * README: image inventory + a section on the new behaviour and log line --- apps/base/osint/README.md | 17 ++++++++++++++++- apps/base/osint/analyst-exporter.yaml | 8 ++++++-- apps/base/osint/configmap.yaml | 7 +++++++ apps/base/osint/news-summarizer-deployment.yaml | 7 ++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/apps/base/osint/README.md b/apps/base/osint/README.md index f9676ee..27845bf 100644 --- a/apps/base/osint/README.md +++ b/apps/base/osint/README.md @@ -15,7 +15,7 @@ instead of a host Docker container on the Pi. | `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) | | `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` | | `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop | -| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fe2b5df369d0` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | +| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fb5285df7f38` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap | Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy co-location + local-path PVs). @@ -141,6 +141,21 @@ because `chat()` swallows non-200s and returns an empty string. It is set in `configmap.yaml`; changing it in the UI (`PUT /api/settings`) only takes effect when the env var is empty, because `resolve_model()` prefers the env. +## Analyst resilience + map concurrency (PR #72) + +`SUMMARY_MAP_CONCURRENCY` (16, in `configmap.yaml`) sets how many map calls are +in flight. Each call is a ~20 s wall clock, so the phase is latency-bound: the +746-batch recap measured **951 s** end-to-end at 16, where 8 is projected at +~98 min. The code default is also 16; the env var is pinned so a default change +upstream cannot silently stretch the 15-min interval past its window. + +A non-retryable Nous rejection (400/404/422 — e.g. a retired model id) now +raises `NousAPIError` and aborts the run with `rc=1` instead of being swallowed +as an empty completion, so the failure shows up in the pod log on the *first* +tick rather than as nine days of "idle" ticks. The per-run summary line is +`summarize done kind= summary_id=… model=… batches=… articles=… +ticker=… map=… elapsed=…s`. + ## Analyst grading (PR #53 + #54) The map call scores every article **0-100** against a rubric in the same request diff --git a/apps/base/osint/analyst-exporter.yaml b/apps/base/osint/analyst-exporter.yaml index 0c975e1..a3c7dbf 100644 --- a/apps/base/osint/analyst-exporter.yaml +++ b/apps/base/osint/analyst-exporter.yaml @@ -21,7 +21,10 @@ # Why the summarizer image: it is the only image in this namespace that already # ships psycopg2 and a python3, and it is pinned by tag (no floating base). The # script uses the stdlib HTTP server, so nothing is installed at runtime and no -# new image build is needed. Revisit if that image is ever replaced. +# new image build is needed. It tracks the summarizer's own pin (currently +# amd64-fb5285df7f38) — bump BOTH together; two different tags for one image in +# one namespace reads as drift in an audit, and the exporter only needs the +# interpreter + psycopg2, which every summarizer build carries. --- apiVersion: v1 kind: ConfigMap @@ -217,7 +220,8 @@ spec: containers: - name: exporter # Pinned summarizer image: python3 + psycopg2, see header comment. - image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0 + # Kept equal to the summarizer pin in news-summarizer-deployment.yaml. + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fb5285df7f38 imagePullPolicy: IfNotPresent command: ["python", "/opt/exporter/exporter.py"] env: diff --git a/apps/base/osint/configmap.yaml b/apps/base/osint/configmap.yaml index 1ef4fab..1fb953d 100644 --- a/apps/base/osint/configmap.yaml +++ b/apps/base/osint/configmap.yaml @@ -78,6 +78,13 @@ data: # batches risk timing out and silently contributing nothing to the reduce # phase. BATCH_SIZE: "4" + # Map-phase fan-out (PR #72). Each map call is a ~20 s wall clock, so the + # phase is latency-bound, not CPU-bound: the 746-batch recap measured 951 s + # end-to-end at 16 in flight, where 8 is projected at ~98 min. 16 is also the + # summarizer's DEFAULT_SUMMARY_MAP_CONCURRENCY; it is pinned here so a future + # code default change cannot silently stretch the 15-min interval past its + # window. + SUMMARY_MAP_CONCURRENCY: "16" # Map-phase grading (PR #53): the map call scores every article 0-100 against # a rubric and only blocks >= SUMMARY_MIN_SCORE reach the brief. When nothing # clears the bar the top SUMMARY_FALLBACK_TOP are used so the HUD is not blank diff --git a/apps/base/osint/news-summarizer-deployment.yaml b/apps/base/osint/news-summarizer-deployment.yaml index 264da5b..931a029 100644 --- a/apps/base/osint/news-summarizer-deployment.yaml +++ b/apps/base/osint/news-summarizer-deployment.yaml @@ -39,7 +39,12 @@ spec: kubernetes.io/arch: amd64 containers: - name: news-summarizer - image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0 + # amd64-fb5285df7f38 = sirius/osint-dashboard@fb5285d (PR #72, merged): + # the map phase runs concurrently (SUMMARY_MAP_CONCURRENCY) and a + # non-retryable Nous rejection raises NousAPIError instead of being + # swallowed, so a wedged analyst fails loudly instead of idling for + # nine days on silent empty completions (card t_22334588 / t_2ae9f0c0). + image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fb5285df7f38 imagePullPolicy: IfNotPresent # Loop: batch the last window, call Nous Portal, write summaries. command: ["python", "run_news_summarizer.py"]