Compare commits

...

8 Commits

10 changed files with 374 additions and 12 deletions

View File

@ -251,6 +251,45 @@ source restrictions, TLS and service authentication. The communications pool
retains `.4` through `.6`; its Local-policy services need a speaker on their
actual endpoint node. Do not restrict all pools to ingress nodes indiscriminately.
The November 28 Jenkins incident was an ingress failure: Jenkins answered
`/login` locally, its PVC was only 13% full, and the controller had no restarts.
Both Traefik replicas had `OOMKilled` terminations at their former 512 MiB limit.
One stayed unready for roughly eleven hours without a liveness probe. The other
held over 6,000 HTTPS connections; all request-read and idle timeouts were disabled.
Metrics recorded periods with zero available ingress replicas.
Traefik now bounds request reads to 300 seconds and idle keep-alive connections
to 180 seconds. The read deadline includes the entire upload body: clients with
uploads longer than five minutes must use chunks or a separately configured
entrypoint. Keep response writes unlimited for streaming. Do not globally remove
read/idle deadlines to accommodate an individual application. See the
[Traefik timeout definitions](https://doc.traefik.io/traefik/v3.3/routing/entrypoints/#respondingtimeouts).
The 1 GiB container limit has a 768 MiB Go soft limit, leaving headroom for
non-runtime memory; the [Go memory limit](https://go.dev/doc/gc-guide#Memory_limit)
does not replace connection bounds or the container limit.
Startup and liveness probes use the same internal `/ping` endpoint as readiness.
Six failed ten-second liveness checks restart an unresponsive container with a
30-second termination grace, while normal rollouts retain the five-minute drain
window and keep at least one ready replica. The `atlas.ingress.health` rule group
evaluates every minute and detects total ingress loss, lost redundancy, recent
OOM restarts, sustained memory pressure and Jenkins controller unavailability.
These rules reach Alertmanager's existing silent default receiver; email routing
remains limited to the previously configured Hermes alerts.
Jenkins also has an HTTP-only ingress with `jenkins-https-redirect` middleware.
It redirects `http://ci.bstein.dev/` to HTTPS, preserving paths and query strings.
The HTTPS ingress alone does not match plain HTTP: without the separate route,
typing the hostname can return Traefik's plain-text 404 even while HTTPS is healthy.
For a repeat report, check both `http://ci.bstein.dev/` and
`https://ci.bstein.dev/login`, compare `/login` inside
the Jenkins container, then check the SSO redirect at
`https://ci.bstein.dev/securityRealm/commenceLogin`. Inspect Traefik pod termination
reasons, `/ping`, `traefik_open_connections` and memory before restarting Jenkins.
Apply recovery configuration through Git and reconcile `traefik`; verify two ready
replicas and a working public login before declaring recovery.
MetalLB uses native L2 mode, without unused FRR/BGP sidecars. There are no BGP
peers or advertisements. Titan-05/06 are excluded from the speaker DaemonSet
until their recovery checks pass. Remove that explicit exclusion in

View File

@ -40,12 +40,13 @@ items:
- --metrics.prometheus.addEntryPointsLabels=true
- --metrics.prometheus.addRoutersLabels=true
- --metrics.prometheus.addServicesLabels=true
- --entrypoints.web.transport.respondingTimeouts.readTimeout=0s
# Bound stalled reads and idle connections; allow five minutes for uploads.
- --entrypoints.web.transport.respondingTimeouts.readTimeout=300s
- --entrypoints.web.transport.respondingTimeouts.writeTimeout=0s
- --entrypoints.web.transport.respondingTimeouts.idleTimeout=0s
- --entrypoints.websecure.transport.respondingTimeouts.readTimeout=0s
- --entrypoints.web.transport.respondingTimeouts.idleTimeout=180s
- --entrypoints.websecure.transport.respondingTimeouts.readTimeout=300s
- --entrypoints.websecure.transport.respondingTimeouts.writeTimeout=0s
- --entrypoints.websecure.transport.respondingTimeouts.idleTimeout=0s
- --entrypoints.websecure.transport.respondingTimeouts.idleTimeout=180s
- --ping=true
- --ping.entrypoint=health
- --entrypoints.health.address=:8082
@ -58,13 +59,33 @@ items:
image: traefik:v3.3.3@sha256:19884a9d0b922b321c9cff54cbfe43f3169893041b8dd4ea6100677afaddce46
imagePullPolicy: IfNotPresent
name: traefik
env:
# Leave room for socket buffers and memory outside the Go heap.
- name: GOMEMLIMIT
value: 768MiB
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
cpu: 250m
memory: 512Mi
limits:
cpu: "1"
memory: 1Gi
startupProbe:
httpGet:
path: /ping
port: health
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 30
livenessProbe:
httpGet:
path: /ping
port: health
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 6
# A wedged process cannot use the normal five-minute drain window.
terminationGracePeriodSeconds: 30
readinessProbe:
httpGet:
path: /ping

View File

@ -9,4 +9,4 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 25Gi
storage: 40Gi

View File

@ -268,9 +268,11 @@ data:
url('https://scm.bstein.dev/bstein/lesavka.git')
credentials('gitea-pat')
}
branches('*/dev-phone-companion-updates')
// Pin both the pipeline definition and worker checkout to the request.
branches('$EXPECTED_SOURCE_REVISION')
}
}
lightweight(false)
scriptPath('docker/Jenkinsfile.compile')
}
}
@ -333,6 +335,7 @@ data:
stringParam('APK21_SHA256', '', 'Reviewed unsigned version-21 fixture hash.')
stringParam('APK22_SHA256', '', 'Reviewed unsigned version-22 fixture hash.')
choiceParam('ANDROID_API', ['34', '36'], 'Empty VM API; separate result per platform.')
choiceParam('ANDROID_IMAGE_TAG', ['platform-default', 'default', 'google_apis'], 'Explicit image comparison; platform-default retains API34 AOSP and API36 Google APIs. AOSP does not qualify Google delivery.')
stringParam('ANDROID_WORKER_IMAGE', '', 'Reviewed lesavka-android-runtime image digest.')
}
definition {
@ -377,9 +380,12 @@ data:
url('https://scm.bstein.dev/bstein/lesavka.git')
credentials('gitea-pat')
}
branches('*/dev-phone-companion-updates')
// Select both Jenkinsfile and worker source from the queued revision.
branches('$EXPECTED_SOURCE_REVISION')
}
}
// A commit is not a branch-head name for lightweight retrieval.
lightweight(false)
scriptPath('docker/Jenkinsfile.software-tests')
}
}
@ -489,9 +495,11 @@ data:
url('https://scm.bstein.dev/bstein/lesavka.git')
credentials('gitea-pat')
}
branches('*/dev-phone-companion-updates')
// Pin both the pipeline definition and worker checkout to the request.
branches('$EXPECTED_SOURCE_REVISION')
}
}
lightweight(false)
scriptPath('docker/Jenkinsfile.runtime')
}
}

View File

@ -0,0 +1,23 @@
# services/jenkins/ingress-http.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jenkins-http
namespace: jenkins
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.tls: "false"
traefik.ingress.kubernetes.io/router.middlewares: jenkins-jenkins-https-redirect@kubernetescrd
spec:
ingressClassName: traefik
rules:
- host: ci.bstein.dev
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: jenkins
port:
name: http

View File

@ -17,6 +17,8 @@ resources:
- vault-sync-deployment.yaml
- deployment.yaml
- service.yaml
- middleware-https-redirect.yaml
- ingress-http.yaml
- ingress.yaml
- lesavka-userns-probe.yaml
- lesavka-kvm-device-plugin.yaml

View File

@ -0,0 +1,10 @@
# services/jenkins/middleware-https-redirect.yaml
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: jenkins-https-redirect
namespace: jenkins
spec:
redirectScheme:
scheme: https
permanent: true

View File

@ -0,0 +1,143 @@
// Controller-side acceptance probe with a private Git fixture. Supply one reviewed
// job's DSL as candidateSeed and its allowlisted name as candidateJob. Installed
// jobs are never saved, queued or changed.
import groovy.json.JsonOutput
import groovy.xml.XmlUtil
import hudson.EnvVars
import hudson.FilePath
import hudson.model.TaskListener
import hudson.plugins.git.GitSCM
import hudson.plugins.git.util.BuildChooserContext
import hudson.plugins.git.util.BuildData
import javaposse.jobdsl.dsl.DslScriptLoader
import javaposse.jobdsl.dsl.Item
import javaposse.jobdsl.plugin.JenkinsJobManagement
import jenkins.model.Jenkins
import org.jenkinsci.plugins.gitclient.Git
import org.jenkinsci.plugins.gitclient.GitClient
import org.eclipse.jgit.storage.file.FileRepositoryBuilder
import java.nio.file.Files
import java.nio.file.attribute.PosixFilePermissions
class ReviewOnly extends JenkinsJobManagement {
Map<String, String> rendered = [:]
final String expectedJob
ReviewOnly(String expectedJob) {
super(TaskListener.NULL.logger, [:], new File('/tmp'))
this.expectedJob = expectedJob
}
@Override boolean createOrUpdateConfig(Item item, boolean ignoreExisting) {
assert item.name == expectedJob
rendered[item.name] = item.xml
return true
}
@Override void queueJob(String name) {
throw new IllegalStateException('acceptance probe cannot queue jobs')
}
}
def selectedJob = binding.getVariable('candidateJob')
def expected = [
'lesavka-software-tests': [path: 'docker/Jenkinsfile.software-tests', builds: '8'],
'lesavka-compile': [path: 'docker/Jenkinsfile.compile', builds: '12'],
'lesavka-runtime-tests': [path: 'docker/Jenkinsfile.runtime', builds: '8'],
]
assert expected.containsKey(selectedJob)
def review = new ReviewOnly(selectedJob)
def installedState = {
def current = Jenkins.get().getItemByFullName(selectedJob).definition
[path: current.scriptPath, lightweight: current.lightweight, branches: current.scm.branches*.name]
}
def before = installedState()
new DslScriptLoader(review).runScript(binding.getVariable('candidateSeed'))
assert review.rendered.keySet() == [selectedJob] as Set
def xml = new XmlParser().parseText(review.rendered[selectedJob])
def definition = Jenkins.XSTREAM2.fromXML(XmlUtil.serialize(xml.definition[0]))
assert !definition.lightweight
assert definition.scriptPath == expected[selectedJob].path
def scm = definition.scm
assert scm.branches*.name == ['$EXPECTED_SOURCE_REVISION']
assert scm.userRemoteConfigs.size() == 1
assert scm.userRemoteConfigs[0].url == 'https://scm.bstein.dev/bstein/lesavka.git'
assert scm.userRemoteConfigs[0].credentialsId == 'gitea-pat'
assert xml.properties.'org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty'.size() == 1
assert xml.properties.'jenkins.model.BuildDiscarderProperty'.strategy.numToKeep.text() == expected[selectedJob].builds
assert xml.properties.'jenkins.model.BuildDiscarderProperty'.strategy.artifactNumToKeep.text() == '4'
def resolver = GitSCM.getDeclaredMethod('getSingleBranch', EnvVars)
resolver.accessible = true
def directory = Files.createTempDirectory('lesavka-source-selection-',
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString('rwx------'))).toFile()
def checks = []
try {
// Tiny public fixture only. No network, credentials, real repository or build.
def git = Git.with(TaskListener.NULL, new EnvVars()).in(directory).using('git').getClient()
git.init()
git.setAuthor('Lesavka CI fixture', 'fixture@example.invalid')
git.setCommitter('Lesavka CI fixture', 'fixture@example.invalid')
def pipeline = new File(directory, definition.scriptPath)
assert pipeline.parentFile.mkdirs()
def payload = new File(directory, 'source.txt')
pipeline.text = 'reviewed pipeline\n'
payload.text = 'reviewed source\n'
git.add('.')
git.commit('Reviewed fixture')
def requested = git.revParse('HEAD').name()
pipeline.text = 'later pipeline\n'
payload.text = 'later source\n'
git.add('.')
git.commit('Branch advanced while request waited')
def later = git.revParse('HEAD').name()
assert later != requested
def repository = new FileRepositoryBuilder().setGitDir(new File(directory, '.git')).build()
try {
def branch = repository.updateRef('refs/remotes/origin/dev-phone-companion-updates')
branch.setNewObjectId(git.revParse('HEAD'))
branch.forceUpdate()
} finally {
repository.close()
}
checks << 'branch_advanced_after_requested_revision'
// Reproduce the old selector choosing the later branch tip in this fixture.
def oldScm = new GitSCM('https://example.invalid/review.git')
oldScm.branches = [new hudson.plugins.git.BranchSpec('*/dev-phone-companion-updates')]
def oldExpanded = resolver.invoke(oldScm, new EnvVars([EXPECTED_SOURCE_REVISION: requested]))
def oldCandidates = oldScm.buildChooser.getCandidateRevisions(false, oldExpanded,
(GitClient) git, TaskListener.NULL, new BuildData(), (BuildChooserContext) null)
assert oldCandidates.size() == 1 && oldCandidates.first().sha1String == later
checks << 'old_selector_reproduces_moving_branch_defect'
// Exercise the installed plugin's expansion and actual revision chooser.
def expanded = resolver.invoke(scm, new EnvVars([EXPECTED_SOURCE_REVISION: requested]))
assert expanded == requested
def candidates = scm.buildChooser.getCandidateRevisions(false, expanded, (GitClient) git,
TaskListener.NULL, new BuildData(), (BuildChooserContext) null)
assert candidates.size() == 1 && candidates.first().sha1String == requested
git.checkout().ref(candidates.first().sha1String).execute()
assert git.revParse('HEAD').name() == requested
assert pipeline.text == 'reviewed pipeline\n' && payload.text == 'reviewed source\n'
checks << 'requested_pipeline_and_payload_selected_after_branch_advance'
// A nonexistent full revision must not fall back to branch HEAD.
def missing = resolver.invoke(scm, new EnvVars([EXPECTED_SOURCE_REVISION: '0' * 40]))
assert scm.buildChooser.getCandidateRevisions(false, missing, (GitClient) git,
TaskListener.NULL, new BuildData(), (BuildChooserContext) null).isEmpty()
checks << 'missing_revision_does_not_select_head'
// No real-job mutation: loading/parsing this configuration is not rollout.
assert installedState() == before
checks << 'installed_job_unchanged'
} finally {
new FilePath(directory).deleteRecursive()
}
assert !directory.exists()
checks << 'private_fixture_removed'
println(JsonOutput.toJson([status: 'passed', job: selectedJob, checks: checks,
plugins: ['git', 'git-client', 'workflow-cps', 'job-dsl'].collectEntries {
[(it): Jenkins.get().pluginManager.getPlugin(it).version]
}]))
return null

View File

@ -0,0 +1,56 @@
// Read public worker definitions through the installed Pipeline step. Supply two
// reviewed commits with different payload hashes and an existing software run.
// No job is created, saved, queued or changed; credentials stay inside GitSCMSource.
import groovy.json.JsonOutput
import hudson.model.Run
import hudson.model.TaskListener
import jenkins.model.Jenkins
import jenkins.plugins.git.GitSCMSource
import org.jenkinsci.plugins.workflow.steps.StepContext
import org.jenkinsci.plugins.workflow.steps.scm.ReadScmFileStep
import java.security.MessageDigest
def job = Jenkins.get().getItemByFullName('lesavka-software-tests')
def build = job.getBuildByNumber(binding.getVariable('existingBuild') as int)
assert build != null && !build.building
def before = job.configFile.asString()
def context = [get: { Class type ->
if (type == Run) { return build }
if (type == TaskListener) { return TaskListener.NULL }
throw new IllegalStateException('Unexpected step context: ' + type.name)
}] as StepContext
def source = new GitSCMSource('https://scm.bstein.dev/bstein/lesavka.git')
source.credentialsId = 'gitea-pat'
def read = { String revision, String path ->
def execution = new ReadScmFileStep(source, revision, path).start(context)
def method = execution.class.getDeclaredMethod('run')
method.accessible = true
method.invoke(execution)
}
def digest = { String value ->
MessageDigest.getInstance('SHA-256').digest(value.getBytes('UTF-8')).encodeHex().toString()
}
def expected = binding.getVariable('expectedPayloads')
assert expected.size() == 2 && expected.values().toSet().size() == 2
def checks = []
expected.each { revision, sha256 ->
assert revision ==~ /[0-9a-f]{40}/
assert sha256 ==~ /[0-9a-f]{64}/
assert digest(read(revision, 'docker/software-test-pod.yaml')) == sha256
checks << 'exact_worker_payload_' + revision
}
boolean missingRefused = false
try {
read('0' * 40, 'docker/software-test-pod.yaml')
} catch (java.lang.reflect.InvocationTargetException failure) {
assert failure.cause instanceof hudson.AbortException
assert failure.cause.message == 'No such revision'
missingRefused = true
}
assert missingRefused
checks << 'missing_revision_refused_without_fallback'
assert job.configFile.asString() == before
checks << 'installed_job_unchanged'
println(JsonOutput.toJson([status: 'passed', checks: checks,
plugin: Jenkins.get().pluginManager.getPlugin('workflow-scm-step').version]))
return null

View File

@ -5,6 +5,66 @@ metadata:
name: vmalert-atlas-availability-rules
namespace: monitoring
data:
ingress-health.yaml: |
groups:
- name: atlas.ingress.health
interval: 1m
# Availability must use fresh samples, not the rollups' one-hour lookback.
params:
step: [2m]
rules:
- alert: AtlasIngressUnavailable
expr: (max(kube_deployment_status_replicas_available{namespace="traefik",deployment="traefik"}) or vector(0)) == 0
for: 1m
labels:
severity: critical
service: atlas-ingress
annotations:
summary: "Atlas ingress has no available replicas"
description: "Public services including ci.bstein.dev may be unreachable. Check Traefik readiness, termination reasons and kube-state-metrics freshness before restarting applications."
- alert: AtlasIngressRedundancyLost
expr: |
(max(kube_deployment_status_replicas_available{namespace="traefik",deployment="traefik"}) < 2)
and (max(kube_deployment_status_replicas_available{namespace="traefik",deployment="traefik"}) > 0)
for: 5m
labels:
severity: warning
service: atlas-ingress
annotations:
summary: "Atlas ingress has lost its second replica"
description: "Only one Traefik replica has been available for five minutes. Inspect rollout events, /ping and memory pressure before the remaining replica fails."
- alert: AtlasIngressOOMKilled
expr: |
(max by (namespace, pod, container) (kube_pod_container_status_last_terminated_reason{namespace="traefik",container="traefik",reason="OOMKilled"}) == 1)
and on (namespace, pod, container)
(max by (namespace, pod, container) (increase(kube_pod_container_status_restarts_total{namespace="traefik",container="traefik"}[15m])) > 0)
labels:
severity: warning
service: atlas-ingress
annotations:
summary: "Traefik was killed by its memory limit"
description: "{{ $labels.pod }} restarted after an OOM kill. Inspect open connections, request timeouts and Go memory usage; increasing the limit alone does not bound retained connections."
- alert: AtlasIngressMemoryPressure
expr: |
max by (namespace, pod, container) (container_memory_working_set_bytes{namespace="traefik",container="traefik"})
/ on (namespace, pod, container)
max by (namespace, pod, container) (kube_pod_container_resource_limits{namespace="traefik",container="traefik",resource="memory"}) > 0.85
for: 5m
labels:
severity: warning
service: atlas-ingress
annotations:
summary: "Traefik memory has exceeded 85% of its limit"
description: "{{ $labels.pod }} is approaching its memory limit. Check connection counts and timeout settings before ingress becomes unavailable."
- alert: JenkinsControllerUnavailable
expr: (max(kube_deployment_status_replicas_available{namespace="jenkins",deployment="jenkins"}) or vector(0)) == 0
for: 2m
labels:
severity: critical
service: jenkins
annotations:
summary: "Jenkins has no available controller"
description: "Check Jenkins pod events, /login, its PVC and Vault initialization. If the controller is healthy, check Traefik and SSO separately. Missing deployment telemetry also triggers this alert."
hermes-triage.yaml: |
groups:
- name: hermes.triage