Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed0a862657 | ||
|
|
bf28adc7fb | ||
|
|
8beefde2a4 | ||
|
|
4d1996c0ab | ||
|
|
34c4c7488a | ||
|
|
11270cfced | ||
|
|
249488d6fc | ||
|
|
336eaaefa7 | ||
|
|
b6cf080618 | ||
|
|
d3a5e6bc73 | ||
|
|
9b0dc4dc52 | ||
|
|
d54d801020 | ||
|
|
ac18f11186 |
@@ -0,0 +1,7 @@
|
||||
# Docker/Jenkins shell scripts require Unix line endings on Windows checkouts.
|
||||
delivery/**/*.sh text eol=lf
|
||||
delivery/agent/ssh_config.droplet text eol=lf
|
||||
gitea/droplet-runner/*.sh text eol=lf
|
||||
|
||||
# Preserve spaces emitted by tools in captured evidence.
|
||||
delivery/evidence/*.txt -whitespace
|
||||
@@ -91,5 +91,13 @@ Thumbs.db
|
||||
*.key
|
||||
secrets.*
|
||||
|
||||
# Source images, the reference template, and the reviewed root submission PDF
|
||||
# are intentionally not ignored.
|
||||
# Source images and the reference template remain versioned.
|
||||
# Local manual builds replace one deliverable; do not commit generated PDFs.
|
||||
/manual/2026F-SSW-590-DevOps-Group-1.pdf
|
||||
/manual/latex/devopsAssignment.pdf
|
||||
|
||||
# Python test environments and bytecode
|
||||
.venv/
|
||||
.ansible-venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
@@ -6,10 +6,22 @@ pipeline {
|
||||
steps { checkout scm }
|
||||
}
|
||||
stage('Syntax check') {
|
||||
steps { sh 'python3 -m py_compile pricing.py' }
|
||||
steps {
|
||||
sh 'python3 -m py_compile pricing.py'
|
||||
sh '''python3 -B - <<'PY'
|
||||
import ast
|
||||
from pathlib import Path
|
||||
for source in Path('delivery').rglob('*.py'):
|
||||
ast.parse(source.read_text(), filename=str(source))
|
||||
print('Delivery Python syntax: passed')
|
||||
PY'''
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps { sh 'python3 -m unittest discover -s tests -v' }
|
||||
steps {
|
||||
sh 'python3 -m unittest discover -s tests -v'
|
||||
sh 'python3 -B -m unittest discover -s delivery/ci -p "test_controls.py" -v'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
# Manual compiler and Gitea workflow
|
||||
|
||||
## Current runner placement
|
||||
|
||||
On 14 November 2026 Vincent requested moving the active Actions runner onto
|
||||
The-Ocean. Its historical name/label remain `ssw590-vince-local` / `latex-local`;
|
||||
the same tested compiler image below was transferred with checksum verification.
|
||||
The laptop daemon is stopped. Remote jobs are capped at 512 MiB RAM / 768 MiB
|
||||
RAM+swap and 0.5 CPU. Run them sequentially with Jenkins delivery work.
|
||||
See [remote runner operations](../../gitea/droplet-runner/README.md).
|
||||
The Docker Desktop instructions below remain useful for image reproduction
|
||||
and an explicitly selected fallback, not for starting a second live runner.
|
||||
|
||||
## Local runner preparation
|
||||
|
||||
Build the job image on the runner's Docker Desktop engine from repository root:
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
**/__pycache__
|
||||
**/.venv
|
||||
**/*.pyc
|
||||
agent/.env
|
||||
@@ -0,0 +1,178 @@
|
||||
# Billy / Claude handoff: Assignment 8 DNS
|
||||
|
||||
**Completed update, 15 November 2026:** Billy added both A records. Google and
|
||||
Cloudflare resolve them to `147.182.178.136`; Caddy now serves trusted HTTPS and
|
||||
redirects HTTP for both names. The app backends are still absent (HTTP 502).
|
||||
Do not repeat DNS setup. The original handoff below is retained as the dated
|
||||
November 14 preparation record; reviewed application releases remain pending.
|
||||
|
||||
Prepared for Billy Ye at Vincent Sun's request on **14 November 2026**.
|
||||
This file is context and a proposed procedure. Billy must authorize changes
|
||||
in his own session; it does not grant Claude account access or override its
|
||||
active instructions. Billy handles login and MFA privately.
|
||||
|
||||
## Quick start for Claude
|
||||
|
||||
Help Billy add the two A records below to the existing `yebilly.me` DNS zone,
|
||||
verify public resolution, and return a short evidence summary to Vincent.
|
||||
Recheck existing records first. Preserve earlier services and stop after DNS
|
||||
verification. SSH, Docker, Jenkins and application deployment are outside this
|
||||
DNS task. Do not rerun the deployment bootstrap; it is already complete.
|
||||
|
||||
```yaml
|
||||
task: assignment_8_dns_setup
|
||||
scope: two_A_records_and_verification
|
||||
domain: yebilly.me
|
||||
expected_provider: Namecheap
|
||||
droplet_name: The-Ocean
|
||||
droplet_ipv4: 147.182.178.136
|
||||
repository: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway
|
||||
prepared_branch: codex/assignment8-secure-delivery
|
||||
prepared_commit: bf28adc7fb03fe25c5cc939599e34427a61ad2fc
|
||||
records_to_add:
|
||||
- type: A
|
||||
host: staging
|
||||
fqdn: staging.yebilly.me
|
||||
value: 147.182.178.136
|
||||
ttl: Automatic
|
||||
- type: A
|
||||
host: app
|
||||
fqdn: app.yebilly.me
|
||||
value: 147.182.178.136
|
||||
ttl: Automatic
|
||||
success_condition: both_names_resolve_to_the_expected_IPv4_and_existing_records_are_preserved
|
||||
next_owner: Vincent_and_Codex_for_Caddy_TLS_and_reviewed_release_execution
|
||||
```
|
||||
|
||||
## Why these records are needed
|
||||
|
||||
Assignment 8 follows **Chapter 6, Secure Delivery and Rollback**, in instructor
|
||||
manual `dosManual-V1.43.pdf`. It requires distinct staging and production HTTPS
|
||||
hostnames. Both applications will run on the same existing droplet, in separate
|
||||
Docker Compose projects. Caddy selects the private application by hostname:
|
||||
|
||||
| Public hostname | Intended destination behind Caddy |
|
||||
|---|---|
|
||||
| `staging.yebilly.me` | `pricing-staging:8000` |
|
||||
| `app.yebilly.me` | `pricing-production:8000` |
|
||||
|
||||
An A record maps a name to the droplet's IPv4 address. It does not contain a
|
||||
port, URL scheme, or application path. Caddy will handle HTTPS certificates.
|
||||
This task uses the existing domain and droplet; no purchase is part of it.
|
||||
|
||||
Preparation already completed: locked v1 pricing service, Ansible, release and
|
||||
security gates, a trusted Jenkins agent now on The-Ocean (migrated from Vincent's
|
||||
laptop to avoid campus SSH restrictions), dedicated deployment
|
||||
access and scoped credentials. The prerequisite Jenkins job passed. The
|
||||
prepared branch was pushed and its ordinary Jenkins branch check passed.
|
||||
Peer review/merge, assessed releases and recovery exercises remain outstanding.
|
||||
The release job is disabled pending reviewed source. The new Caddy routes and
|
||||
production monitoring additions are prepared in Git but have not been applied.
|
||||
|
||||
## Observed baseline: recheck before making changes
|
||||
|
||||
Public Cloudflare DNS-over-HTTPS queries were checked on
|
||||
**14 November 2026, about 20:35 America/New_York**
|
||||
(15 November, about 01:35 UTC). These are observations, not a guarantee that
|
||||
the zone will remain unchanged when Billy opens it.
|
||||
|
||||
| Query | Observed answer |
|
||||
|---|---|
|
||||
| `yebilly.me` NS | `dns1.registrar-servers.com`, `dns2.registrar-servers.com` |
|
||||
| `staging.yebilly.me` A | NXDOMAIN: name did not exist |
|
||||
| `app.yebilly.me` A | NXDOMAIN: name did not exist |
|
||||
| `git.yebilly.me` A | `147.182.178.136` |
|
||||
| `ci.yebilly.me` A | `147.182.178.136` |
|
||||
| `metrics.yebilly.me` A | `147.182.178.136` |
|
||||
|
||||
The existing services are Gitea (`git`), Jenkins (`ci`) and Grafana (`metrics`).
|
||||
Other zone records may also exist, including the retired Color Buttons name,
|
||||
mail and verification records. Preserve them. The droplet has been resized to
|
||||
2 GiB RAM with its 25 GB plan disk retained; no address change was observed.
|
||||
|
||||
## Namecheap procedure
|
||||
|
||||
1. Billy signs in to the account managing `yebilly.me`.
|
||||
2. Open **Domain List > Manage** beside that domain, then **Advanced DNS**.
|
||||
3. In **Host Records**, add the two rows from the YAML/table. Enter only
|
||||
`staging` or `app` in the Host field. Use **A Record**, the exact IPv4 value,
|
||||
and **Automatic** TTL. Save the two additions.
|
||||
4. Inspect the saved rows and retain a cropped screenshot showing those rows,
|
||||
with account, billing, login and secret information excluded.
|
||||
|
||||
If a requested record already has the correct value, reuse it. If an existing
|
||||
`staging` or `app` record conflicts (including a CNAME/redirect), explain the
|
||||
conflict to Billy before changing it; do not delete unrelated records. This
|
||||
request is for IPv4 A records, not additional AAAA, wildcard or redirect records.
|
||||
|
||||
If Host Records is unavailable or nameservers differ from the baseline, identify
|
||||
the active DNS provider and edit the existing zone there. Keep nameserver
|
||||
delegation unchanged. Namecheap documents this distinction in its host-record
|
||||
guide linked below.
|
||||
|
||||
## Verify and capture evidence
|
||||
|
||||
From PowerShell, record the actual UTC time and check public resolution:
|
||||
|
||||
```powershell
|
||||
[DateTime]::UtcNow.ToString('o')
|
||||
Resolve-DnsName staging.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
|
||||
Resolve-DnsName app.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
|
||||
Resolve-DnsName staging.yebilly.me -Type A -Server 8.8.8.8 -DnsOnly
|
||||
Resolve-DnsName app.yebilly.me -Type A -Server 8.8.8.8 -DnsOnly
|
||||
```
|
||||
|
||||
Expected A answer for both names: **147.182.178.136**. A resolver may briefly
|
||||
retain the earlier negative answer; allow caches to expire and repeat. A lookup
|
||||
that times out on a restricted network is inconclusive. Do not report success
|
||||
from the saved dashboard rows alone.
|
||||
|
||||
Recheck the earlier names as well:
|
||||
|
||||
```powershell
|
||||
Resolve-DnsName git.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
|
||||
Resolve-DnsName ci.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
|
||||
Resolve-DnsName metrics.yebilly.me -Type A -Server 1.1.1.1 -DnsOnly
|
||||
```
|
||||
|
||||
If direct public-resolver queries are blocked, use an available DNS lookup
|
||||
method and record which resolver/method was actually used. Authoritative checks
|
||||
can help distinguish an unsaved record from resolver caching; document the
|
||||
actual results and any disagreement rather than assuming propagation completed.
|
||||
|
||||
**DNS success is not application success.** HTTPS may still be unavailable,
|
||||
show a certificate problem, or return an upstream error before Vincent applies
|
||||
Caddy routes and deploys the applications. Do not weaken TLS checks or alter
|
||||
firewall rules to make a DNS-only check appear successful.
|
||||
|
||||
## Return to Vincent
|
||||
|
||||
Report:
|
||||
|
||||
- The two saved record types, hostnames, values and actual TTL selection.
|
||||
- Verification UTC time, resolver(s), actual answers and any pending cache result.
|
||||
- Confirmation that existing records were preserved, with the earlier-name checks.
|
||||
- A cropped screenshot or text evidence containing no credentials/account details.
|
||||
- Any blocker, conflicting record, or unverified assumption.
|
||||
|
||||
Then Vincent/Codex can finish Caddy HTTPS setup and the reviewed release tests.
|
||||
Billy's separate code-review task remains: review/approve the preparation PR
|
||||
if satisfied, and later review v2 and the staging failure configuration. DNS
|
||||
completion does not approve code or authorize a production promotion.
|
||||
|
||||
For repository work, read `AGENTS.md`,
|
||||
`manual/latex/devopsAIAgentRequirements.tex` and
|
||||
`manual/latex/devopsAIAgentGuide.tex` first. Useful context is in
|
||||
`delivery/README.md`, `delivery/RUNBOOKS.md`, `delivery/SECURITY.md`,
|
||||
`deploy/Caddyfile` and `delivery/evidence/agent-preflight-1.txt`.
|
||||
|
||||
## Official references and provenance
|
||||
|
||||
- [Namecheap: add an A record](https://www.namecheap.com/support/knowledgebase/article.aspx/319/2237/how-can-i-set-up-an-a-address-record-for-my-domain/).
|
||||
- [Namecheap: host records, provider selection and TTL](https://www.namecheap.com/support/knowledgebase/article.aspx/434/2237/how-do-i-set-up-host-records-for-a-domain/).
|
||||
|
||||
Codex prepared this handoff at Vincent's explicit request, using the repository's
|
||||
prepared configuration, current public DNS observations and those official
|
||||
Namecheap guides. No DNS account was opened or modified during its preparation.
|
||||
The original instructor manual defines the assignment; the names/IP above are
|
||||
the team's selected deployment values.
|
||||
@@ -0,0 +1,55 @@
|
||||
# Preparation evidence — not completed release evidence
|
||||
|
||||
All timestamps below are UTC on 14 November 2026. No assessed application
|
||||
release, image publication, production approval or rollback has occurred yet.
|
||||
|
||||
| Check | Actual result |
|
||||
|---|---|
|
||||
| 19:50 user-run original target baseline | 961 MiB RAM, 126 MiB available, 752 MiB swap used; deploy account absent |
|
||||
| 20:15 post-resize SSH check | 1,967 MiB RAM, 1,008 MiB available, 101 MiB swap used; disk unchanged; seven containers up; zero failed systemd units |
|
||||
| Post-maintenance external HTTPS | Gitea, Jenkins and Grafana login routes each returned HTTP 200 from laptop |
|
||||
| 20:04 local runtime smoke | Gunicorn, UID 10001, read-only root/capability drops, 64 MiB cap; health v1, explicit `uncommitted-preflight` identity, total 30, invalid input HTTP 400 |
|
||||
| 19:55 synthetic secret gate | Blocked; actual scanner detected the generated fixture; exit status 1 |
|
||||
| 20:27 controlled wrong-price test | Three original tests passed; extra expected=-1 assertion failed; exit status 1 |
|
||||
| 20:40 restored local app baseline | Three tests passed; exit status 0 |
|
||||
| 20:32 full runtime image gate | Passed, zero HIGH/CRITICAL findings; full JSON and tool/database metadata retained |
|
||||
| 21:00–21:01 final source/dependency gate | Passed; source scanner and pip-audit exit status 0 |
|
||||
| Linux regression/syntax checks | Existing two tests and 12 delivery-control tests passed; Ansible syntax passed |
|
||||
| Jenkins/Compose validation | Dedicated delivery pipeline validated using installed declarative parser; final agent Compose configuration validated |
|
||||
| Proxy/monitoring candidates | Installed Caddy validation and Prometheus promtool syntax checks passed; candidates were not reloaded or applied |
|
||||
| 20:40:49 Jenkins bootstrap | Exclusive node and folder-scoped credentials created; pricing release job disabled; earlier jobs retained |
|
||||
| 20:42:28 agent connection | WebSocket opened; agent connected; no agent host port published |
|
||||
| 20:46 agent prerequisite build 1 | SUCCESS; real Jenkins credential binding, pinned SSH host key, deploy login, sudo, Python/Docker/Compose prerequisites |
|
||||
|
||||
The final preflight image was local only, tagged
|
||||
`ssw590-pricing:preflight-v1-runtime`. It is not a reviewed source release or
|
||||
published registry RepoDigest. Earlier Debian and installer-containing Alpine
|
||||
image scans were blocked and retained; no security exception was added.
|
||||
|
||||
Raw local reports: ignored `build/evidence/assignment8-local/`. Publicly
|
||||
versioned prerequisite inventory: `evidence/agent-preflight-1.txt`.
|
||||
Jenkins evidence: [build 1](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/1/)
|
||||
and its [tool inventory artifact](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/1/artifact/build/preflight/tools-and-target.txt).
|
||||
Jenkins requires existing approved-network access and login as applicable.
|
||||
|
||||
Remaining assessed evidence must come from actual reviewed v1/v2 pipeline
|
||||
runs, not these local checks. See `ISSUE.md` and `RUNBOOKS.md`.
|
||||
|
||||
## Later agent migration
|
||||
|
||||
The agent subsequently moved to The-Ocean at Vincent's direction to remove
|
||||
campus SSH dependence. [Migration record](evidence/agent-migration-20261114.md)
|
||||
distinguishes the actual remote prerequisite build 2 and bounded capacity trial
|
||||
from the initial laptop checks above. UTC dates cross into November 15 while
|
||||
the client's Eastern date is still November 14. At that point the PDF runner
|
||||
was unchanged. It subsequently moved too; see the
|
||||
[manual runner migration record](../gitea/droplet-runner/EVIDENCE.md).
|
||||
Assessed releases and recovery are still pending.
|
||||
|
||||
## DNS and TLS readiness
|
||||
|
||||
On 15 November Billy's two DNS records were verified and Caddy's prepared
|
||||
routes applied. Both names have trusted TLS and HTTP 308 redirects; HTTPS
|
||||
returns 502 while pricing backends are absent. See the
|
||||
[dated HTTPS evidence](evidence/https-20261115.md). Application deployment,
|
||||
production monitoring and assessed recovery evidence remain pending.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Implement Assignment 8 secure delivery and rollback
|
||||
|
||||
Use instructor manual 1.43 Chapter 6 and its Startup Pricing Service on the
|
||||
existing Gitea/Jenkins/Caddy/monitoring foundation.
|
||||
|
||||
- [x] Prepare exact dependencies, base digest, trusted agent and Ansible.
|
||||
- [x] Verify deploy SSH, host-key pinning, sudo and target prerequisites.
|
||||
- [x] Prepare gates, pipeline, approval and recovery automation.
|
||||
- [ ] Review/merge v1 source; configure staging/app DNS and TLS routes.
|
||||
- [ ] Show blocked unit-test and synthetic-secret Jenkins runs, then repair.
|
||||
- [ ] Publish v1; deploy staging; prove changed=0; approve production.
|
||||
- [ ] Preserve v1 records; review/merge v2; promote the same v2 digest.
|
||||
- [ ] Roll production back to matching v1 image/config; measure interruption.
|
||||
- [ ] Review staging-only bad command; show failed wait and recovery.
|
||||
- [ ] Add production monitoring and correlate actual samples/timestamps.
|
||||
- [ ] Finalize traceability, runbooks, history, AI log and one PDF.
|
||||
|
||||
Local preparation is not assessed release evidence. Preserve branch protection
|
||||
and earlier services/data; keep credentials out of Git and reports.
|
||||
@@ -0,0 +1,146 @@
|
||||
// A separate trusted delivery job loads this file from protected main.
|
||||
// The existing multibranch PR job keeps its ordinary test-only Jenkinsfile.
|
||||
pipeline {
|
||||
agent { label 'delivery-trusted' }
|
||||
options {
|
||||
skipDefaultCheckout()
|
||||
disableConcurrentBuilds()
|
||||
timeout(time: 60, unit: 'MINUTES')
|
||||
buildDiscarder(logRotator(numToKeepStr: '20'))
|
||||
}
|
||||
parameters {
|
||||
choice(name: 'MODE', choices: ['release', 'blocked-test', 'blocked-secret', 'rollback-production', 'staging-failure', 'recover-staging'], description: 'Reviewed release or recovery operation')
|
||||
string(name: 'SOURCE_COMMIT', defaultValue: '', description: 'Optional full reviewed source commit already on main')
|
||||
string(name: 'RELEASE_RECORD', defaultValue: '', description: 'Reviewed delivery/releases/*.json for rollback or recovery')
|
||||
string(name: 'STAGING_FAILURE_CONFIG', defaultValue: '', description: 'Only for staging-failure. Full reviewed commit of the staging-only bad command template')
|
||||
}
|
||||
environment {
|
||||
PYTHONDONTWRITEBYTECODE = '1'
|
||||
TRIVY_CACHE_DIR = '/home/jenkins/agent/.cache/trivy'
|
||||
}
|
||||
stages {
|
||||
stage('Reviewed checkout') {
|
||||
steps {
|
||||
deleteDir()
|
||||
checkout scm
|
||||
script {
|
||||
if (params.SOURCE_COMMIT) {
|
||||
if (!(params.SOURCE_COMMIT ==~ /[0-9a-f]{40}/)) {
|
||||
error('SOURCE_COMMIT must be a full Git commit')
|
||||
}
|
||||
withEnv(["RELEASE_SOURCE=${params.SOURCE_COMMIT}"]) {
|
||||
sh 'git merge-base --is-ancestor "$RELEASE_SOURCE" origin/main && git checkout --detach "$RELEASE_SOURCE"'
|
||||
}
|
||||
}
|
||||
}
|
||||
sh 'git merge-base --is-ancestor HEAD origin/main'
|
||||
sh 'mkdir -p build/delivery/reports && git rev-parse HEAD > build/delivery/reports/source-commit.txt'
|
||||
}
|
||||
}
|
||||
stage('Unit tests') {
|
||||
steps {
|
||||
sh 'python3 -B -m unittest discover -s delivery/ci -p "test_controls.py" -v'
|
||||
script {
|
||||
withEnv(["TEST_FAILURE=${params.MODE == 'blocked-test'}"]) {
|
||||
sh 'sh delivery/ci/test-app.sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Source security gates') {
|
||||
steps {
|
||||
script {
|
||||
def fixture = params.MODE == 'blocked-secret' ? ' --fixture' : ''
|
||||
sh "python3 delivery/ci/security.py source${fixture}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build, scan, publish') {
|
||||
when { expression { params.MODE == 'release' } }
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'delivery-registry-write', usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_TOKEN')]) {
|
||||
sh 'sh delivery/ci/publish.sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Select release record') {
|
||||
steps {
|
||||
script {
|
||||
if (params.MODE == 'release') {
|
||||
env.SELECTED_RECORD = sh(script: "find build/delivery/releases -name '*-staging.json'", returnStdout: true).trim()
|
||||
} else {
|
||||
if (!(params.RELEASE_RECORD ==~ /delivery\/releases\/[a-zA-Z0-9._-]+\.json/)) {
|
||||
error('Choose a committed delivery/releases/*.json record')
|
||||
}
|
||||
env.SELECTED_RECORD = params.RELEASE_RECORD
|
||||
if (params.MODE == 'staging-failure') {
|
||||
if (!(params.STAGING_FAILURE_CONFIG ==~ /[0-9a-f]{40}/)) {
|
||||
error('Choose the full reviewed staging failure configuration commit')
|
||||
}
|
||||
withEnv(["FAILURE_CONFIG=${params.STAGING_FAILURE_CONFIG}"]) {
|
||||
sh '''mkdir -p build/delivery/releases
|
||||
python3 - <<'PY'
|
||||
import json, os
|
||||
from pathlib import Path
|
||||
record = json.loads(Path(os.environ['SELECTED_RECORD']).read_text())
|
||||
assert record['target_env'] == 'staging', 'Failure exercise requires staging'
|
||||
record['configuration_commit'] = os.environ['FAILURE_CONFIG']
|
||||
Path('build/delivery/releases/failure-staging.json').write_text(json.dumps(record, indent=2))
|
||||
PY'''
|
||||
}
|
||||
env.SELECTED_RECORD = 'build/delivery/releases/failure-staging.json'
|
||||
}
|
||||
}
|
||||
}
|
||||
sh 'python3 delivery/ci/release.py verify "$SELECTED_RECORD"'
|
||||
}
|
||||
}
|
||||
stage('Staging deploy and unchanged rerun') {
|
||||
when { expression { params.MODE == 'release' || params.MODE == 'recover-staging' || params.MODE == 'staging-failure' } }
|
||||
steps {
|
||||
withCredentials([
|
||||
sshUserPrivateKey(credentialsId: 'delivery-deploy-ssh', keyFileVariable: 'DEPLOY_KEY'),
|
||||
file(credentialsId: 'delivery-known-hosts', variable: 'DEPLOY_KNOWN_HOSTS')
|
||||
]) {
|
||||
sh 'sh delivery/ci/deploy.sh "$SELECTED_RECORD" staging'
|
||||
sh 'sh delivery/ci/deploy.sh "$SELECTED_RECORD" staging rerun'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Production approval') {
|
||||
when { expression { params.MODE == 'release' || params.MODE == 'rollback-production' } }
|
||||
steps {
|
||||
archiveArtifacts(artifacts: 'build/delivery/reports/**,build/delivery/releases/**', allowEmptyArchive: false)
|
||||
script {
|
||||
if (params.MODE == 'release') {
|
||||
env.SELECTED_RECORD = env.SELECTED_RECORD.replace('-staging.json', '-production.json')
|
||||
}
|
||||
sh 'python3 delivery/ci/release.py verify "$SELECTED_RECORD" --environment production'
|
||||
def record = readFile(env.SELECTED_RECORD)
|
||||
def approver
|
||||
timeout(time: 20, unit: 'MINUTES') {
|
||||
approver = input(message: "Approve production? Source, digest and target below. Review archived scan reports and staging console results.\n${record}", ok: 'Approve production', submitter: 'billy,vsun1', submitterParameter: 'APPROVER')
|
||||
}
|
||||
def approvedAt = sh(script: 'date -u +%Y-%m-%dT%H:%M:%SZ', returnStdout: true).trim()
|
||||
writeFile(file: 'build/delivery/reports/production-approval.txt', text: "Approver=${approver}\nDecision=approved\nUTC=${approvedAt}\n${record}\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Production deploy and verification') {
|
||||
when { expression { params.MODE == 'release' || params.MODE == 'rollback-production' } }
|
||||
steps {
|
||||
withCredentials([
|
||||
sshUserPrivateKey(credentialsId: 'delivery-deploy-ssh', keyFileVariable: 'DEPLOY_KEY'),
|
||||
file(credentialsId: 'delivery-known-hosts', variable: 'DEPLOY_KNOWN_HOSTS')
|
||||
]) {
|
||||
sh 'sh delivery/ci/deploy.sh "$SELECTED_RECORD" production'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts(artifacts: 'build/delivery/reports/**,build/delivery/releases/**', excludes: '**/test-venv/**', allowEmptyArchive: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
# Prepare secure delivery and rollback for Assignment 8
|
||||
|
||||
The existing CI checks code but does not publish or promote an application.
|
||||
Add the instructor's pricing service with locked inputs and a trusted-agent
|
||||
pipeline for security gates, digest-based staging/production deployment,
|
||||
unchanged Ansible reruns, recorded human approval and recovery operations.
|
||||
Keep the earlier PR job separate from folder-scoped deployment credentials.
|
||||
|
||||
Include the reproducible agent/bootstrap, scan policy, runbooks, actual
|
||||
prerequisite evidence and a clearly marked preparation chapter. Billy's DNS
|
||||
records and Caddy HTTPS routes are now verified; app requests return 502 until
|
||||
the backends are deployed. Monitoring additions await healthy production.
|
||||
The release job is configured but disabled until reviewed source
|
||||
reaches main. Assessed v1/v2 promotions and both recovery exercises remain
|
||||
pending and will require separate reviewed changes and execution evidence.
|
||||
|
||||
Validation: two existing tests, three Flask tests, twelve control tests;
|
||||
controlled test/secret blocks; passing source/dependency and runtime-image
|
||||
gates; Ansible syntax, agent Compose and installed Jenkins parser checks;
|
||||
successful prerequisite builds 1 (laptop) and 2 (Droplet), including pinned
|
||||
deployment SSH and noninteractive sudo. The agent now runs on the existing
|
||||
2 GiB Droplet to avoid campus SSH restrictions, with separate agent/builder
|
||||
resource caps and a passing bounded build/scan/smoke trial. Shared-host Docker
|
||||
administration is documented. The original Gitea Actions runner also moved to
|
||||
the Droplet with its existing identity, separate daemon/job caps and a passing
|
||||
reviewed-main run 12 rerun (attempt 3); the initial low-memory attempt is retained.
|
||||
No production approval or completed release is claimed.
|
||||
@@ -0,0 +1,117 @@
|
||||
# Secure Delivery and Rollback — Assignment 8
|
||||
|
||||
The active application starts with the instructor's Startup Pricing Service
|
||||
v1 from `Examples.zip`, `Examples/dosSecureDelivery/v1/`. The deployment
|
||||
starters come from that bundle's `ansible/` directory. The task follows
|
||||
Chapter 6 of instructor manual version 1.43.
|
||||
|
||||
`app/` contains the Flask/Gunicorn service, nine exact direct/transitive
|
||||
dependencies, and a pinned Python 3.13 Alpine base digest for Linux/amd64.
|
||||
The inventory selects The-Ocean's dedicated deploy account. The example
|
||||
release record remains explicitly an example; real registry digests will be
|
||||
generated by Jenkins after the source has been reviewed and merged.
|
||||
|
||||
Run the tests from `app/` after installing its requirements into the selected
|
||||
Linux test environment. The expected v1 result for three units is USD 30.
|
||||
The later v2 source/test change will be a separate reviewed commit and will
|
||||
return USD 36. The source commit must be baked into each built image.
|
||||
|
||||
Deployment work uses a dedicated trusted Jenkins agent, immutable images
|
||||
in the existing Gitea registry, and separate Ansible-managed staging and
|
||||
production Compose projects. The agent requires Docker build capability,
|
||||
Python, Ansible, the Docker collection, and the selected security scanners.
|
||||
Registry publication, staging deployment, approval, production promotion,
|
||||
and both recovery exercises require dated execution evidence.
|
||||
|
||||
## Attribution and preparation record
|
||||
|
||||
On 14 November 2026 Vincent asked Codex to review the assignment and begin
|
||||
preparation while he started Docker Desktop. Codex checked the repository's
|
||||
AI requirements and usage guide, read Chapter 6 and the example sources,
|
||||
verified remote main `8beefde`, and created branch
|
||||
`codex/assignment8-secure-delivery`. It copied the v1 and Ansible starters
|
||||
without changing their contents and checked Python syntax. This preparation
|
||||
record will be consolidated into the manual's AI assistance log when the
|
||||
assignment chapter is authored. The instructor retains authorship of the
|
||||
starter application and playbook.
|
||||
|
||||
## Verified preparation, 14 November 2026
|
||||
|
||||
The existing two pricing tests, three new Flask tests and twelve release/control
|
||||
tests passed. The deliberate wrong-price assertion failed as intended; the
|
||||
synthetic secret fixture blocked its gate. Pip-audit passed for the nine locked
|
||||
application dependencies. The full Trivy runtime-image gate reported no HIGH
|
||||
or CRITICAL findings. Earlier failed scans remain in ignored local evidence;
|
||||
no scanner exception was introduced. A non-root Gunicorn container passed
|
||||
health, identity, pricing and invalid-input checks with a 64 MiB memory cap.
|
||||
|
||||
The droplet now has 2 GiB RAM and its original 25 GB plan disk. Vincent resized
|
||||
it and installed package updates. The existing seven service containers and
|
||||
their HTTPS routes were verified after maintenance.
|
||||
|
||||
The trusted node `ssw590-vince-delivery` now runs on The-Ocean, with one
|
||||
exclusive executor and label `delivery-trusted`. Its name is retained from
|
||||
the initial laptop installation. The laptop copy is stopped. The remote
|
||||
agent uses private HTTP/WebSocket to `jenkins:8080`; its SSH configuration
|
||||
routes the existing deployment inventory address through Docker's host gateway,
|
||||
retaining `HostKeyAlias 147.182.178.136` and the pinned Jenkins known-hosts file.
|
||||
No campus SSH connection is needed to run a delivery job from the browser.
|
||||
[Agent prerequisite build 1](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/1/)
|
||||
passed using the dedicated deploy key, pinned host key and root sudo. Its
|
||||
non-secret tool inventory is versioned in `evidence/agent-preflight-1.txt`.
|
||||
The `secure-delivery/pricing` job loads `delivery/Jenkinsfile` from protected
|
||||
main and is disabled pending reviewed source. Release credentials are scoped
|
||||
to that Jenkins folder; the PR job does not bind them or the Docker socket.
|
||||
|
||||
The original inventory above is historical. [Remote prerequisite build 2](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/2/)
|
||||
passed after migration; `evidence/agent-preflight-2.txt` records the tools and
|
||||
target. A separate bounded capacity trial passed control/app tests, source and
|
||||
dependency checks, a limited image build, image scan and temporary HTTP smoke.
|
||||
It used a preparation snapshot, not a reviewed release, and published nothing.
|
||||
|
||||
The deployment account has root-only passwordless sudo: effective host
|
||||
administration privileges, restricted to reviewed delivery code. Distinct
|
||||
package-write and package-read tokens under `vsun1` are stored in Jenkins and
|
||||
root's target Docker configuration respectively. No values are in Git.
|
||||
Remote agent identity and workspace live in named Docker volumes outside Git.
|
||||
The agent has administrative access to the same Docker host as Jenkins and
|
||||
Gitea; a container is not a security boundary against malicious trusted jobs.
|
||||
Use only reviewed delivery code. `agent/compose.droplet.yaml` caps the agent
|
||||
at 512 MiB RAM / 768 MiB RAM+swap and 0.5 CPU; a dedicated pinned BuildKit
|
||||
builder has 256 MiB / 384 MiB and 0.5 CPU. Builds select that builder explicitly.
|
||||
Agent and builder restart unless stopped. `bootstrap/start-droplet-agent.sh`
|
||||
is the root-operated installation/reconnect helper in
|
||||
`/opt/ssw590-delivery-agent`; it detects the Docker socket group (987 on this host).
|
||||
No public agent, Docker API or app port is added.
|
||||
|
||||
`bootstrap/start-agent.ps1` refuses to start the laptop copy by default.
|
||||
For an intentional fallback, first stop the remote agent and builder, then use
|
||||
`-AllowLaptopFallback`. Never connect both copies of the same node. Preserve
|
||||
their volumes. The Gitea Actions manual-build runner subsequently moved to
|
||||
The-Ocean too; see `../gitea/droplet-runner/README.md`. Neither active runner
|
||||
now depends on Docker Desktop. Run manual builds and delivery releases sequentially.
|
||||
See `RUNBOOKS.md`.
|
||||
|
||||
Ansible syntax, agent Compose configuration, and the installed Jenkins
|
||||
controller's declarative parser checks passed. These are preparation checks;
|
||||
**v1/v2 registry releases, promotion and recovery are not yet demonstrated**.
|
||||
|
||||
## Remaining checkpoints
|
||||
|
||||
Vincent pushed preparation commit `bf28adc` and opened PR #24. The later
|
||||
migration changes are uncommitted and need the same review path. Create the
|
||||
issue and obtain Billy's PR review. Keep main protection. Billy added the A
|
||||
records; Google and Cloudflare now resolve both names to `147.182.178.136`.
|
||||
On 15 November Caddy's prepared routes were validated and gracefully reloaded;
|
||||
both names have trusted HTTPS and HTTP redirects. They currently return 502
|
||||
because the app containers are not deployed. See `evidence/https-20261115.md`.
|
||||
Enable the
|
||||
release job after the reviewed source reaches main, then follow `RUNBOOKS.md`.
|
||||
Keep Jenkins and the remote delivery node available. Production approval requires an authorized
|
||||
human; an agent must not approve unattended.
|
||||
|
||||
`SECURITY.md` defines the gate policy. `bootstrap/` makes administrator setup
|
||||
reviewable; its one-time script refuses to overwrite existing deployment state.
|
||||
Raw local reports remain under ignored `build/evidence/assignment8-local/`.
|
||||
The manual records material AI assistance and distinguishes pending work from
|
||||
actual evidence. This preparation is not ready for assignment submission.
|
||||
@@ -0,0 +1,167 @@
|
||||
# Release, recovery and cleanup
|
||||
|
||||
These are execution instructions, not completed release evidence.
|
||||
|
||||
Current status, 15 November 2026: Billy's DNS records resolve correctly and the
|
||||
two Caddy routes are active with trusted certificates and HTTP-to-HTTPS redirects.
|
||||
502 is expected while the app backends are absent. The one-time HTTPS helper
|
||||
has already run; use the normal validate/reload procedure for later changes.
|
||||
Monitoring additions and assessed releases remain pending.
|
||||
|
||||
## Authority and preparation
|
||||
|
||||
Billy reviews code; Vincent commits/pushes. Jenkins users `billy` or `vsun1`
|
||||
may approve production interactively; administrators retain override authority.
|
||||
The Droplet delivery agent must be online and source/configuration commits reviewed and
|
||||
merged into protected main. Do not run untrusted PR/fork code with its Docker
|
||||
socket or the delivery folder's credentials. Exclusive scheduling alone does
|
||||
not prevent someone authorized to alter jobs from selecting the node.
|
||||
|
||||
Confirm A records `staging` and `app` point to The-Ocean. Validate and reload
|
||||
the prepared additions to `/root/gitea/Caddyfile`, preserving the earlier file,
|
||||
allowlist environment and volumes. Publish no application host port. The
|
||||
applications join the existing `gitea_web` network with different aliases.
|
||||
Enable `secure-delivery/pricing` after reviewed source reaches main.
|
||||
|
||||
The installed-binary validation commands are:
|
||||
|
||||
```text
|
||||
docker exec gitea-caddy-1 caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile
|
||||
docker exec gitea-caddy-1 caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile
|
||||
docker exec monitoring-prometheus-1 promtool check config /etc/prometheus/prometheus.yml
|
||||
```
|
||||
|
||||
Preserve bind-mounted file inodes when copying new contents. Apply monitoring
|
||||
only after healthy production, then reload using its existing documented
|
||||
procedure. The temporary candidate checks already passed without a reload.
|
||||
|
||||
## v1 and v2
|
||||
|
||||
1. Run MODE `blocked-test`: the wrong-price fixture must fail and prevent
|
||||
publication/deployment. Run MODE `blocked-secret`: the generated synthetic
|
||||
fixture must block the scanner gate. Fixtures exist only during those runs.
|
||||
2. Run MODE `release` with the full reviewed v1 SOURCE_COMMIT if needed. Tests,
|
||||
dependency/secret checks and image gates must pass. The commit-tagged image
|
||||
is built once, scanned, pushed/pulled, and selected by exact registry digest.
|
||||
Existing commit tags are reused, not overwritten. Full reports are archived.
|
||||
3. Staging checks health, version, source SHA and total 30. Its unchanged rerun
|
||||
must report changed=0; the pipeline blocks otherwise.
|
||||
4. Review the presented release metadata, archived scans and staging results.
|
||||
An authorized human approves within 20 minutes. Rejection/timeout stops
|
||||
production. The actual approval identity/UTC is archived. Production uses
|
||||
the same digest and verifies all three endpoints; it does not rebuild.
|
||||
5. Save both generated v1 JSON records from Jenkins into `delivery/releases/`
|
||||
and review/commit them before recovery. Never invent a digest or commit SHA.
|
||||
6. Apply the supplied v2 application/test changes in a separate reviewed commit:
|
||||
VERSION=v2, UNIT_PRICE=12, expected total=36. Repeat the complete release and
|
||||
real approval. Preserve v1 images/configuration/records; save v2 records.
|
||||
|
||||
## Healthy production rollback
|
||||
|
||||
Record the detection/decision UTC and reason. Before approval, start the HTTPS
|
||||
observer on an available client or the remote agent, for example:
|
||||
|
||||
```text
|
||||
python delivery/ci/observe.py --url https://app.yebilly.me --seconds 600 --output build/evidence/assignment8/rollback-health.csv
|
||||
```
|
||||
|
||||
Run MODE `rollback-production` with committed
|
||||
`delivery/releases/v1-production.json`. SOURCE_COMMIT can stay on main: the
|
||||
record selects the exact historical image and configuration. Review/approve
|
||||
the input. Ansible restores playbook/template using `git archive` of the
|
||||
configuration commit, then verifies v1, its original SHA and total 30.
|
||||
Archive decision, approval, deployment start/completion/elapsed time and the
|
||||
observer CSV. Report failed samples and gaps; no failed samples does not prove
|
||||
zero interruption between requests. Correlate the 30-second monitoring samples.
|
||||
|
||||
## Failed staging deployment and recovery
|
||||
|
||||
After v2 succeeds, add this staging-only override to the app service in
|
||||
`ansible/templates/compose.yaml.j2` in a separate reviewed configuration commit:
|
||||
|
||||
```jinja2
|
||||
{% if target_env == 'staging' %}
|
||||
command: ["gunicorn", "--bind", "0.0.0.0:8001", "--workers", "1", "--worker-tmp-dir", "/tmp", "app:app"]
|
||||
{% endif %}
|
||||
```
|
||||
|
||||
The image's healthcheck still probes 8000. Select MODE `staging-failure`, the
|
||||
committed good v2 staging record, and full STAGING_FAILURE_CONFIG SHA. Compose
|
||||
wait must fail within its 90-second bound and stop Jenkins before production.
|
||||
Do not use MODE `release` to build an image for this configuration exercise.
|
||||
Restore/review the correct template, then use MODE `recover-staging` with the
|
||||
original good v2 staging record and matching configuration commit. Verify
|
||||
health, exact source SHA, total 36 and changed=0. Retain failure, restoration,
|
||||
recovery reports and observer timing. Do not alter earlier infrastructure to
|
||||
manufacture a failure.
|
||||
|
||||
## Monitoring and limits
|
||||
|
||||
After production is healthy, add `https://app.yebilly.me/health` to the existing
|
||||
Prometheus `https` job and display it in Grafana. Keep Gitea/Jenkins probes and
|
||||
host metrics. Validate configuration before reload. Record actual samples and
|
||||
alerts around releases/recovery; a short failure can fall between scrapes or
|
||||
below the alert duration. HTTP status cannot validate the expected price.
|
||||
|
||||
Each stateless app is capped at 64 MiB RAM, 96 MiB RAM+swap, 0.25 CPU and 64
|
||||
PIDs, with a read-only root filesystem, 16 MiB /tmp tmpfs, UID 10001 and all
|
||||
capabilities dropped. The remote agent is capped at 512 MiB RAM / 768 MiB
|
||||
RAM+swap and 0.5 CPU; its pinned BuildKit builder at 256 MiB / 384 MiB and
|
||||
0.5 CPU. The preparation trial passed but used swap and is not a full release
|
||||
load test. Keep one exclusive executor and serialized delivery. One droplet
|
||||
and a shared proxy network provide neither high availability nor strong lateral
|
||||
isolation. A real database migration or external payment can invalidate image
|
||||
rollback; use compatible expand/migrate/contract changes and tested backups.
|
||||
|
||||
## After grading, only when instructed
|
||||
|
||||
Archive required evidence first. Remove only the two pricing Compose projects,
|
||||
their routes, monitoring additions and test DNS names. Revoke the two named
|
||||
Assignment 8 package tokens, then remove the deploy key/sudo grant and its
|
||||
Jenkins folder/node when no longer needed. Preserve required job history before
|
||||
removing configuration. Stop the remote agent and dedicated builder; remove only their identity/workspace
|
||||
volumes after approval. Preserve Gitea, Jenkins home, proxy storage, monitoring
|
||||
volumes and earlier assignments. Never system-prune or use `down -v` here.
|
||||
|
||||
## Bootstrap recovery
|
||||
|
||||
The protected `/root/ssw590-delivery-bootstrap/` directory contains metadata,
|
||||
a consistent Jenkins-home archive and a Gitea SQLite backup taken before token
|
||||
creation. Metadata records token names, not values. Transient private inputs
|
||||
are erased after Jenkins encrypts them. If setup fails partway, inspect its
|
||||
marker/logs and existing state rather than rerunning or rotating credentials.
|
||||
Do not restore entire volumes/databases over later work without a reviewed plan.
|
||||
|
||||
## Agent placement and campus demonstration
|
||||
|
||||
The node name `ssw590-vince-delivery` is historical; it now runs on The-Ocean.
|
||||
Deployment SSH goes to `host.docker.internal` through the mounted SSH config,
|
||||
with the original public-IP host-key alias and strict verification. The Jenkins
|
||||
connection is private HTTP/WebSocket on `gitea_web`; public browser access
|
||||
continues through Caddy HTTPS and its existing allowlist. No campus SSH is
|
||||
needed for this delivery path. Rehearse campus browser access before presenting.
|
||||
The Gitea Actions PDF runner now also runs on The-Ocean. Its existing label
|
||||
`latex-local` is historical. Both laptop copies are stopped; run manual builds
|
||||
and delivery releases sequentially. See `../gitea/droplet-runner/README.md`.
|
||||
|
||||
To stop the remote agent from an authorized administrator shell:
|
||||
|
||||
```sh
|
||||
cd /opt/ssw590-delivery-agent
|
||||
docker compose -f compose.droplet.yaml stop
|
||||
docker stop buildx_buildkit_ssw590-delivery-limited0
|
||||
```
|
||||
|
||||
To reconnect, run `bash /opt/ssw590-delivery-agent/start-droplet-agent.sh`.
|
||||
It reuses protected identity and workspace volumes; do not rerun the original
|
||||
host/account bootstrap. Agent recreation reuses the node identity. The verified
|
||||
tool image was transferred from Docker Desktop and checked by archive SHA-256
|
||||
and image ID before loading. It can be rebuilt from `agent/Dockerfile` on a
|
||||
build-capable machine and transferred again if required.
|
||||
|
||||
For a laptop fallback, stop the remote copy first, load the administrator key
|
||||
into Windows ssh-agent, then run
|
||||
`./delivery/bootstrap/start-agent.ps1 -AllowLaptopFallback`.
|
||||
Stop the laptop copy before starting the remote one again.
|
||||
No new cloud instance or plan change was made; existing Droplet billing applies.
|
||||
VS maintains this agent and BY retains server administration ownership.
|
||||
@@ -0,0 +1,39 @@
|
||||
# Release security policy
|
||||
|
||||
Policy selected before the assessed scans on 14 November 2026.
|
||||
|
||||
- Block every detected repository secret. Use Trivy's built-in rules together
|
||||
with the course synthetic-fixture rule in `trivy-secret.yaml`.
|
||||
- Block HIGH and CRITICAL image vulnerabilities, including issues without a
|
||||
published fix. Retain the full report, including lower severities, for review.
|
||||
- Block every Python dependency advisory reported by pip-audit. Review direct
|
||||
and transitive dependencies and update the exact lock before rebuilding.
|
||||
- A scanner execution error, unavailable advisory service, unavailable
|
||||
vulnerability database, malformed report, or missing report fails the gate.
|
||||
- No exceptions are currently approved. An exception requires instructor
|
||||
acceptance, an advisory identifier, owner, rationale, compensating controls,
|
||||
and expiry recorded with the release. Findings must never be silently ignored.
|
||||
- For a suspected false positive, retain the report and record the evidence
|
||||
used for triage. Keep the release blocked until the finding is resolved or
|
||||
an instructor-approved exception is recorded.
|
||||
|
||||
Each release archives UTC scan times, tool versions, Trivy database metadata,
|
||||
commands, exit codes, reports, source commit, and the selected image digest.
|
||||
Rebuild and rescan after changing a dependency or base image.
|
||||
|
||||
The synthetic fixture is generated only for a deliberate blocked-gate run.
|
||||
Its label identifies course test data and has no credential authority. Remove
|
||||
the fixture and repeat the gate before a release can proceed.
|
||||
|
||||
The deployment agent now has administrative Docker access on The-Ocean,
|
||||
including the host running the controller, registry and monitoring, as well as
|
||||
deployment privileges. Co-location reduces isolation: the agent's container
|
||||
and resource caps do not prevent a malicious Docker-authorized job from
|
||||
accessing other containers or host files. This is a documented course-lab
|
||||
trade-off to avoid campus SSH restrictions, not a hardened production design.
|
||||
Run reviewed delivery code on
|
||||
this agent. Pull-request jobs must not receive its Docker socket or release
|
||||
credentials. The remote agent connects over private HTTP/WebSocket on the
|
||||
existing Docker network; browser access remains HTTPS through Caddy. Strict
|
||||
SSH verification retains the public-IP host-key alias while transport stays
|
||||
on Docker's host gateway. No firewall, TLS, approval or credential scope was relaxed.
|
||||
@@ -0,0 +1,25 @@
|
||||
FROM docker:29-cli@sha256:5a7af0dcb0e46c803efe9b45371dd21cb500e5b4453250394ac6f06d49b6e6f1 AS dockercli
|
||||
FROM aquasec/trivy:0.76.2@sha256:8f6bb947dbc528902e11f2f5be52f7b519f6a39d5d148f41166f2040499768fb AS scanner
|
||||
FROM jenkins/inbound-agent:jdk21@sha256:25a3704f7de4d3d0becc441f5683a227556658df1473865ee94c5232355678ab
|
||||
|
||||
USER root
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends python3 python3-venv git openssh-client ca-certificates curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=dockercli /usr/local/bin/docker /usr/local/bin/docker
|
||||
COPY --from=dockercli /usr/local/libexec/docker/cli-plugins/ /usr/local/libexec/docker/cli-plugins/
|
||||
COPY --from=scanner /usr/local/bin/trivy /usr/local/bin/trivy
|
||||
COPY agent/requirements.txt /tmp/requirements.txt
|
||||
RUN python3 -m venv /opt/delivery-tools \
|
||||
&& /opt/delivery-tools/bin/pip install --no-cache-dir -r /tmp/requirements.txt
|
||||
ENV PATH="/opt/delivery-tools/bin:${PATH}" \
|
||||
ANSIBLE_COLLECTIONS_PATH=/opt/ansible-collections \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
COPY ansible/requirements.yml /tmp/collections.yml
|
||||
RUN ansible-galaxy collection install -r /tmp/collections.yml -p /opt/ansible-collections \
|
||||
&& chmod -R a+rX /opt/ansible-collections \
|
||||
&& mkdir -p /opt/delivery-tools/inventory \
|
||||
&& dpkg-query -W > /opt/delivery-tools/inventory/debian-packages.txt \
|
||||
&& pip freeze > /opt/delivery-tools/inventory/python-packages.txt
|
||||
USER jenkins
|
||||
@@ -0,0 +1,54 @@
|
||||
name: ssw590-delivery
|
||||
services:
|
||||
agent:
|
||||
image: ssw590-delivery-agent:20261114
|
||||
restart: unless-stopped
|
||||
entrypoint: ["java", "-jar", "/usr/share/jenkins/agent.jar"]
|
||||
command:
|
||||
- -url
|
||||
- http://jenkins:8080/
|
||||
- -name
|
||||
- ssw590-vince-delivery
|
||||
- -secret
|
||||
- "@/run/delivery-identity/agent-secret"
|
||||
- -webSocket
|
||||
- -workDir
|
||||
- /home/jenkins/agent
|
||||
environment:
|
||||
JAVA_TOOL_OPTIONS: "-Xms32m -Xmx96m -XX:+UseSerialGC -XX:MaxMetaspaceSize=96m"
|
||||
GOMEMLIMIT: 192MiB
|
||||
TRIVY_PARALLEL: "1"
|
||||
BUILDX_CONFIG: /home/jenkins/agent/.buildx
|
||||
DELIVERY_BUILDER: ssw590-delivery-limited
|
||||
# Docker membership is host administration, including controller access.
|
||||
# Only reviewed delivery jobs may select this exclusive one-executor node.
|
||||
group_add: ["${DOCKER_GID:?set to the host Docker socket group}"]
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
networks: [web]
|
||||
volumes:
|
||||
- workspace:/home/jenkins/agent
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- identity:/run/delivery-identity:ro
|
||||
- ./ssh_config.droplet:/etc/ssh/ssh_config.d/90-delivery-target.conf:ro
|
||||
mem_limit: 512m
|
||||
memswap_limit: 768m
|
||||
cpus: 0.5
|
||||
pids_limit: 128
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
cap_drop: ["ALL"]
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 10m
|
||||
max-file: "3"
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
name: gitea_web
|
||||
volumes:
|
||||
identity:
|
||||
external: true
|
||||
name: ssw590-delivery-identity
|
||||
workspace:
|
||||
name: ssw590-delivery-workspace
|
||||
@@ -0,0 +1,33 @@
|
||||
name: ssw590-delivery
|
||||
services:
|
||||
agent:
|
||||
image: ssw590-delivery-agent:20261114
|
||||
restart: "no"
|
||||
entrypoint: ["java", "-jar", "/usr/share/jenkins/agent.jar"]
|
||||
command:
|
||||
- -url
|
||||
- https://ci.yebilly.me/
|
||||
- -name
|
||||
- ssw590-vince-delivery
|
||||
- -secret
|
||||
- "@/run/delivery-identity/agent-secret"
|
||||
- -webSocket
|
||||
- -workDir
|
||||
- /home/jenkins/agent
|
||||
# Docker's Linux VM socket is owned by group 0. Membership grants Docker
|
||||
# administration privileges. Use this node exclusively for trusted jobs.
|
||||
group_add: ["0"]
|
||||
volumes:
|
||||
- workspace:/home/jenkins/agent
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- identity:/run/delivery-identity:ro
|
||||
mem_limit: 2g
|
||||
cpus: 2
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
cap_drop: ["ALL"]
|
||||
volumes:
|
||||
identity:
|
||||
external: true
|
||||
name: ssw590-delivery-identity
|
||||
workspace:
|
||||
name: ssw590-delivery-workspace
|
||||
@@ -0,0 +1,2 @@
|
||||
ansible-core==2.21.6
|
||||
pip-audit==2.10.1
|
||||
@@ -0,0 +1,35 @@
|
||||
ansible-core==2.21.6
|
||||
boolean.py==5.0
|
||||
CacheControl==0.14.4
|
||||
certifi==2026.10.23
|
||||
cffi==2.1.1
|
||||
charset-normalizer==3.5.2
|
||||
cryptography==50.0.2
|
||||
cyclonedx-python-lib==11.12.0
|
||||
defusedxml==0.7.1
|
||||
filelock==4.2.10
|
||||
idna==3.20
|
||||
Jinja2==3.1.6
|
||||
license-expression==30.4.4
|
||||
markdown-it-py==4.3.0
|
||||
MarkupSafe==3.0.4
|
||||
mdurl==0.1.2
|
||||
msgpack==1.2.4
|
||||
packageurl-python==0.17.6
|
||||
packaging==26.3
|
||||
pip-requirements-parser==32.0.1
|
||||
pip_api==0.0.35
|
||||
pip_audit==2.10.1
|
||||
platformdirs==4.14.5
|
||||
py-serializable==2.2.0
|
||||
pycparser==3.12
|
||||
Pygments==2.21.0
|
||||
pyparsing==3.3.3
|
||||
PyYAML==6.0.3
|
||||
requests==2.34.2
|
||||
resolvelib==1.2.1
|
||||
rich==15.0.0
|
||||
sortedcontainers==2.4.0
|
||||
tomli==2.5.0
|
||||
tomli_w==1.2.0
|
||||
urllib3==2.8.0
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
python -m venv /tmp/tools
|
||||
/tmp/tools/bin/python -m pip install --disable-pip-version-check -r /workspace/delivery/agent/requirements.in
|
||||
/tmp/tools/bin/python -m pip freeze > /workspace/delivery/agent/requirements.txt
|
||||
/tmp/tools/bin/ansible-galaxy collection install -r /workspace/delivery/ansible/requirements.yml -p /tmp/collections
|
||||
/tmp/tools/bin/ansible-galaxy collection list -p /tmp/collections --format json > /tmp/collections.json
|
||||
/tmp/tools/bin/python - <<'PY'
|
||||
import json
|
||||
from pathlib import Path
|
||||
data = json.loads(Path('/tmp/collections.json').read_text())
|
||||
versions = {
|
||||
name: metadata['version']
|
||||
for collections in data.values()
|
||||
for name, metadata in collections.items()
|
||||
if name.startswith('community.')
|
||||
}
|
||||
assert 'community.docker' in versions, versions
|
||||
Path('/workspace/delivery/ansible/requirements.yml').write_text(
|
||||
'collections:\n' + ''.join(
|
||||
f' - name: {name}\n version: "{version}"\n'
|
||||
for name, version in sorted(versions.items())
|
||||
)
|
||||
)
|
||||
print(f'Pinned collections: {versions}')
|
||||
PY
|
||||
@@ -0,0 +1,6 @@
|
||||
# On The-Ocean only: keep the inventory and pinned public-key identity, but
|
||||
# send deployment SSH to this Docker host's gateway, never across campus Wi-Fi.
|
||||
Host 147.182.178.136
|
||||
HostName host.docker.internal
|
||||
HostKeyAlias 147.182.178.136
|
||||
ConnectTimeout 10
|
||||
@@ -0,0 +1,74 @@
|
||||
- name: Deploy a selected immutable pricing release
|
||||
hosts: delivery
|
||||
become: true
|
||||
vars:
|
||||
project_dir: "/opt/startup/pricing-{{ target_env }}"
|
||||
tasks:
|
||||
- name: Validate release selection
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- target_env in ['staging', 'production']
|
||||
- "'@sha256:' in release_image"
|
||||
- expected_version in ['v1', 'v2']
|
||||
- expected_total | int > 0
|
||||
- public_url.startswith('https://')
|
||||
- proxy_network | length > 0
|
||||
- expected_commit is match('^[0-9a-f]{40}$')
|
||||
- configuration_commit is match('^[0-9a-f]{40}$')
|
||||
- release_image is match('^git[.]yebilly[.]me/ssw590-group1/pricing@sha256:[0-9a-f]{64}$')
|
||||
- proxy_network == 'gitea_web'
|
||||
- public_url == ('https://staging.yebilly.me' if target_env == 'staging' else 'https://app.yebilly.me')
|
||||
- expected_total | int == (30 if expected_version == 'v1' else 36)
|
||||
- name: Create deployment directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ project_dir }}"
|
||||
state: directory
|
||||
mode: '0750'
|
||||
- name: Render selected Compose configuration
|
||||
ansible.builtin.template:
|
||||
src: compose.yaml.j2
|
||||
dest: "{{ project_dir }}/compose.yaml"
|
||||
mode: '0640'
|
||||
- name: Converge application without rebuilding
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ project_dir }}"
|
||||
project_name: "pricing-{{ target_env }}"
|
||||
state: present
|
||||
build: never
|
||||
pull: missing
|
||||
wait: true
|
||||
wait_timeout: 90
|
||||
- name: Verify health through public TLS endpoint
|
||||
ansible.builtin.uri:
|
||||
url: "{{ public_url }}/health"
|
||||
return_content: true
|
||||
validate_certs: true
|
||||
register: health
|
||||
until: health.status == 200 and health.json.status == 'ok'
|
||||
retries: 12
|
||||
delay: 5
|
||||
changed_when: false
|
||||
- name: Read release identity
|
||||
ansible.builtin.uri:
|
||||
url: "{{ public_url }}/"
|
||||
return_content: true
|
||||
register: identity
|
||||
changed_when: false
|
||||
- name: Exercise business behavior
|
||||
ansible.builtin.uri:
|
||||
url: "{{ public_url }}/price?quantity=3"
|
||||
return_content: true
|
||||
register: price
|
||||
changed_when: false
|
||||
- name: Check release identity and calculation
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- identity.json.version == expected_version
|
||||
- health.json.version == expected_version
|
||||
- identity.json.commit == expected_commit
|
||||
- price.json.total | int == expected_total | int
|
||||
- name: Preserve the selected non-secret release metadata
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ project_dir }}/release.json"
|
||||
mode: '0640'
|
||||
content: "{{ {'release_image': release_image, 'source_commit': expected_commit, 'configuration_commit': configuration_commit, 'version': expected_version, 'expected_total': expected_total, 'public_url': public_url} | to_nice_json }}\n"
|
||||
@@ -0,0 +1,3 @@
|
||||
[delivery]
|
||||
# The SSH host key must be verified and supplied by the trusted delivery job.
|
||||
startup ansible_host=147.182.178.136 ansible_user=deploy ansible_python_interpreter=/usr/bin/python3
|
||||
@@ -0,0 +1,9 @@
|
||||
# Copy to a release-specific file and replace EVERY placeholder.
|
||||
target_env: staging
|
||||
release_image: git.yebilly.me/ssw590-group1/pricing@sha256:REPLACE_DIGEST
|
||||
expected_version: v1
|
||||
expected_commit: REPLACE_FULL_GIT_COMMIT
|
||||
configuration_commit: REPLACE_FULL_REVIEWED_CONFIGURATION_COMMIT
|
||||
expected_total: 30
|
||||
public_url: https://staging.yebilly.me
|
||||
proxy_network: gitea_web
|
||||
@@ -0,0 +1,5 @@
|
||||
collections:
|
||||
- name: community.docker
|
||||
version: "5.4.0"
|
||||
- name: community.library_inventory_filtering_v1
|
||||
version: "1.1.5"
|
||||
@@ -0,0 +1,23 @@
|
||||
services:
|
||||
app:
|
||||
image: "{{ release_image }}"
|
||||
restart: unless-stopped
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp:size=16m,mode=1777
|
||||
cap_drop:
|
||||
- ALL
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 64m
|
||||
memswap_limit: 96m
|
||||
cpus: 0.25
|
||||
pids_limit: 64
|
||||
networks:
|
||||
edge:
|
||||
aliases:
|
||||
- "pricing-{{ target_env }}"
|
||||
networks:
|
||||
edge:
|
||||
external: true
|
||||
name: "{{ proxy_network }}"
|
||||
@@ -0,0 +1,4 @@
|
||||
__pycache__
|
||||
.venv
|
||||
.git
|
||||
*.pyc
|
||||
@@ -0,0 +1,13 @@
|
||||
FROM python:3.13-alpine@sha256:9ef1a599f863231c3d91e941389bfdc4a2d6070557243d54df1a4e57015b960e
|
||||
ARG APP_COMMIT=development
|
||||
ENV APP_COMMIT=$APP_COMMIT PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||
WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt \
|
||||
&& python -m pip uninstall -y pip \
|
||||
&& rm -rf /usr/local/lib/python3.13/ensurepip
|
||||
COPY app.py .
|
||||
USER 10001:10001
|
||||
EXPOSE 8000
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--worker-tmp-dir", "/tmp", "app:app"]
|
||||
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
from flask import Flask, jsonify, request
|
||||
|
||||
app = Flask(__name__)
|
||||
VERSION = "v1"
|
||||
UNIT_PRICE = 10
|
||||
COMMIT = os.environ.get("APP_COMMIT", "development")
|
||||
|
||||
|
||||
def total_price(quantity):
|
||||
if quantity < 1 or quantity > 1000:
|
||||
raise ValueError("quantity must be between 1 and 1000")
|
||||
return UNIT_PRICE * quantity
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def index():
|
||||
return jsonify(service="Startup Pricing", version=VERSION, commit=COMMIT)
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return jsonify(status="ok", version=VERSION)
|
||||
|
||||
|
||||
@app.get("/price")
|
||||
def price():
|
||||
try:
|
||||
quantity = int(request.args.get("quantity", "1"))
|
||||
total = total_price(quantity)
|
||||
except ValueError as error:
|
||||
return jsonify(error=str(error)), 400
|
||||
return jsonify(quantity=quantity, total=total, currency="USD")
|
||||
@@ -0,0 +1,3 @@
|
||||
# Instructor compatibility ranges. requirements.txt locks the assessed versions.
|
||||
Flask>=3.1,<3.2
|
||||
gunicorn>=23,<24
|
||||
@@ -0,0 +1,9 @@
|
||||
blinker==1.9.0
|
||||
click==8.5.1
|
||||
Flask==3.1.3
|
||||
gunicorn==23.0.0
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.6
|
||||
MarkupSafe==3.0.4
|
||||
packaging==26.3
|
||||
Werkzeug==3.1.9
|
||||
@@ -0,0 +1,25 @@
|
||||
import unittest
|
||||
from app import app, total_price
|
||||
|
||||
|
||||
class PricingTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.client = app.test_client()
|
||||
|
||||
def test_price(self):
|
||||
self.assertEqual(total_price(3), 30)
|
||||
response = self.client.get("/price?quantity=3")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json["total"], 30)
|
||||
|
||||
def test_invalid_quantity(self):
|
||||
for value in ["0", "-1", "1001", "abc", "1.5"]:
|
||||
self.assertEqual(self.client.get("/price?quantity=" + value).status_code, 400)
|
||||
|
||||
def test_release_identity(self):
|
||||
self.assertEqual(self.client.get("/").json["version"], "v1")
|
||||
self.assertEqual(self.client.get("/health").json["status"], "ok")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# Run inside the idle trusted agent from a non-secret preparation snapshot.
|
||||
# This is a capacity/tool trial, never a reviewed release or registry push.
|
||||
set -eu
|
||||
export TRIVY_CACHE_DIR=/home/jenkins/agent/.cache/trivy
|
||||
mkdir -p build/delivery/reports
|
||||
date -u
|
||||
python3 -B -m unittest discover -s delivery/ci -p 'test_controls.py' -v
|
||||
sh delivery/ci/test-app.sh
|
||||
python3 delivery/ci/security.py source
|
||||
: "${DELIVERY_BUILDER:?use the limited remote builder}"
|
||||
docker buildx build --builder "$DELIVERY_BUILDER" --load --platform linux/amd64 \
|
||||
--build-arg APP_COMMIT=uncommitted-remote-preflight \
|
||||
-t ssw590-pricing:remote-preflight-v1 delivery/app
|
||||
python3 delivery/ci/security.py image --image ssw590-pricing:remote-preflight-v1
|
||||
name=ssw590-delivery-capacity-smoke
|
||||
cleanup() { docker rm -f "$name" >/dev/null 2>&1 || true; }
|
||||
# Refuse to replace any existing container, even one from an interrupted trial.
|
||||
if docker container inspect "$name" >/dev/null 2>&1; then
|
||||
echo 'Inspect the existing trial container before retrying' >&2
|
||||
exit 1
|
||||
fi
|
||||
trap cleanup EXIT
|
||||
docker run -d --name "$name" --network gitea_web --read-only \
|
||||
--tmpfs /tmp:rw,nosuid,noexec,size=16m --memory 64m --memory-swap 96m \
|
||||
--cpus .25 --pids-limit 64 --cap-drop ALL --security-opt no-new-privileges \
|
||||
ssw590-pricing:remote-preflight-v1
|
||||
python3 - <<'PY'
|
||||
import json, time, urllib.request, urllib.error
|
||||
url = 'http://ssw590-delivery-capacity-smoke:8000'
|
||||
for attempt in range(30):
|
||||
try:
|
||||
with urllib.request.urlopen(url + '/health', timeout=2) as response:
|
||||
health = json.load(response)
|
||||
break
|
||||
except (OSError, ValueError):
|
||||
time.sleep(1)
|
||||
else:
|
||||
raise RuntimeError('Application failed to start')
|
||||
def get(path):
|
||||
with urllib.request.urlopen(url + path, timeout=5) as response:
|
||||
return json.load(response)
|
||||
identity, price = get('/'), get('/price?quantity=3')
|
||||
assert health['status'] == 'ok' and health['version'] == 'v1', health
|
||||
assert identity['commit'] == 'uncommitted-remote-preflight', identity
|
||||
assert price['total'] == 30, price
|
||||
try:
|
||||
get('/price?quantity=-1')
|
||||
raise AssertionError('Invalid quantity accepted')
|
||||
except urllib.error.HTTPError as error:
|
||||
assert error.code == 400, error.code
|
||||
print(json.dumps({'health': health, 'identity': identity, 'price': price,
|
||||
'invalid_quantity_status': 400}, indent=2))
|
||||
PY
|
||||
docker inspect "$name" --format 'smoke OOMKilled={{.State.OOMKilled}} memory={{.HostConfig.Memory}}'
|
||||
date -u
|
||||
echo 'PASS: remote capacity preparation; no image published or assessed environment deployed'
|
||||
@@ -0,0 +1,79 @@
|
||||
// One-time bootstrap loaded from Jenkins home after an authorized host setup.
|
||||
// Never print secret values. Scope release credentials to the delivery folder.
|
||||
import jenkins.model.Jenkins
|
||||
import hudson.model.Node
|
||||
import hudson.slaves.DumbSlave
|
||||
import hudson.slaves.JNLPLauncher
|
||||
import hudson.slaves.RetentionStrategy
|
||||
import com.cloudbees.hudson.plugins.folder.Folder
|
||||
import com.cloudbees.plugins.credentials.CredentialsProvider
|
||||
import com.cloudbees.plugins.credentials.CredentialsScope
|
||||
import com.cloudbees.plugins.credentials.SecretBytes
|
||||
import com.cloudbees.plugins.credentials.domains.Domain
|
||||
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl
|
||||
import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey
|
||||
import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl
|
||||
import org.jenkinsci.plugins.workflow.job.WorkflowJob
|
||||
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition
|
||||
import hudson.plugins.git.GitSCM
|
||||
import hudson.plugins.git.UserRemoteConfig
|
||||
import hudson.plugins.git.BranchSpec
|
||||
import groovy.json.JsonOutput
|
||||
|
||||
def j = Jenkins.get()
|
||||
def inputs = new File(j.rootDir, 'delivery-bootstrap')
|
||||
def done = new File(inputs, 'configured.json')
|
||||
if (done.exists()) return
|
||||
assert j.getItem('secure-delivery') == null : 'Existing folder requires review'
|
||||
assert j.getNode('ssw590-vince-delivery') == null : 'Existing node requires review'
|
||||
def folder = j.createProject(Folder, 'secure-delivery')
|
||||
folder.description = 'Assignment 8: reviewed releases only; folder-scoped deployment credentials.'
|
||||
folder.save()
|
||||
def store = CredentialsProvider.lookupStores(folder).find { it.context == folder }
|
||||
assert store != null : 'Folder credential store unavailable'
|
||||
def scope = CredentialsScope.GLOBAL
|
||||
def credential = new UsernamePasswordCredentialsImpl(scope, 'delivery-registry-write',
|
||||
'Assignment 8 package-write only; vsun1; revoke after grading', 'vsun1',
|
||||
new File(inputs, 'registry-write').text.trim())
|
||||
assert store.addCredentials(Domain.global(), credential)
|
||||
def key = new BasicSSHUserPrivateKey(scope, 'delivery-deploy-ssh', 'deploy',
|
||||
new BasicSSHUserPrivateKey.DirectEntryPrivateKeySource(new File(inputs, 'deploy_ed25519').text),
|
||||
'', 'Assignment 8 deploy account; root sudo; reviewed releases only')
|
||||
assert store.addCredentials(Domain.global(), key)
|
||||
def knownHosts = new FileCredentialsImpl(scope, 'delivery-known-hosts',
|
||||
'The-Ocean ED25519 host key verified through existing pinned administrator SSH',
|
||||
'known_hosts', SecretBytes.fromBytes(new File(inputs, 'known_hosts').bytes))
|
||||
assert store.addCredentials(Domain.global(), knownHosts)
|
||||
def launcher = new JNLPLauncher()
|
||||
launcher.setWebSocket(true)
|
||||
def node = new DumbSlave('ssw590-vince-delivery', 'Trusted The-Ocean Docker/Ansible delivery agent (legacy node name)',
|
||||
'/home/jenkins/agent', '1', Node.Mode.EXCLUSIVE, 'delivery-trusted', launcher,
|
||||
new RetentionStrategy.Always(), [])
|
||||
j.addNode(node)
|
||||
def secret = new File(inputs, 'agent-secret')
|
||||
secret.text = node.toComputer().getJnlpMac() + '\n'
|
||||
secret.setReadable(false, false)
|
||||
secret.setWritable(false, false)
|
||||
secret.setReadable(true, true)
|
||||
secret.setWritable(true, true)
|
||||
def job = folder.createProject(WorkflowJob, 'pricing')
|
||||
def scm = new GitSCM(
|
||||
[new UserRemoteConfig('https://git.yebilly.me/ssw590-group1/vpn-dns-gateway.git', null, null, 'gitea-jenkins-bot')],
|
||||
[new BranchSpec('*/main')], false, [], null, null, [])
|
||||
def definition = new CpsScmFlowDefinition(scm, 'delivery/Jenkinsfile')
|
||||
definition.lightweight = true
|
||||
job.definition = definition
|
||||
job.description = 'Reviewed protected-main code only. Enable after the Assignment 8 source is reviewed and merged.'
|
||||
job.disabled = true
|
||||
job.save()
|
||||
done.text = JsonOutput.prettyPrint(JsonOutput.toJson([
|
||||
configured_at: new Date().format("yyyy-MM-dd'T'HH:mm:ssXXX", TimeZone.getTimeZone('UTC')),
|
||||
node: node.nodeName, label: 'delivery-trusted', executors: 1, exclusive: true,
|
||||
job: job.fullName, disabled: true, credential_scope: folder.fullName,
|
||||
credential_ids: ['delivery-registry-write', 'delivery-deploy-ssh', 'delivery-known-hosts']
|
||||
])) + '\n'
|
||||
['registry-write', 'deploy_ed25519', 'known_hosts'].each { name ->
|
||||
assert new File(inputs, name).delete() : "Could not remove transient bootstrap input ${name}"
|
||||
}
|
||||
assert new File(j.rootDir, 'init.groovy.d/ssw590-delivery.groovy').delete()
|
||||
println('Assignment 8 delivery configuration complete; secret values were not printed; job is disabled.')
|
||||
@@ -0,0 +1,72 @@
|
||||
"""Apply only the prepared Assignment 8 proxy additions, preserving the bind inode."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--candidate', required=True, type=Path)
|
||||
parser.add_argument('--backup', required=True, type=Path)
|
||||
parser.add_argument('--apply', action='store_true')
|
||||
args = parser.parse_args()
|
||||
live = Path('/root/gitea/Caddyfile')
|
||||
marker = '# Assignment 8: apply after both DNS names resolve to The-Ocean.'
|
||||
candidate = args.candidate.read_text()
|
||||
before = live.read_bytes()
|
||||
prefix, additions = candidate.split(marker, 1)
|
||||
expected = '''# Assignment 8: apply after both DNS names resolve to The-Ocean. Containers
|
||||
# publish no host ports; the existing proxy reaches their private aliases.
|
||||
staging.yebilly.me {
|
||||
\treverse_proxy pricing-staging:8000
|
||||
}
|
||||
|
||||
app.yebilly.me {
|
||||
\treverse_proxy pricing-production:8000
|
||||
}'''
|
||||
assert (marker + additions).strip() == expected, 'Unexpected proxy additions'
|
||||
assert prefix.strip() == before.decode().replace('\r\n', '\n').strip(), 'Live earlier routes differ; inspect instead of overwriting'
|
||||
for host in ('staging.yebilly.me', 'app.yebilly.me'):
|
||||
addresses = {item[4][0] for item in socket.getaddrinfo(host, 443, socket.AF_INET)}
|
||||
assert addresses == {'147.182.178.136'}, (host, addresses)
|
||||
temp = '/tmp/ssw590-assignment8-https.Caddyfile'
|
||||
subprocess.run(['docker', 'cp', str(args.candidate), 'gitea-caddy-1:' + temp], check=True)
|
||||
try:
|
||||
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'caddy', 'validate', '--config', temp, '--adapter', 'caddyfile'], check=True)
|
||||
if not args.apply:
|
||||
print('Candidate validated; no active configuration changed.')
|
||||
raise SystemExit(0)
|
||||
args.backup.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
backup = args.backup / 'Caddyfile.before'
|
||||
assert not backup.exists(), 'Existing backup: inspect state before retrying'
|
||||
shutil.copy2(live, backup)
|
||||
prior_stat = live.stat()
|
||||
try:
|
||||
with live.open('wb') as stream:
|
||||
stream.write(candidate.encode())
|
||||
stream.flush()
|
||||
os.fsync(stream.fileno())
|
||||
assert live.stat().st_ino == prior_stat.st_ino, 'Bind-mounted inode changed'
|
||||
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'caddy', 'reload', '--config', '/etc/caddy/Caddyfile', '--adapter', 'caddyfile'], check=True)
|
||||
except Exception:
|
||||
with live.open('wb') as stream:
|
||||
stream.write(before)
|
||||
stream.flush()
|
||||
os.fsync(stream.fileno())
|
||||
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'caddy', 'reload', '--config', '/etc/caddy/Caddyfile', '--adapter', 'caddyfile'], check=True)
|
||||
raise
|
||||
report = {'applied_at': datetime.now(timezone.utc).isoformat(),
|
||||
'before_sha256': hashlib.sha256(before).hexdigest(),
|
||||
'after_sha256': hashlib.sha256(live.read_bytes()).hexdigest(),
|
||||
'inode_preserved': live.stat().st_ino == prior_stat.st_ino,
|
||||
'prior_routes_preserved': True, 'applications_deployed': False,
|
||||
'new_hosts': ['staging.yebilly.me', 'app.yebilly.me'],
|
||||
'backup': str(backup), 'result': 'reloaded; certificate verification pending'}
|
||||
(args.backup / 'applied.json').write_text(json.dumps(report, indent=2))
|
||||
print(json.dumps(report, indent=2))
|
||||
finally:
|
||||
subprocess.run(['docker', 'exec', 'gitea-caddy-1', 'rm', '-f', temp], check=True)
|
||||
@@ -0,0 +1,34 @@
|
||||
// Administrator preparation only: no checkout, image publication or deployment.
|
||||
pipeline {
|
||||
agent { label 'delivery-trusted' }
|
||||
options { disableConcurrentBuilds(); timeout(time: 5, unit: 'MINUTES') }
|
||||
stages {
|
||||
stage('Tool and target prerequisites') {
|
||||
steps {
|
||||
withCredentials([
|
||||
sshUserPrivateKey(credentialsId: 'delivery-deploy-ssh', keyFileVariable: 'DEPLOY_KEY'),
|
||||
file(credentialsId: 'delivery-known-hosts', variable: 'DEPLOY_KNOWN_HOSTS')
|
||||
]) {
|
||||
sh '''set -eu
|
||||
set +x
|
||||
mkdir -p build/preflight
|
||||
{
|
||||
date -u
|
||||
id
|
||||
python3 --version
|
||||
ansible --version
|
||||
ansible-galaxy collection list
|
||||
docker --version
|
||||
docker compose version
|
||||
trivy --version
|
||||
pip-audit --version
|
||||
ssh -i "$DEPLOY_KEY" -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o "UserKnownHostsFile=$DEPLOY_KNOWN_HOSTS" deploy@147.182.178.136 'id; sudo -n true; python3 --version; sudo -n docker --version; sudo -n docker compose version; free -m; nproc; df -h /'
|
||||
} > build/preflight/tools-and-target.txt
|
||||
cat build/preflight/tools-and-target.txt
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post { always { archiveArtifacts(artifacts: 'build/preflight/**', allowEmptyArchive: true) } }
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
"""One-time administrator bootstrap; run only on the authorized droplet.
|
||||
|
||||
Secrets stay in protected host/Jenkins storage and are never printed. This
|
||||
does not deploy an application, enable the release job, commit, or push.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sqlite3
|
||||
import subprocess
|
||||
from datetime import datetime, timezone
|
||||
|
||||
HOME = Path('/var/lib/docker/volumes/gitea_jenkins-home/_data')
|
||||
STATE = Path('/root/ssw590-delivery-bootstrap')
|
||||
SCRIPTS = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
def run(args, **kwargs):
|
||||
return subprocess.run(args, check=True, **kwargs)
|
||||
|
||||
|
||||
def private_file(path, content, owner=None):
|
||||
path.write_text(content)
|
||||
path.chmod(0o600)
|
||||
if owner is not None:
|
||||
os.chown(path, owner, owner)
|
||||
|
||||
|
||||
def registry_token(name, scope):
|
||||
result = subprocess.run([
|
||||
'docker', 'exec', '-u', 'git', 'gitea-gitea-1', 'gitea',
|
||||
'--config', '/data/gitea/conf/app.ini', 'admin', 'user',
|
||||
'generate-access-token', '--username', 'vsun1', '--token-name', name,
|
||||
'--scopes', scope, '--raw',
|
||||
], text=True, capture_output=True)
|
||||
value = result.stdout.strip()
|
||||
if result.returncode or len(value) != 40 or not all(c in '0123456789abcdef' for c in value):
|
||||
raise RuntimeError('Token creation did not return the expected format; no secret output emitted')
|
||||
return value
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--apply', action='store_true')
|
||||
args = parser.parse_args()
|
||||
if not args.apply:
|
||||
print('Plan: back up Jenkins/Gitea; create deploy SSH/sudo access; create package-only tokens;')
|
||||
print('configure folder-scoped Jenkins credentials, an exclusive agent and a DISABLED release job; restart Jenkins.')
|
||||
return
|
||||
if os.geteuid() != 0 or not HOME.is_dir():
|
||||
raise RuntimeError('Run as root on the existing The-Ocean droplet')
|
||||
if STATE.exists() or (HOME / 'delivery-bootstrap').exists():
|
||||
raise RuntimeError('Bootstrap state already exists: inspect it rather than rotating or overwriting access')
|
||||
if subprocess.run(['id', 'deploy'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0:
|
||||
raise RuntimeError('An existing deploy account requires review before modification')
|
||||
run(['docker', 'exec', 'gitea-jenkins-1', 'test', '-e', '/var/jenkins_home/plugins/cloudbees-folder.jpi'])
|
||||
STATE.mkdir(mode=0o700)
|
||||
stamp = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')
|
||||
backup = STATE / ('backup-' + stamp)
|
||||
backup.mkdir(mode=0o700)
|
||||
database = Path('/var/lib/docker/volumes/gitea_gitea-data/_data/gitea/gitea.db')
|
||||
with sqlite3.connect(f'file:{database}?mode=ro', uri=True) as source:
|
||||
with sqlite3.connect(backup / 'gitea.db') as target:
|
||||
source.backup(target)
|
||||
(backup / 'gitea.db').chmod(0o600)
|
||||
run(['docker', 'stop', 'gitea-jenkins-1'], stdout=subprocess.DEVNULL)
|
||||
try:
|
||||
run(['tar', '-czf', str(backup / 'jenkins-home.tgz'), '-C', str(HOME), '.'])
|
||||
finally:
|
||||
run(['docker', 'start', 'gitea-jenkins-1'], stdout=subprocess.DEVNULL)
|
||||
(backup / 'jenkins-home.tgz').chmod(0o600)
|
||||
if Path('/root/.docker/config.json').exists():
|
||||
shutil.copy2('/root/.docker/config.json', backup / 'docker-config.json')
|
||||
(backup / 'docker-config.json').chmod(0o600)
|
||||
key = STATE / 'deploy_ed25519'
|
||||
run(['ssh-keygen', '-q', '-t', 'ed25519', '-N', '', '-C', 'ssw590-jenkins-delivery', '-f', str(key)])
|
||||
run(['useradd', '--create-home', '--shell', '/bin/bash', '--comment', 'SSW590 trusted Ansible deployment', 'deploy'])
|
||||
sshdir = Path('/home/deploy/.ssh')
|
||||
sshdir.mkdir(mode=0o700)
|
||||
run(['chown', 'deploy:deploy', str(sshdir)])
|
||||
public_key = key.with_suffix('.pub').read_text().strip()
|
||||
private_file(sshdir / 'authorized_keys', 'restrict ' + public_key + '\n')
|
||||
run(['chown', 'deploy:deploy', str(sshdir / 'authorized_keys')])
|
||||
sudoers = Path('/etc/sudoers.d/ssw590-delivery')
|
||||
private_file(sudoers, '# Trusted Ansible release account: effective host administrator.\ndeploy ALL=(root) NOPASSWD: ALL\n')
|
||||
sudoers.chmod(0o440)
|
||||
run(['visudo', '-cf', str(sudoers)])
|
||||
write_token = registry_token('ssw590-delivery-agent-' + stamp, 'write:package')
|
||||
read_token = registry_token('ssw590-delivery-target-' + stamp, 'read:package')
|
||||
result = subprocess.run([
|
||||
'docker', 'login', '--username', 'vsun1', '--password-stdin', 'git.yebilly.me'
|
||||
], input=read_token + '\n', text=True, capture_output=True)
|
||||
if result.returncode:
|
||||
raise RuntimeError('Target registry login failed; no secret output emitted')
|
||||
inputs = HOME / 'delivery-bootstrap'
|
||||
inputs.mkdir(mode=0o700)
|
||||
os.chown(inputs, 1000, 1000)
|
||||
private_file(inputs / 'deploy_ed25519', key.read_text(), 1000)
|
||||
private_file(inputs / 'registry-write', write_token, 1000)
|
||||
public_host_key = Path('/etc/ssh/ssh_host_ed25519_key.pub').read_text().split()
|
||||
private_file(inputs / 'known_hosts', '147.182.178.136 ' + ' '.join(public_host_key[:2]) + '\n', 1000)
|
||||
init = HOME / 'init.groovy.d'
|
||||
init.mkdir(exist_ok=True)
|
||||
os.chown(init, 1000, 1000)
|
||||
script = init / 'ssw590-delivery.groovy'
|
||||
shutil.copyfile(SCRIPTS / 'configure_jenkins.groovy', script)
|
||||
script.chmod(0o600)
|
||||
os.chown(script, 1000, 1000)
|
||||
private_file(STATE / 'metadata.json', json.dumps({
|
||||
'started': stamp, 'registry_user': 'vsun1',
|
||||
'agent_token_name': 'ssw590-delivery-agent-' + stamp,
|
||||
'target_token_name': 'ssw590-delivery-target-' + stamp,
|
||||
'agent_scope': 'write:package', 'target_scope': 'read:package',
|
||||
'backup_directory': str(backup),
|
||||
'deploy_sudo_scope': 'root commands without a password; trusted code only',
|
||||
}, indent=2))
|
||||
run(['docker', 'restart', 'gitea-jenkins-1'], stdout=subprocess.DEVNULL)
|
||||
# The private key is now the Jenkins bootstrap input; remove the duplicate.
|
||||
key.unlink()
|
||||
key.with_suffix('.pub').unlink()
|
||||
print('Host bootstrap applied. Jenkins is restarting; verify its completion marker before starting the agent.')
|
||||
print('Existing Gitea, proxy and monitoring configuration was preserved. Release job remains disabled.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,28 @@
|
||||
param(
|
||||
[switch]$AllowLaptopFallback,
|
||||
[string]$Droplet = '147.182.178.136',
|
||||
[string]$IdentityFile = (Join-Path $env:USERPROFILE '.ssh/digitalocean')
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$PSNativeCommandUseErrorActionPreference = $true
|
||||
if (-not $AllowLaptopFallback) {
|
||||
throw 'The delivery node now runs on The-Ocean. Start a laptop fallback only after stopping the remote copy, then pass -AllowLaptopFallback. Never connect both copies of the same node.'
|
||||
}
|
||||
$repoPath = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
|
||||
$sshArguments = @('-i', $IdentityFile, '-o', 'IdentitiesOnly=yes', '-o', 'BatchMode=yes',
|
||||
'-o', 'StrictHostKeyChecking=yes', '-o', 'ConnectTimeout=10', "root@$Droplet")
|
||||
& ssh @sshArguments 'docker exec -u jenkins gitea-jenkins-1 test -f /var/jenkins_home/delivery-bootstrap/configured.json'
|
||||
& docker volume create ssw590-delivery-identity | Out-Null
|
||||
# The generated identity flows directly from pinned administrator SSH into a
|
||||
# protected Docker volume. No secret enters command arguments, output or Git.
|
||||
& ssh @sshArguments 'docker exec -u jenkins gitea-jenkins-1 cat /var/jenkins_home/delivery-bootstrap/agent-secret' |
|
||||
& docker run --rm -i --network none --user 0:0 --entrypoint sh `
|
||||
--mount 'type=volume,source=ssw590-delivery-identity,target=/identity' `
|
||||
ssw590-delivery-agent:20261114 -c 'set -eu; umask 077; cat > /identity/agent-secret; test -s /identity/agent-secret; chown 1000:1000 /identity /identity/agent-secret; chmod 700 /identity; chmod 400 /identity/agent-secret'
|
||||
Push-Location $repoPath
|
||||
try {
|
||||
& docker compose -f delivery/agent/compose.yaml up -d
|
||||
& docker compose -f delivery/agent/compose.yaml ps
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Run as root from /opt/ssw590-delivery-agent after stopping the laptop copy.
|
||||
# Copy compose.droplet.yaml and ssh_config.droplet here first; load the verified
|
||||
# agent image. Never copy any identity file into this directory or into Git.
|
||||
set -euo pipefail
|
||||
test "$(id -u)" = 0
|
||||
cd /opt/ssw590-delivery-agent
|
||||
export DOCKER_GID
|
||||
DOCKER_GID=$(stat -c '%g' /var/run/docker.sock)
|
||||
# Numeric group only, not a credential. Keep it available for later Compose use.
|
||||
printf 'DOCKER_GID=%s\n' "$DOCKER_GID" > .env
|
||||
chmod 644 .env
|
||||
docker image inspect ssw590-delivery-agent:20261114 >/dev/null
|
||||
docker compose -f compose.droplet.yaml config --quiet
|
||||
docker exec -u jenkins gitea-jenkins-1 test -s /var/jenkins_home/delivery-bootstrap/agent-secret
|
||||
docker volume create ssw590-delivery-identity >/dev/null
|
||||
docker exec -u jenkins gitea-jenkins-1 cat /var/jenkins_home/delivery-bootstrap/agent-secret |
|
||||
docker run --rm -i --network none --user 0:0 --entrypoint sh \
|
||||
--mount type=volume,source=ssw590-delivery-identity,target=/identity \
|
||||
ssw590-delivery-agent:20261114 -c \
|
||||
'set -eu; umask 077; cat > /identity/agent-secret; test -s /identity/agent-secret; chown 1000:1000 /identity /identity/agent-secret; chmod 700 /identity; chmod 400 /identity/agent-secret'
|
||||
docker compose -f compose.droplet.yaml up -d --pull never
|
||||
agent=ssw590-delivery-agent-1
|
||||
# BuildKit's own container must be limited too: the socket mount does not make
|
||||
# child build containers inherit the agent's resource caps.
|
||||
if ! docker exec "$agent" docker buildx inspect ssw590-delivery-limited >/dev/null 2>&1; then
|
||||
docker exec "$agent" docker buildx create --name ssw590-delivery-limited \
|
||||
--driver docker-container \
|
||||
--driver-opt image=moby/buildkit@sha256:c5f8862f52499773af85bc07695b2379ef08e8002352b0df2c4864c91d78dabe,memory=256m,memory-swap=384m,cpu-period=100000,cpu-quota=50000,restart-policy=unless-stopped
|
||||
fi
|
||||
docker exec "$agent" docker buildx inspect ssw590-delivery-limited --bootstrap
|
||||
docker compose -f compose.droplet.yaml ps
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Read-only, non-secret runtime checks; run as root on The-Ocean."""
|
||||
import json
|
||||
import subprocess
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def run(*args):
|
||||
return subprocess.check_output(args, text=True).strip()
|
||||
|
||||
|
||||
report = {"observed_at": datetime.now(timezone.utc).isoformat(), "containers": []}
|
||||
names = ["ssw590-delivery-agent-1", "buildx_buildkit_ssw590-delivery-limited0"]
|
||||
for name in names:
|
||||
info = json.loads(run("docker", "inspect", name))[0]
|
||||
config, state = info["HostConfig"], info["State"]
|
||||
events = Path("/sys/fs/cgroup/system.slice", "docker-" + info["Id"] + ".scope", "memory.events")
|
||||
report["containers"].append({
|
||||
"name": name, "running": state["Running"], "oom_killed": state["OOMKilled"],
|
||||
"restart_count": info["RestartCount"], "restart_policy": config["RestartPolicy"]["Name"],
|
||||
"memory_bytes": config["Memory"], "memory_swap_bytes": config["MemorySwap"],
|
||||
"nano_cpus": config["NanoCpus"], "cpu_quota": config["CpuQuota"],
|
||||
"cpu_period": config["CpuPeriod"], "port_bindings": config["PortBindings"],
|
||||
"memory_events": events.read_text().strip() if events.exists() else "unavailable",
|
||||
})
|
||||
assert state["Running"] and not state["OOMKilled"], name
|
||||
report["private_http"] = {}
|
||||
for url in ["http://jenkins:8080/login", "http://gitea:3000/", "http://monitoring-grafana-1:3000/login"]:
|
||||
code = run("docker", "exec", names[0], "curl", "--silent", "--show-error", "--max-time", "15",
|
||||
"-o", "/dev/null", "-w", "%{http_code}", url)
|
||||
report["private_http"][url] = code
|
||||
assert code == "200", (url, code)
|
||||
ssh = run("docker", "exec", names[0], "ssh", "-G", "147.182.178.136")
|
||||
report["deployment_ssh_route"] = [line for line in ssh.splitlines() if line.startswith(("hostname ", "hostkeyalias "))]
|
||||
assert "hostname host.docker.internal" in ssh.splitlines()
|
||||
assert "hostkeyalias 147.182.178.136" in ssh.splitlines()
|
||||
report["memory"] = run("free", "-m")
|
||||
report["disk"] = run("df", "-h", "/")
|
||||
report["running_containers"] = run("docker", "ps", "--format", "{{.Names}} {{.Status}}")
|
||||
report["result"] = "passed"
|
||||
print(json.dumps(report, indent=2))
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
record=$1
|
||||
environment=$2
|
||||
operation=${3:-deploy}
|
||||
case "$record" in
|
||||
build/delivery/releases/*.json|delivery/releases/*.json) ;;
|
||||
*) echo 'Release record must be in the release metadata directory' >&2; exit 1 ;;
|
||||
esac
|
||||
python3 delivery/ci/release.py verify "$record" --environment "$environment"
|
||||
config=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["configuration_commit"])' "$record")
|
||||
scratch=$(mktemp -d)
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
# Recover both playbook and template from the configuration recorded with this image.
|
||||
git archive "$config" delivery/ansible | tar -x -C "$scratch"
|
||||
: "${DEPLOY_KEY:?bind the deployment SSH key as a Jenkins file credential}"
|
||||
: "${DEPLOY_KNOWN_HOSTS:?bind the verified known_hosts as a Jenkins file credential}"
|
||||
export ANSIBLE_HOST_KEY_CHECKING=True
|
||||
export ANSIBLE_SSH_ARGS="-o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$DEPLOY_KNOWN_HOSTS"
|
||||
export ANSIBLE_PRIVATE_KEY_FILE="$DEPLOY_KEY"
|
||||
ansible-playbook -i "$scratch/delivery/ansible/inventory.ini" \
|
||||
"$scratch/delivery/ansible/deploy.yml" --syntax-check -e "@$record"
|
||||
python3 delivery/ci/run-ansible.py "$record" "$operation" \
|
||||
-i "$scratch/delivery/ansible/inventory.ini" \
|
||||
"$scratch/delivery/ansible/deploy.yml" -e "@$record"
|
||||
@@ -0,0 +1,48 @@
|
||||
"""Sample public HTTPS health during release/recovery; failures are evidence."""
|
||||
|
||||
import argparse
|
||||
import csv
|
||||
from datetime import datetime, timezone
|
||||
import json
|
||||
from pathlib import Path
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--url', choices=['https://app.yebilly.me', 'https://staging.yebilly.me'], required=True)
|
||||
parser.add_argument('--seconds', type=int, default=600)
|
||||
parser.add_argument('--interval', type=float, default=1)
|
||||
parser.add_argument('--output', required=True)
|
||||
args = parser.parse_args()
|
||||
if not 1 <= args.seconds <= 1800 or args.interval < 0.5:
|
||||
parser.error('Use 1-1800 seconds and at least 0.5 seconds between samples')
|
||||
output = Path(args.output)
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
deadline = time.monotonic() + args.seconds
|
||||
with output.open('w', newline='') as stream:
|
||||
writer = csv.writer(stream)
|
||||
writer.writerow(['started_utc', 'elapsed_seconds', 'http_status', 'status', 'version', 'error'])
|
||||
while time.monotonic() < deadline:
|
||||
started = datetime.now(timezone.utc).isoformat()
|
||||
clock = time.monotonic()
|
||||
code, status, version, error = '', '', '', ''
|
||||
try:
|
||||
with urllib.request.urlopen(args.url + '/health', timeout=2) as response:
|
||||
code = response.status
|
||||
body = json.load(response)
|
||||
status, version = body.get('status', ''), body.get('version', '')
|
||||
except urllib.error.HTTPError as failure:
|
||||
code, error = failure.code, type(failure).__name__
|
||||
except (OSError, ValueError, urllib.error.URLError) as failure:
|
||||
error = type(failure).__name__
|
||||
writer.writerow([started, round(time.monotonic() - clock, 3), code, status, version, error])
|
||||
stream.flush()
|
||||
time.sleep(max(0, args.interval - (time.monotonic() - clock)))
|
||||
print(f'Saved samples to {output}; inspect failed samples and gaps, not just the exit status')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
set +x
|
||||
: "${REGISTRY_USER:?bind registry credentials}"
|
||||
: "${REGISTRY_TOKEN:?bind registry credentials}"
|
||||
image=git.yebilly.me/ssw590-group1/pricing
|
||||
commit=$(git rev-parse HEAD)
|
||||
reports=build/delivery/reports
|
||||
mkdir -p "$reports" build/delivery/releases
|
||||
export DOCKER_CONFIG
|
||||
DOCKER_CONFIG=$(mktemp -d)
|
||||
trap 'rm -rf "$DOCKER_CONFIG"' EXIT
|
||||
printf '%s' "$REGISTRY_TOKEN" | docker login --username "$REGISTRY_USER" --password-stdin git.yebilly.me
|
||||
# Never overwrite a source-commit tag during a retry.
|
||||
if docker manifest inspect "$image:$commit" > "$reports/existing-manifest.json" 2> "$reports/manifest-check.log"; then
|
||||
docker pull "$image:$commit"
|
||||
else
|
||||
if ! grep -Eqi 'manifest unknown|no such manifest|not found' "$reports/manifest-check.log"; then
|
||||
cat "$reports/manifest-check.log" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "${DELIVERY_BUILDER:-}" ]; then
|
||||
docker buildx build --builder "$DELIVERY_BUILDER" --load --platform linux/amd64 \
|
||||
--build-arg "APP_COMMIT=$commit" -t "$image:$commit" delivery/app
|
||||
else
|
||||
docker build --platform linux/amd64 --build-arg "APP_COMMIT=$commit" -t "$image:$commit" delivery/app
|
||||
fi
|
||||
python3 delivery/ci/security.py image --image "$image:$commit" --reports "$reports/image-gate"
|
||||
docker push "$image:$commit"
|
||||
docker pull "$image:$commit"
|
||||
fi
|
||||
digest=$(docker image inspect "$image:$commit" --format '{{index .RepoDigests 0}}')
|
||||
python3 delivery/ci/security.py image --image "$digest" --reports "$reports/published-image-gate"
|
||||
printf '%s\n' "$digest" > "$reports/published-digest.txt"
|
||||
python3 delivery/ci/release.py create --image "$digest" --build-url "$BUILD_URL" --output build/delivery/releases
|
||||
@@ -0,0 +1,77 @@
|
||||
"""Create and verify non-secret release records used by Ansible."""
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
URLS = {"staging": "https://staging.yebilly.me", "production": "https://app.yebilly.me"}
|
||||
IMAGE = re.compile(r"git\.yebilly\.me/ssw590-group1/pricing@sha256:[0-9a-f]{64}")
|
||||
COMMIT = re.compile(r"[0-9a-f]{40}")
|
||||
|
||||
|
||||
def verify(record):
|
||||
required = {"release_image", "expected_commit", "configuration_commit",
|
||||
"expected_version", "expected_total", "proxy_network", "target_env", "public_url"}
|
||||
if not required <= record.keys() or record.keys() - required - {"build_url", "created_at"}:
|
||||
raise ValueError("Missing or unexpected release fields")
|
||||
if not IMAGE.fullmatch(record["release_image"]):
|
||||
raise ValueError("Release requires the team registry image and exact digest")
|
||||
for name in ("expected_commit", "configuration_commit"):
|
||||
value = record[name]
|
||||
if not COMMIT.fullmatch(value):
|
||||
raise ValueError(f"Invalid {name}")
|
||||
subprocess.run(["git", "merge-base", "--is-ancestor", value, "origin/main"], check=True)
|
||||
version = record["expected_version"]
|
||||
if version not in {"v1", "v2"}:
|
||||
raise ValueError("Unsupported application release")
|
||||
if record["expected_total"] != {"v1": 30, "v2": 36}[version]:
|
||||
raise ValueError("Unexpected business result")
|
||||
environment = record["target_env"]
|
||||
if record["public_url"] != URLS[environment] or record["proxy_network"] != "gitea_web":
|
||||
raise ValueError("Unexpected deployment target")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
commands = parser.add_subparsers(dest="action", required=True)
|
||||
create = commands.add_parser("create")
|
||||
create.add_argument("--image", required=True)
|
||||
create.add_argument("--build-url", required=True)
|
||||
create.add_argument("--output", required=True)
|
||||
check = commands.add_parser("verify")
|
||||
check.add_argument("record")
|
||||
check.add_argument("--environment", choices=["staging", "production"])
|
||||
args = parser.parse_args()
|
||||
if args.action == "verify":
|
||||
record = json.loads(Path(args.record).read_text())
|
||||
verify(record)
|
||||
if args.environment and record["target_env"] != args.environment:
|
||||
raise ValueError("Release environment does not match the authorized pipeline stage")
|
||||
return
|
||||
values = {}
|
||||
for node in ast.parse(Path("delivery/app/app.py").read_text()).body:
|
||||
if isinstance(node, ast.Assign):
|
||||
for target in node.targets:
|
||||
if isinstance(target, ast.Name) and target.id in {"VERSION", "UNIT_PRICE"}:
|
||||
values[target.id] = ast.literal_eval(node.value)
|
||||
commit = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
|
||||
record = {
|
||||
"release_image": args.image, "expected_commit": commit,
|
||||
"configuration_commit": commit, "expected_version": values["VERSION"],
|
||||
"expected_total": values["UNIT_PRICE"] * 3, "proxy_network": "gitea_web",
|
||||
"build_url": args.build_url, "created_at": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
output = Path(args.output)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
for environment, url in URLS.items():
|
||||
target = dict(record, target_env=environment, public_url=url)
|
||||
verify(target)
|
||||
(output / f"{values['VERSION']}-{environment}.json").write_text(json.dumps(target, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,62 @@
|
||||
"""Archive deployment timing/recaps and enforce the unchanged-rerun gate."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
record = json.loads(Path(sys.argv[1]).read_text())
|
||||
operation = sys.argv[2]
|
||||
if operation not in {"deploy", "rerun"}:
|
||||
raise ValueError("Unknown deployment operation")
|
||||
reports = Path("build/delivery/reports")
|
||||
reports.mkdir(parents=True, exist_ok=True)
|
||||
stem = f"ansible-{record['target_env']}-{operation}"
|
||||
started = datetime.now(timezone.utc).isoformat()
|
||||
clock = time.monotonic()
|
||||
process = subprocess.Popen(
|
||||
["ansible-playbook", *sys.argv[3:]], text=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
env=dict(os.environ, ANSIBLE_NOCOLOR="1"),
|
||||
)
|
||||
lines = []
|
||||
with (reports / f"{stem}.txt").open("w") as log:
|
||||
for line in process.stdout:
|
||||
print(line, end="", flush=True)
|
||||
log.write(line)
|
||||
lines.append(line)
|
||||
status = process.wait()
|
||||
recaps = []
|
||||
for line in lines:
|
||||
match = re.match(r"^(\S+)\s+:\s+ok=(\d+)\s+changed=(\d+)\s+unreachable=(\d+)\s+failed=(\d+)", line)
|
||||
if match:
|
||||
recaps.append(dict(zip(
|
||||
["host", "ok", "changed", "unreachable", "failed"],
|
||||
[match[1], *map(int, match.groups()[1:])],
|
||||
)))
|
||||
passed = status == 0 and bool(recaps) and all(
|
||||
row["failed"] == 0 and row["unreachable"] == 0
|
||||
and (operation != "rerun" or row["changed"] == 0)
|
||||
for row in recaps
|
||||
)
|
||||
report = {
|
||||
"started": started, "completed": datetime.now(timezone.utc).isoformat(),
|
||||
"elapsed_seconds": round(time.monotonic() - clock, 3),
|
||||
"operation": operation, "release": record,
|
||||
"ansible_exit_code": status, "recaps": recaps,
|
||||
"result": "passed" if passed else "blocked",
|
||||
}
|
||||
(reports / f"{stem}.json").write_text(json.dumps(report, indent=2))
|
||||
if not passed:
|
||||
print("Deployment gate blocked: inspect the archived Ansible recap", file=sys.stderr)
|
||||
return 0 if passed else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,127 @@
|
||||
"""Run release gates and preserve reports, tool versions, and process exit codes."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import subprocess
|
||||
import tempfile
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def now():
|
||||
return datetime.now(timezone.utc).isoformat()
|
||||
|
||||
|
||||
def check_report(report, kind):
|
||||
if kind == "dependencies":
|
||||
dependencies = report["dependencies"]
|
||||
if not dependencies:
|
||||
raise ValueError("Dependency audit returned no packages")
|
||||
return [v for package in dependencies for v in package["vulns"]]
|
||||
if report["SchemaVersion"] != 2 or "ArtifactName" not in report:
|
||||
raise ValueError("Unrecognized Trivy report")
|
||||
results = report["Results"]
|
||||
if not isinstance(results, list):
|
||||
raise ValueError("Trivy Results must be a list")
|
||||
if kind == "image" and not results:
|
||||
raise ValueError("Image scan returned no analyzed targets")
|
||||
if kind == "secrets":
|
||||
return [secret for result in results for secret in result.get("Secrets", [])]
|
||||
return [
|
||||
vulnerability
|
||||
for result in results
|
||||
for vulnerability in result.get("Vulnerabilities", [])
|
||||
if vulnerability["Severity"] in {"HIGH", "CRITICAL"}
|
||||
]
|
||||
|
||||
|
||||
def redact_secret_matches(report):
|
||||
for result in report.get("Results", []):
|
||||
for secret in result.get("Secrets", []):
|
||||
secret["Match"] = "[REDACTED]"
|
||||
for line in secret.get("Code", {}).get("Lines", []):
|
||||
line["Content"] = "[REDACTED]"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("phase", choices=["source", "image"])
|
||||
parser.add_argument("--image")
|
||||
parser.add_argument("--fixture", action="store_true")
|
||||
parser.add_argument("--reports", default="build/delivery/reports")
|
||||
args = parser.parse_args()
|
||||
reports = Path(args.reports).resolve()
|
||||
reports.mkdir(parents=True, exist_ok=True)
|
||||
execution = {"started": now(), "phase": args.phase, "steps": []}
|
||||
|
||||
def run(command, label, accepted=(0,)):
|
||||
result = subprocess.run(command, text=True, capture_output=True)
|
||||
(reports / f"{label}.log").write_text(result.stdout + result.stderr)
|
||||
execution["steps"].append({
|
||||
"label": label, "command": command, "completed": now(),
|
||||
"exit_code": result.returncode,
|
||||
})
|
||||
if result.returncode not in accepted:
|
||||
raise RuntimeError(f"{label} failed with exit code {result.returncode}")
|
||||
return result
|
||||
|
||||
def scan_secrets(target, label):
|
||||
output = reports / f"{label}.json"
|
||||
run([
|
||||
"trivy", "fs", "--scanners", "secret", "--secret-config",
|
||||
"delivery/trivy-secret.yaml", "--format", "json", "--output", str(output),
|
||||
"--skip-dirs", ".git", "--skip-dirs", "build", "--skip-dirs", "work",
|
||||
"--skip-dirs", ".venv", str(target),
|
||||
], label)
|
||||
report = json.loads(output.read_text())
|
||||
redact_secret_matches(report)
|
||||
output.write_text(json.dumps(report, indent=2))
|
||||
if check_report(report, "secrets"):
|
||||
raise RuntimeError(f"{label}: detected secrets block delivery")
|
||||
|
||||
try:
|
||||
run(["trivy", "--version"], "trivy-version")
|
||||
run(["pip-audit", "--version"], "pip-audit-version")
|
||||
if args.phase == "source":
|
||||
scan_secrets(".", "source-secrets")
|
||||
output = reports / "dependencies.json"
|
||||
result = run([
|
||||
"pip-audit", "-r", "delivery/app/requirements.txt", "--no-deps",
|
||||
"--disable-pip", "--format", "json", "--output", str(output),
|
||||
], "dependencies", accepted=(0, 1))
|
||||
findings = check_report(json.loads(output.read_text()), "dependencies")
|
||||
if result.returncode or findings:
|
||||
raise RuntimeError("Dependency findings or audit errors block delivery")
|
||||
if args.fixture:
|
||||
with tempfile.TemporaryDirectory(prefix="ssw590-scan-") as directory:
|
||||
# Construct the nonfunctional course fixture only in the test run.
|
||||
value = "SSW590_SYNTHETIC_SECRET_" + "0" * 16
|
||||
Path(directory, "fixture.txt").write_text(value)
|
||||
scan_secrets(directory, "synthetic-secret")
|
||||
raise RuntimeError("Synthetic fixture was not detected")
|
||||
else:
|
||||
if not args.image:
|
||||
raise ValueError("--image is required for the image gate")
|
||||
output = reports / "image.json"
|
||||
run([
|
||||
"trivy", "image", "--scanners", "vuln", "--format", "json",
|
||||
"--output", str(output), args.image,
|
||||
], "image")
|
||||
run(["trivy", "--version"], "trivy-database-version")
|
||||
if check_report(json.loads(output.read_text()), "image"):
|
||||
raise RuntimeError("HIGH/CRITICAL image findings block delivery")
|
||||
execution["result"] = "passed"
|
||||
print(f"{args.phase} gate passed")
|
||||
except (OSError, ValueError, KeyError, TypeError, RuntimeError) as error:
|
||||
execution["result"] = "blocked"
|
||||
execution["reason"] = str(error)
|
||||
print(f"{args.phase} gate blocked: {error}")
|
||||
return 1
|
||||
finally:
|
||||
execution["completed"] = now()
|
||||
(reports / f"{args.phase}-execution.json").write_text(json.dumps(execution, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
reports=${REPORTS_DIR:-build/delivery/reports}
|
||||
mkdir -p "$reports"
|
||||
reports=$(cd "$reports" && pwd)
|
||||
test_dir=$(mktemp -d)
|
||||
trap 'rm -rf "$test_dir"' EXIT
|
||||
python3 -m venv "$test_dir/venv"
|
||||
test_python="$test_dir/venv/bin/python"
|
||||
"$test_python" -m pip install -r delivery/app/requirements.txt
|
||||
cp delivery/app/app.py delivery/app/test_app.py "$test_dir/"
|
||||
if [ "${TEST_FAILURE:-false}" = true ]; then
|
||||
cat > "$test_dir/test_gate_fixture.py" <<'PY'
|
||||
import unittest
|
||||
from app import app
|
||||
|
||||
class ControlledWrongPrice(unittest.TestCase):
|
||||
def test_deliberately_wrong_expected_price(self):
|
||||
response = app.test_client().get('/price?quantity=3')
|
||||
self.assertEqual(response.json['total'], -1, 'Controlled test must block delivery')
|
||||
PY
|
||||
fi
|
||||
cd "$test_dir"
|
||||
"$test_python" -B - "$reports" <<'PY'
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
started = datetime.now(timezone.utc).isoformat()
|
||||
result = subprocess.run([sys.executable, '-B', '-m', 'unittest', '-v'], text=True, capture_output=True)
|
||||
output = result.stdout + result.stderr
|
||||
print(output, end='')
|
||||
reports = Path(sys.argv[1])
|
||||
(reports / 'unit-tests.txt').write_text(output)
|
||||
(reports / 'unit-tests.json').write_text(json.dumps({
|
||||
'started': started, 'completed': datetime.now(timezone.utc).isoformat(),
|
||||
'exit_code': result.returncode,
|
||||
'result': 'passed' if result.returncode == 0 else 'blocked',
|
||||
}, indent=2))
|
||||
raise SystemExit(result.returncode)
|
||||
PY
|
||||
@@ -0,0 +1,112 @@
|
||||
"""Regression checks for fail-closed release and scan boundaries."""
|
||||
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import release
|
||||
import security
|
||||
|
||||
spec = importlib.util.spec_from_file_location('run_ansible', Path(__file__).with_name('run-ansible.py'))
|
||||
run_ansible = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(run_ansible)
|
||||
|
||||
|
||||
class SecurityGateTests(unittest.TestCase):
|
||||
def test_empty_dependency_audit_is_not_clean_evidence(self):
|
||||
with self.assertRaises(ValueError):
|
||||
security.check_report({"dependencies": []}, "dependencies")
|
||||
|
||||
def test_incomplete_or_unrecognized_scan_is_rejected(self):
|
||||
for report in [{}, {"SchemaVersion": 2, "ArtifactName": "."},
|
||||
{"SchemaVersion": 3, "ArtifactName": ".", "Results": []}]:
|
||||
with self.subTest(report=report), self.assertRaises((ValueError, KeyError)):
|
||||
security.check_report(report, "secrets")
|
||||
|
||||
def test_high_findings_and_secrets_block(self):
|
||||
report = {"SchemaVersion": 2, "ArtifactName": "image", "Results": [{
|
||||
"Vulnerabilities": [{"Severity": "LOW"}, {"Severity": "HIGH"}, {"Severity": "CRITICAL"}],
|
||||
"Secrets": [{"Severity": "LOW", "Match": "test-data"}],
|
||||
}]}
|
||||
self.assertEqual(len(security.check_report(report, "image")), 2)
|
||||
self.assertEqual(len(security.check_report(report, "secrets")), 1)
|
||||
security.redact_secret_matches(report)
|
||||
self.assertEqual(report["Results"][0]["Secrets"][0]["Match"], "[REDACTED]")
|
||||
|
||||
def test_image_without_analyzed_targets_is_rejected(self):
|
||||
with self.assertRaises(ValueError):
|
||||
security.check_report({"SchemaVersion": 2, "ArtifactName": "image", "Results": []}, "image")
|
||||
|
||||
|
||||
class ReleaseBoundaryTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.record = {
|
||||
"release_image": "git.yebilly.me/ssw590-group1/pricing@sha256:" + "a" * 64,
|
||||
"expected_commit": "b" * 40, "configuration_commit": "c" * 40,
|
||||
"expected_version": "v1", "expected_total": 30,
|
||||
"proxy_network": "gitea_web", "target_env": "staging",
|
||||
"public_url": "https://staging.yebilly.me",
|
||||
}
|
||||
|
||||
@patch("release.subprocess.run")
|
||||
def test_both_commits_must_be_reviewed_main_ancestors(self, run):
|
||||
release.verify(self.record)
|
||||
self.assertEqual([call.args[0][-2] for call in run.call_args_list], ["b" * 40, "c" * 40])
|
||||
self.assertTrue(all(call.kwargs["check"] for call in run.call_args_list))
|
||||
|
||||
@patch("release.subprocess.run")
|
||||
def test_cross_environment_url_is_rejected(self, run):
|
||||
self.record["public_url"] = "https://app.yebilly.me"
|
||||
with self.assertRaises(ValueError):
|
||||
release.verify(self.record)
|
||||
|
||||
|
||||
def test_mutable_tag_or_other_registry_is_rejected(self):
|
||||
for image in ["git.yebilly.me/ssw590-group1/pricing:latest", "example.com/pricing@sha256:" + "a" * 64]:
|
||||
self.record["release_image"] = image
|
||||
with self.assertRaises(ValueError):
|
||||
release.verify(self.record)
|
||||
|
||||
def test_unexpected_ansible_variables_are_rejected(self):
|
||||
self.record["ansible_host"] = "unapproved-host"
|
||||
with self.assertRaises(ValueError):
|
||||
release.verify(self.record)
|
||||
|
||||
|
||||
class UnchangedRerunTests(unittest.TestCase):
|
||||
def check_recap(self, text, exit_code=0):
|
||||
original = Path.cwd()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
try:
|
||||
os.chdir(directory)
|
||||
Path('release.json').write_text(json.dumps({'target_env': 'staging'}))
|
||||
with patch('sys.argv', ['run-ansible.py', 'release.json', 'rerun', 'playbook.yml']), \
|
||||
patch.object(run_ansible.subprocess, 'Popen') as launch, \
|
||||
patch('sys.stdout', new_callable=io.StringIO), \
|
||||
patch('sys.stderr', new_callable=io.StringIO):
|
||||
launch.return_value.stdout = io.StringIO(text)
|
||||
launch.return_value.wait.return_value = exit_code
|
||||
return run_ansible.main()
|
||||
finally:
|
||||
os.chdir(original)
|
||||
|
||||
def test_unchanged_success_passes(self):
|
||||
self.assertEqual(self.check_recap('startup : ok=9 changed=0 unreachable=0 failed=0 skipped=0\n'), 0)
|
||||
|
||||
def test_success_with_unnecessary_changes_blocks(self):
|
||||
self.assertEqual(self.check_recap('startup : ok=9 changed=1 unreachable=0 failed=0 skipped=0\n'), 1)
|
||||
|
||||
def test_missing_recap_is_not_a_success(self):
|
||||
self.assertEqual(self.check_recap('No deployment results\n'), 1)
|
||||
|
||||
def test_ansible_error_blocks_even_with_good_looking_recap(self):
|
||||
self.assertEqual(self.check_recap('startup : ok=9 changed=0 unreachable=0 failed=0\n', 1), 1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,64 @@
|
||||
# Delivery agent migration — preparation evidence
|
||||
|
||||
Vincent selected The-Ocean instead of the laptop to avoid the previously
|
||||
observed campus SSH restriction. This work occurred on November 14 Eastern;
|
||||
the host's UTC timestamps below fall on November 15, 2026.
|
||||
|
||||
- Existing host: 1 CPU, 1,967 MiB RAM, original 25 GB plan disk, 2 GiB swap.
|
||||
At 03:29 UTC, 811 MiB RAM was available and swap used was 129 MiB.
|
||||
- Transferred the existing agent image, without rebuilding its toolchain:
|
||||
`sha256:0752666650a3afe7b61854c1df4dca21f4ef381fab1f4fb9b042adaa203c58a8`.
|
||||
Transfer archive SHA-256 matched on both machines:
|
||||
`f987fdb285757aabe91fffd21a3a58da00bec975efcce7ee8ef3f127b27d0696`.
|
||||
- Stopped the laptop container before connecting its replacement. Existing
|
||||
node name `ssw590-vince-delivery`, label `delivery-trusted`, one exclusive
|
||||
executor, folder credentials and disabled pricing job were retained.
|
||||
- Remote agent: 512 MiB RAM / 768 MiB RAM+swap, 0.5 CPU, 96 MiB JVM heap,
|
||||
no published port, existing `gitea_web` network, private WebSocket connection.
|
||||
Socket group detected as 987; initial group-0 mismatch was corrected.
|
||||
- Builder: BuildKit v0.34.2 image pinned by index digest in the start helper;
|
||||
256 MiB RAM / 384 MiB RAM+swap, CPU quota 50000/100000, no published port.
|
||||
The pipeline explicitly selects this builder when `DELIVERY_BUILDER` is set.
|
||||
- Deployment SSH: `ssh -G` reports `hostname host.docker.internal` and
|
||||
`hostkeyalias 147.182.178.136`. The existing Jenkins known-hosts credential
|
||||
remains authoritative; host verification was not bypassed.
|
||||
- [Jenkins prerequisite build 2](https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/2/)
|
||||
passed at 03:47 UTC, including real credential binding, deploy login, pinned
|
||||
host key and sudo. See [inventory](agent-preflight-2.txt).
|
||||
- 03:50:16–03:51:43 UTC: the separate capacity preparation trial passed 12
|
||||
control tests and 3 app tests, source-secret/dependency gates, capped image
|
||||
build, full image gate (zero HIGH/CRITICAL), and a temporary 64 MiB app smoke.
|
||||
Health v1, identity `uncommitted-remote-preflight`, total 30 for quantity 3,
|
||||
and HTTP 400 for invalid quantity were verified. The smoke container was
|
||||
removed. No image was pushed and no assessed environment was deployed.
|
||||
- The trial used a non-secret local snapshot of `delivery/app`, `delivery/ci`,
|
||||
the scanner rule and the trial script, not a reviewed full repository checkout.
|
||||
Snapshot archive SHA-256:
|
||||
`2cd5d23062ff9904b48a23dfd5d9f2b9c67929cb86db006e7b2677060da3afa0`.
|
||||
Gate reports retain actual timestamps and tool/database metadata.
|
||||
- Observed available RAM exceeded 700 MiB; swap used increased from 263 to
|
||||
372 MiB during the sampled trial. At 03:54 UTC, 861 MiB was available, swap
|
||||
used was 370 MiB and root disk was 56% used (11 GiB available, rounded by df).
|
||||
Agent cgroup memory-limit events were nonzero; agent and builder `oom` and
|
||||
`oom_kill` counters were zero, and both reported `OOMKilled=false`.
|
||||
- Gitea, Jenkins login and Grafana login returned HTTP 200 through private
|
||||
Docker routes after the trial. Seven previous containers remained running.
|
||||
- Restarted only the agent; logs recorded a fresh WebSocket connection and
|
||||
`Connected` at 03:57:57 UTC. `unless-stopped` is configured for both agent and
|
||||
builder; an entire-host reboot was not performed as part of this migration.
|
||||
|
||||
Raw reports, partial resource-output capture, runtime JSON and screenshot:
|
||||
ignored `build/evidence/assignment8-agent-migration/`. Protected server reports:
|
||||
`/root/ssw590-delivery-bootstrap/agent-migration/`. The short trial used swap
|
||||
and does not prove full release, recovery or campus presentation performance.
|
||||
|
||||
No firewall rule, credential scope, TLS verification, peer-review requirement
|
||||
or human production approval changed. Co-located Docker authority gives trusted
|
||||
jobs administrative access to the shared host; this is an explicit course-lab
|
||||
trade-off. The older Gitea Actions PDF runner remains on the laptop. No new
|
||||
instance or cloud plan change was made. Migration changes are uncommitted;
|
||||
DNS, reviewed releases, production approvals and recovery exercises remain pending.
|
||||
|
||||
Subsequently Vincent requested moving that Actions runner too. The statement
|
||||
above describes the end of the delivery-agent migration, not current placement.
|
||||
See the [later runner record](../../gitea/droplet-runner/EVIDENCE.md).
|
||||
@@ -0,0 +1,32 @@
|
||||
Sat Nov 14 20:46:17 UTC 2026
|
||||
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins),0(root)
|
||||
Python 3.13.5
|
||||
ansible [core 2.21.6]
|
||||
config file = None
|
||||
configured module search path = ['/home/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
|
||||
ansible python module location = /opt/delivery-tools/lib/python3.13/site-packages/ansible
|
||||
ansible collection location = /opt/ansible-collections
|
||||
executable location = /opt/delivery-tools/bin/ansible
|
||||
python version = 3.13.5 (main, Aug 10 2026, 12:06:59) [GCC 14.2.0] (/opt/delivery-tools/bin/python3)
|
||||
jinja version = 3.1.6
|
||||
pyyaml version = 6.0.3 (with libyaml v0.2.5)
|
||||
|
||||
# /opt/ansible-collections/ansible_collections
|
||||
Collection Version
|
||||
---------------------------------------- -------
|
||||
community.docker 5.4.0
|
||||
community.library_inventory_filtering_v1 1.1.5
|
||||
Docker version 29.9.3, build 5457199
|
||||
Docker Compose version v5.7.1
|
||||
Version: 0.76.2
|
||||
pip-audit 2.10.1
|
||||
uid=1000(deploy) gid=1000(deploy) groups=1000(deploy)
|
||||
Python 3.12.3
|
||||
Docker version 29.9.3, build 5457199
|
||||
Docker Compose version v5.7.1
|
||||
total used free shared buff/cache available
|
||||
Mem: 1967 1089 85 4 955 878
|
||||
Swap: 2047 102 1945
|
||||
1
|
||||
Filesystem Size Used Avail Use% Mounted on
|
||||
/dev/vda1 24G 9.5G 14G 41% /
|
||||
@@ -0,0 +1,32 @@
|
||||
Sun Nov 15 03:47:13 UTC 2026
|
||||
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins),987
|
||||
Python 3.13.5
|
||||
ansible [core 2.21.6]
|
||||
config file = None
|
||||
configured module search path = ['/home/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
|
||||
ansible python module location = /opt/delivery-tools/lib/python3.13/site-packages/ansible
|
||||
ansible collection location = /opt/ansible-collections
|
||||
executable location = /opt/delivery-tools/bin/ansible
|
||||
python version = 3.13.5 (main, Aug 10 2026, 12:06:59) [GCC 14.2.0] (/opt/delivery-tools/bin/python3)
|
||||
jinja version = 3.1.6
|
||||
pyyaml version = 6.0.3 (with libyaml v0.2.5)
|
||||
|
||||
# /opt/ansible-collections/ansible_collections
|
||||
Collection Version
|
||||
---------------------------------------- -------
|
||||
community.docker 5.4.0
|
||||
community.library_inventory_filtering_v1 1.1.5
|
||||
Docker version 29.9.3, build 5457199
|
||||
Docker Compose version v5.7.1
|
||||
Version: 0.76.2
|
||||
pip-audit 2.10.1
|
||||
uid=1000(deploy) gid=1000(deploy) groups=1000(deploy)
|
||||
Python 3.12.3
|
||||
Docker version 29.9.3, build 5457199
|
||||
Docker Compose version v5.7.1
|
||||
total used free shared buff/cache available
|
||||
Mem: 1967 1205 106 3 832 762
|
||||
Swap: 2047 265 1782
|
||||
1
|
||||
Filesystem Size Used Avail Use% Mounted on
|
||||
/dev/vda1 24G 12G 13G 49% /
|
||||
@@ -0,0 +1,36 @@
|
||||
# DNS and HTTPS readiness — 15 November 2026
|
||||
|
||||
Billy added A records for `staging.yebilly.me` and `app.yebilly.me` pointing to
|
||||
`147.182.178.136`. At 06:14 UTC, Google and Cloudflare DNS-over-HTTPS both returned
|
||||
that A record and no AAAA answer for each name. No DNS account was accessed or
|
||||
changed by Codex.
|
||||
|
||||
At 06:09:34 UTC, the prepared `deploy/Caddyfile` additions were validated with
|
||||
installed Caddy 2.11.4, backed up and gracefully reloaded. The helper checked
|
||||
that earlier routes matched before changing anything and preserved the existing
|
||||
bind-mounted inode. The first comparison stopped because of CRLF versus LF;
|
||||
normalizing only that comparison allowed the matching routes to pass.
|
||||
|
||||
- Before SHA-256: `0197f100c5a1f2a21c6a293964fada27f61fe6f4ddf0b0c6d1ed6455f2cfbcc5`.
|
||||
- After SHA-256: `7adbd9469b1e0ebcb8d6b62c8576eb4fb8b51efc70409607f604f453f8ac8187`.
|
||||
- Backup: `/root/ssw590-delivery-bootstrap/https-20261115/Caddyfile.before`.
|
||||
- Existing Gitea/Jenkins/Grafana routes, allowlist placeholders, volumes and
|
||||
certificate storage were preserved. No firewall or published port changed.
|
||||
|
||||
Normal Windows curl and Ubuntu Python TLS checks passed without insecure mode.
|
||||
Both hostnames negotiated TLS 1.3 with trusted hostname-matching certificates.
|
||||
HTTP returned 308 with the corresponding HTTPS Location. HTTPS returned 502:
|
||||
the staging/production pricing containers do not exist yet. This proves DNS,
|
||||
TLS and redirects, not app health or a completed release.
|
||||
|
||||
All ten prior service/agent/builder containers remained running. Gitea, Jenkins
|
||||
login and Grafana login returned private HTTP 200 after the reload. Production
|
||||
monitoring was not enabled while the pricing service was absent.
|
||||
|
||||
Actual DNS answers, certificate issuer/SAN/validity/fingerprints and HTTP results
|
||||
are in ignored `build/evidence/assignment8-https/verification.json`; application
|
||||
and existing-service checks remain separate. No reviewed release, registry
|
||||
publication, promotion, rollback, password reset or account-permission change
|
||||
was performed during this work. The source changes remain uncommitted.
|
||||
|
||||
Caddy behavior: [Automatic HTTPS](https://caddyserver.com/docs/automatic-https).
|
||||
@@ -0,0 +1,6 @@
|
||||
rules:
|
||||
- id: ssw590-synthetic-secret
|
||||
category: course-test
|
||||
title: SSW590 synthetic blocked-gate fixture
|
||||
severity: HIGH
|
||||
regex: 'SSW590_SYNTHETIC_SECRET_[A-Z0-9]{16}'
|
||||
@@ -10,8 +10,26 @@ colors.yebilly.me {
|
||||
# Jenkins: Stevens campus network (155.246.0.0/16) plus team and approved grader
|
||||
# IPs from CI_TEAM_IPS in the untracked .env. Everyone else gets 403 before login.
|
||||
# The Stevens VPN is split-tunnel, so it does not give visitors a 155.246.x.x address.
|
||||
# 172.30.90.10 is Blackbox Exporter on the private probe network (monitoring/compose.yaml).
|
||||
ci.yebilly.me {
|
||||
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS}
|
||||
@denied not remote_ip 155.246.0.0/16 172.30.90.10/32 {$CI_TEAM_IPS}
|
||||
respond @denied 403
|
||||
reverse_proxy jenkins:8080
|
||||
}
|
||||
|
||||
# Grafana (Assignment 7): same allowlist as Jenkins, then Grafana's own login.
|
||||
metrics.yebilly.me {
|
||||
@denied not remote_ip 155.246.0.0/16 {$CI_TEAM_IPS}
|
||||
respond @denied 403
|
||||
reverse_proxy grafana:3000
|
||||
}
|
||||
|
||||
# Assignment 8: apply after both DNS names resolve to The-Ocean. Containers
|
||||
# publish no host ports; the existing proxy reaches their private aliases.
|
||||
staging.yebilly.me {
|
||||
reverse_proxy pricing-staging:8000
|
||||
}
|
||||
|
||||
app.yebilly.me {
|
||||
reverse_proxy pricing-production:8000
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ services:
|
||||
# Jenkins resolves git.yebilly.me to Caddy here, so checkout and status
|
||||
# calls stay on the droplet instead of hairpinning through the public IP.
|
||||
aliases: [git.yebilly.me]
|
||||
probe:
|
||||
# Blackbox Exporter (monitoring/compose.yaml) probes both sites through Caddy here.
|
||||
aliases: [git.yebilly.me, ci.yebilly.me]
|
||||
depends_on: [gitea]
|
||||
|
||||
# Jenkins LTS controller (Assignment 6). Builds run on its single executor.
|
||||
@@ -66,3 +69,10 @@ volumes:
|
||||
|
||||
networks:
|
||||
web:
|
||||
# Fixed subnet so Blackbox Exporter can have a fixed address (172.30.90.10), the only
|
||||
# private address the ci.yebilly.me allowlist admits. The web subnet stays denied:
|
||||
# Docker's proxy presents IPv6 and hairpin visitors as its gateway, 172.18.0.1.
|
||||
probe:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.30.90.0/28
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Manual runner migration evidence
|
||||
|
||||
Requested by Vincent on 14 November 2026, Eastern time. Server timestamps below
|
||||
are UTC on 15 November. No commit, push, new registration or scope change occurred.
|
||||
|
||||
- Baseline 04:24 UTC: 1,967 MiB RAM, 860 MiB available, 338 MiB swap used;
|
||||
root disk 55% used, 11 GiB available (rounded by df).
|
||||
- Exported the existing compiler image, verified the transfer archive SHA-256
|
||||
`faf56b61af1187b6dad0f1e27b1ec47bed282ffe52aee9c458c13a88ee02849a`,
|
||||
then loaded it on The-Ocean. Image ID matches the original tested image:
|
||||
`sha256:5d24657a4578977fc7709165b82fc869f09a654a58ab4a0c8defd9d2cd662d5d`.
|
||||
- Stopped the idle laptop runner before copying its existing registration
|
||||
directly over pinned SSH into the remote Docker volume. Identity was
|
||||
validated quietly, mode 0600; no value was output or written into the repo.
|
||||
Name `ssw590-vince-local`, label `latex-local`, capacity one and repository
|
||||
scope remain unchanged. The laptop volume/image are retained as fallback.
|
||||
- At 04:31 UTC the remote daemon declared successfully. The initial 96 MiB
|
||||
daemon cap was insufficient during action setup: Docker recorded an OOM
|
||||
event at 04:32:18 and restart count 1. Run 12 attempt 2 / job 13 was canceled.
|
||||
Its failure log is retained; its orphan container, network and two task-only
|
||||
volumes were removed after validation, preserving shared volumes.
|
||||
- Raised only the daemon to 192 MiB RAM / 256 MiB RAM+swap, with GOMEMLIMIT
|
||||
128 MiB and 0.25 CPU. Compiler job caps remain 512 MiB / 768 MiB, 0.5 CPU,
|
||||
256 PIDs, no published ports and no automatic job Docker socket mount.
|
||||
- [Run 12, attempt 3, job 14](https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/actions/runs/12/jobs/14)
|
||||
succeeded on the remote runner. Source is reviewed main commit
|
||||
`8beefde2a4983888effb79526e527303e60a1a82`; this reruns Assignment 7 source,
|
||||
not the uncommitted Assignment 8 preparation. Setup 2m33s, checkout 9s,
|
||||
compile 1m42s, PDF upload 5s, diagnostics upload 2s, completion 1s; total 4m32s.
|
||||
- Diagnostics supplied by Vincent in `build/evidence/run-12/` confirm source
|
||||
SHA, run 12, suffix `+build.12.8beefde`, TeX Live 2022, latexmk 4.79,
|
||||
Git 2.39.5 and Node 22.23.3. The PDF is 9,059,039 bytes and its SHA-256
|
||||
matches diagnostics:
|
||||
`f81fd73d8fd975d8d61164948a977c4048ee93e38b656904334835f6b5c29c8b`.
|
||||
Its title was visually verified as `5.1+build.12.8beefde`.
|
||||
- Browser download waiting timed out and the debugger then detached. Vincent
|
||||
supplied diagnostics; the exact attempt-3 PDF was retrieved using read-only
|
||||
artifact metadata and gzip payload over pinned administrator SSH, without
|
||||
changing server data. Original expired attempt-1 metadata was preserved.
|
||||
- At 04:41 UTC during compilation: 738 MiB host RAM available, 354 MiB swap
|
||||
used; sampled compiler working set 142.4 MiB, daemon 20.43 MiB. A later
|
||||
idle check found no active jobs, daemon restarts 0 and no current OOM flag.
|
||||
These samples do not prove concurrency capacity or uninterrupted service.
|
||||
- The idle daemon restarted and declared successfully again at 04:55:52 UTC.
|
||||
`unless-stopped` is configured; a complete Droplet reboot was not performed.
|
||||
- Final post-migration check: all ten service/agent/builder containers running;
|
||||
Gitea, Jenkins login and Grafana login returned private HTTP 200. Host RAM
|
||||
available 840 MiB, swap used 358 MiB, root disk 61% used with 9.2 GiB
|
||||
available after removing the verified compiler transfer archive. Both laptop
|
||||
daemons were confirmed exited. Protected identities and prior evidence remain.
|
||||
|
||||
Raw logs, runtime checks and artifact verification are under ignored
|
||||
`build/evidence/assignment8-manual-runner/`; the user-provided diagnostics and
|
||||
verified CI PDF remain in `build/evidence/run-12/`. Existing service checks and
|
||||
the final local manual build are recorded separately. Both active runners
|
||||
now run on The-Ocean; keep manual compilation and delivery releases sequential.
|
||||
The assignment's actual app releases and recovery evidence remain pending.
|
||||
@@ -0,0 +1,78 @@
|
||||
# Manual Actions runner on The-Ocean
|
||||
|
||||
Vincent requested this migration on 14 November 2026 after moving the Jenkins
|
||||
delivery agent. This replaces the active laptop runner; it does not create
|
||||
another registration or expand its repository scope. The historical runner
|
||||
name `ssw590-vince-local` and label `latex-local` remain for workflow compatibility.
|
||||
The container is `ssw590-manual-runner`, under `/opt/ssw590-manual-runner`.
|
||||
|
||||
## Configuration and ownership
|
||||
|
||||
- Gitea runner 2.3.0, pinned to the same official image digest as the laptop.
|
||||
- Same tested compiler image `ssw590-manual-ci:20261007`, ID
|
||||
`sha256:5d24657a4578977fc7709165b82fc869f09a654a58ab4a0c8defd9d2cd662d5d`.
|
||||
- Runner: 192 MiB RAM / 256 MiB RAM+swap, 0.25 CPU, one job at a time.
|
||||
The first 96 MiB trial was killed during action setup; that attempt is retained
|
||||
in migration evidence. Compiler jobs have a separate 512 MiB / 768 MiB cap,
|
||||
0.5 CPU and 256 PID cap. Resource limits are ceilings, not reserved memory.
|
||||
- Runner and job containers publish no ports. Existing Gitea HTTPS and TLS
|
||||
verification remain enabled. Cache server stays disabled.
|
||||
- Registration lives in the host's `ssw590-local-runner-data` Docker volume,
|
||||
`/data/.runner`, mode 0600 in a 0700 directory. Never print it, place it in
|
||||
Git or share it as evidence. The stopped laptop copy is an intentional fallback.
|
||||
- `unless-stopped` reconnects the daemon after Docker/host restarts. No server
|
||||
reboot is needed for installation. Only restart an idle runner.
|
||||
- Admission checks pause new jobs below 3 GiB free disk or 600 MiB available
|
||||
host RAM. This does not reserve resources or lock Jenkins out. Run manual
|
||||
builds and Jenkins delivery releases sequentially on this single-CPU host.
|
||||
- VS maintains the runner; BY retains Droplet administration. Existing Droplet
|
||||
billing applies; no new instance or plan change was made.
|
||||
|
||||
The runner can administer host Docker. Automatic socket mounting into jobs is
|
||||
disabled, jobs are not privileged, capabilities are dropped, and arbitrary
|
||||
workflow bind mounts remain disallowed. Runner 2.x does not comprehensively
|
||||
filter workflow container options, so only the trusted team may edit these
|
||||
workflows. Co-location gives a compromised Docker-authorized workflow a path
|
||||
to the shared host; these settings are not strong isolation from untrusted code.
|
||||
See [official runner configuration](https://docs.gitea.com/runner/2/configuration/).
|
||||
|
||||
## Reconnect and stop
|
||||
|
||||
From an authorized administrator SSH session:
|
||||
|
||||
```sh
|
||||
sh /opt/ssw590-manual-runner/start.sh
|
||||
cd /opt/ssw590-manual-runner
|
||||
docker compose ps
|
||||
docker compose logs --tail 30
|
||||
python3 verify.py
|
||||
# Only when idle:
|
||||
docker compose stop
|
||||
```
|
||||
|
||||
The start helper requires existing identity and compiler image; it never
|
||||
registers a new runner. `verify.py` validates identity quietly and prints only
|
||||
non-secret runtime settings. It can capture compiler-job limits while a job runs.
|
||||
No account token is required in shell arguments, environment or repository.
|
||||
|
||||
## Migration and fallback
|
||||
|
||||
The migration exported the existing compiler image, verified the transfer
|
||||
archive SHA-256 and loaded image ID, stopped the laptop daemon, then streamed
|
||||
its existing registration directly from Docker Desktop through pinned SSH into
|
||||
the remote Docker volume using `import-identity.sh`. The import refuses to
|
||||
overwrite an identity. It is a one-time operation; do not rerun it here.
|
||||
Original laptop volumes and images remain intact.
|
||||
|
||||
To return temporarily to the laptop, first stop the remote runner while idle,
|
||||
then use `gitea/local-runner/runner.ps1 -Action Start -AllowLaptopFallback`.
|
||||
Stop the laptop copy before restarting the remote one. Never connect both
|
||||
copies of the registration. The label intentionally remains `latex-local`.
|
||||
|
||||
After grading, only when instructed, retain needed evidence, stop this runner
|
||||
and remove only its explicitly identified container, network and state volume.
|
||||
Retire the Gitea registration only when no fallback is needed. Never prune the
|
||||
host or remove shared Gitea/Jenkins/proxy/monitoring state.
|
||||
|
||||
Source for image/state handling:
|
||||
[Gitea Docker installation](https://docs.gitea.com/runner/2/installation/docker/).
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Pause fetching new jobs when the shared host has less than 600 MiB available.
|
||||
# This is admission control, not a reservation or cross-engine execution lock.
|
||||
set -eu
|
||||
awk '/^MemAvailable:/ { found=1; if ($2 < 614400) exit 1 } END { if (!found) exit 1 }' /proc/meminfo
|
||||
@@ -0,0 +1,32 @@
|
||||
name: ssw590-manual-runner
|
||||
services:
|
||||
runner:
|
||||
image: docker.io/gitea/runner@sha256:66d80966792e621c9761c47919644198d35fd1c297e9a01e69ed3c1ae37db0c7
|
||||
container_name: ssw590-manual-runner
|
||||
working_dir: /data
|
||||
entrypoint: ["gitea-runner"]
|
||||
command: ["--config", "/config.yaml", "daemon"]
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 70s
|
||||
environment:
|
||||
GOMEMLIMIT: 128MiB
|
||||
volumes:
|
||||
- runner-data:/data
|
||||
- ./config.yaml:/config.yaml:ro
|
||||
- ./admission-check.sh:/admission-check.sh:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
mem_limit: 192m
|
||||
memswap_limit: 256m
|
||||
cpus: 0.25
|
||||
pids_limit: 128
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
cap_drop: ["ALL"]
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
volumes:
|
||||
runner-data:
|
||||
external: true
|
||||
name: ssw590-local-runner-data
|
||||
@@ -0,0 +1,24 @@
|
||||
log:
|
||||
level: info
|
||||
runner:
|
||||
file: /data/.runner
|
||||
capacity: 1
|
||||
timeout: 30m
|
||||
shutdown_timeout: 60s
|
||||
insecure: false
|
||||
labels:
|
||||
- "latex-local:docker://ssw590-manual-ci:20261007"
|
||||
cache:
|
||||
enabled: false
|
||||
container:
|
||||
privileged: false
|
||||
valid_volumes: []
|
||||
docker_host: "-"
|
||||
force_pull: false
|
||||
options: "--memory=512m --memory-swap=768m --cpus=0.5 --pids-limit=256 --cap-drop=ALL --security-opt=no-new-privileges"
|
||||
health_check:
|
||||
enabled: true
|
||||
min_free_disk_space_mb: 3072
|
||||
script: /admission-check.sh
|
||||
interval: 15s
|
||||
timeout: 5s
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# Root-operated, one-time stdin import. Never print or stage registration in Git.
|
||||
set -eu
|
||||
test "$(id -u)" = 0
|
||||
docker volume create ssw590-local-runner-data >/dev/null
|
||||
docker run --rm -i --network none --user 0:0 --entrypoint sh \
|
||||
--mount type=volume,source=ssw590-local-runner-data,target=/data \
|
||||
docker.io/gitea/runner@sha256:66d80966792e621c9761c47919644198d35fd1c297e9a01e69ed3c1ae37db0c7 \
|
||||
-c 'set -eu; test ! -e /data/.runner; umask 077; cat > /data/.runner; test -s /data/.runner; chmod 700 /data; chmod 600 /data/.runner'
|
||||
echo 'Registration imported into protected Docker volume; values not printed.'
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# Root-operated reconnect only; an existing protected registration is required.
|
||||
set -eu
|
||||
cd /opt/ssw590-manual-runner
|
||||
docker image inspect ssw590-manual-ci:20261007 >/dev/null
|
||||
docker volume inspect ssw590-local-runner-data >/dev/null
|
||||
docker compose config --quiet
|
||||
docker compose run --rm -T --no-deps --entrypoint sh runner -c 'test -s /data/.runner'
|
||||
docker compose up -d
|
||||
docker compose ps
|
||||
@@ -0,0 +1,59 @@
|
||||
"""Read-only, non-secret runner/runtime checks. Run as root on The-Ocean."""
|
||||
import json
|
||||
import stat
|
||||
import subprocess
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def run(*args):
|
||||
return subprocess.check_output(args, text=True).strip()
|
||||
|
||||
|
||||
template = ('{"state":{{json .State}},"host":{{json .HostConfig}},'
|
||||
'"mounts":{{json .Mounts}},"image":{{json .Config.Image}},'
|
||||
'"restart_count":{{.RestartCount}}}')
|
||||
|
||||
|
||||
def inspect(name):
|
||||
# Fetch selected fields, never container environment variables.
|
||||
info = json.loads(run('docker', 'inspect', '--format', template, name))
|
||||
state, host = info['state'], info['host']
|
||||
return {
|
||||
'name': name, 'image': info['image'], 'running': state['Running'],
|
||||
'oom_killed': state['OOMKilled'], 'memory_bytes': host['Memory'],
|
||||
'restart_count': info['restart_count'],
|
||||
'memory_swap_bytes': host['MemorySwap'], 'nano_cpus': host['NanoCpus'],
|
||||
'restart_policy': host['RestartPolicy']['Name'],
|
||||
'port_bindings': host['PortBindings'],
|
||||
'mount_destinations': [mount['Destination'] for mount in info['mounts']],
|
||||
}
|
||||
|
||||
|
||||
root = Path(run('docker', 'volume', 'inspect', '--format', '{{.Mountpoint}}', 'ssw590-local-runner-data'))
|
||||
identity = root / '.runner'
|
||||
registration = json.loads(identity.read_text())
|
||||
assert registration.get('name') == 'ssw590-vince-local'
|
||||
assert registration.get('address', '').rstrip('/') == 'https://git.yebilly.me'
|
||||
assert isinstance(registration.get('token'), str) and registration['token']
|
||||
assert stat.S_IMODE(identity.stat().st_mode) == 0o600
|
||||
# Registration is checked in memory only. Do not serialize any of its values.
|
||||
report = {'observed_at': datetime.now(timezone.utc).isoformat(),
|
||||
'registration_validated_without_output': True, 'identity_mode': '0600',
|
||||
'runner': inspect('ssw590-manual-runner'), 'active_jobs': []}
|
||||
assert report['runner']['running'] and not report['runner']['oom_killed']
|
||||
for name in run('docker', 'ps', '--format', '{{.Names}}').splitlines():
|
||||
if name.startswith('GITEA-ACTIONS-TASK-'):
|
||||
job = inspect(name)
|
||||
assert job['memory_bytes'] == 512 * 1024 * 1024
|
||||
assert job['memory_swap_bytes'] == 768 * 1024 * 1024
|
||||
assert job['nano_cpus'] == 500000000
|
||||
assert '/var/run/docker.sock' not in job['mount_destinations']
|
||||
report['active_jobs'].append(job)
|
||||
report['admission_check'] = run('docker', 'exec', 'ssw590-manual-runner', 'sh', '-c', '/admission-check.sh && echo passed')
|
||||
report['compiler_image_id'] = run('docker', 'image', 'inspect', '--format', '{{.Id}}', 'ssw590-manual-ci:20261007')
|
||||
assert report['compiler_image_id'] == 'sha256:5d24657a4578977fc7709165b82fc869f09a654a58ab4a0c8defd9d2cd662d5d'
|
||||
report['memory'] = run('free', '-m')
|
||||
report['disk'] = run('df', '-h', '/')
|
||||
report['result'] = 'passed'
|
||||
print(json.dumps(report, indent=2))
|
||||
@@ -1,5 +1,12 @@
|
||||
# Local Gitea runner (Assignment 5 preparation)
|
||||
|
||||
**Current placement, 14 November 2026:** the active runner has moved to
|
||||
The-Ocean. This directory preserves the original laptop configuration and
|
||||
historical setup. See [`../droplet-runner/README.md`](../droplet-runner/README.md).
|
||||
The laptop copy is stopped; Register/Start now require `-AllowLaptopFallback`
|
||||
after stopping the remote copy. Never run both registrations simultaneously.
|
||||
The setup instructions below describe the original October installation.
|
||||
|
||||
Run from the repository root in PowerShell with Docker Desktop's Linux engine running:
|
||||
|
||||
```powershell
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[ValidateSet('Check', 'Register', 'Start', 'Logs', 'Stop')]
|
||||
[string]$Action = 'Check'
|
||||
[string]$Action = 'Check',
|
||||
[switch]$AllowLaptopFallback
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if ($Action -in @('Register', 'Start') -and -not $AllowLaptopFallback) {
|
||||
throw 'This runner now runs on The-Ocean. Stop the remote copy first, then pass -AllowLaptopFallback for an intentional laptop fallback. Never run both copies of the registration.'
|
||||
}
|
||||
$composeFile = Join-Path $PSScriptRoot 'compose.yaml'
|
||||
$composeArgs = @('compose', '--project-name', 'ssw590-local-runner', '-f', $composeFile)
|
||||
$runnerImage = 'docker.io/gitea/runner@sha256:66d80966792e621c9761c47919644198d35fd1c297e9a01e69ed3c1ae37db0c7'
|
||||
|
||||
@@ -14,7 +14,34 @@ discuss repository visibility with the other group member before publication.
|
||||
No registration token, runner identity file, private key, or account credential
|
||||
is copied. Hints-only Hosts/Passwords records are retained.
|
||||
|
||||
## Build and status
|
||||
## Local PDF for review and submission
|
||||
|
||||
From repository root, use the existing TinyTeX installation:
|
||||
|
||||
```powershell
|
||||
./manual/latex/makefilePowerShell.ps1 -Action pdf
|
||||
```
|
||||
|
||||
The helper detects the shared `../Tools/LaTeX/TinyTeX` installation. For a
|
||||
different existing installation, set `DEVOPS_LATEX_BIN` to its `bin/windows`
|
||||
directory first. It runs the full bibliography, glossary, acronym, index,
|
||||
and cross-reference sequence and replaces
|
||||
`manual/2026F-SSW-590-DevOps-Group-1.pdf`. That PDF and compiler intermediates
|
||||
are ignored by Git; sources and evidence remain versioned. Docker and an
|
||||
Actions artifact download are unnecessary for this local build. Local builds
|
||||
show the human document version without claiming an Actions run number.
|
||||
|
||||
After reviewing the PDF, remove generated LaTeX intermediates with:
|
||||
|
||||
```powershell
|
||||
./manual/latex/makefilePowerShell.ps1 -Action clean
|
||||
```
|
||||
|
||||
The PDF is retained. Continue using Gitea Actions for automated build evidence;
|
||||
keep historical run artifacts already required by the manual. New local
|
||||
revisions reuse this one PDF rather than creating more run folders.
|
||||
|
||||
## Historical Assignment 5 build evidence
|
||||
|
||||
See [compiler and workflow instructions](../ci/manual/README.md).
|
||||
Gitea run 1 succeeded for commit `828f6c5` (issue #12), including checkout,
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
This group document records the SSW 590 coursework and its supporting
|
||||
commands, designs, and evidence. Assignment 6 adds continuous integration:
|
||||
a Jenkins LTS controller runs beside Gitea on the DigitalOcean droplet,
|
||||
reachable at \url{https://ci.yebilly.me/login} from approved networks only.
|
||||
A Gitea pull request triggers a private webhook; Jenkins tests the pull
|
||||
request's latest head commit with a versioned \texttt{Jenkinsfile} and
|
||||
reports a named status check that branch protection requires before merge.
|
||||
A deliberate unit-test failure blocked pull request \#15, a repair passed,
|
||||
and the change was reviewed and merged. Earlier chapters retain the group's
|
||||
prior assignment results, including the Gitea Actions manual build.
|
||||
commands, designs, and evidence. Assignment 8 prepares secure delivery with
|
||||
a trusted Jenkins agent, locked Flask/Gunicorn service, security gates,
|
||||
Ansible, scoped deployment credentials and recovery runbooks. The prerequisite
|
||||
job passed; reviewed v1/v2 publication, DNS/TLS, promotion, rollback and staging
|
||||
recovery remain pending. This draft is not ready for submission.
|
||||
Assignment 7 introduced site reliability
|
||||
engineering: Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter
|
||||
run as four pinned containers beside Gitea and Jenkins on the originally 1\,GiB
|
||||
DigitalOcean droplet, with Grafana at \url{https://metrics.yebilly.me/login}
|
||||
for approved networks only. A dashboard shows host CPU, memory, and disk and
|
||||
the HTTPS availability of Gitea and Jenkins. A 99\% availability objective is
|
||||
defined and measured, and three alert rules (service availability, disk
|
||||
space, and collection health) notify the team's Discord channel. Each was
|
||||
shown firing and resolving; the availability rule through a planned Jenkins
|
||||
outage that was detected in about two minutes and recovered about a minute
|
||||
after restart. Earlier chapters retain the group's prior assignment
|
||||
results, including the Jenkins merge gate and the Gitea Actions manual build.
|
||||
On November 14 the team resized the droplet to 2\,GiB without enlarging its
|
||||
disk, updated packages and verified the existing services.
|
||||
|
||||
@@ -647,3 +647,291 @@ the report. Vincent then tested from campus Wi-Fi \texttt{Stevens-Net}
|
||||
his screenshots into one figure, blurring the password field and profile
|
||||
icon. A friend reportedly on campus saw a blank page (the 403); his network
|
||||
and address were not recorded, so no conclusion is drawn from it.
|
||||
|
||||
\section{Assignment 6 Run-9 Review and Final Corrections}
|
||||
Date: October 23, 2026; Tool: OpenAI Codex; Human: Vincent Sun.
|
||||
Inputs: Vincent's request to review the run-9 PDF, instructor manual version
|
||||
1.38, the repository's AI guidance, public Gitea commit/status/review records,
|
||||
and Vincent's approval to correct the documentation while leaving the three
|
||||
theme plugins unchanged. Codex reviewed the Jenkins chapter, updated tables,
|
||||
history, and AI records visually; checked the artifact ZIP and PDF links;
|
||||
and confirmed the recorded failed/repaired statuses, approval, and merge
|
||||
against Gitea. A read-only HTTPS check returned the Jenkins sign-in page
|
||||
with certificate verification passing. No authenticated Jenkins inspection
|
||||
or new droplet experiment was performed during this review.
|
||||
|
||||
Human/AI corrections: the PDF linked a 60-plugin lockfile at the initial
|
||||
deployment merge while describing the later 63-plugin set. Codex changed
|
||||
that link to the recorded revision \texttt{ac18f11}, retaining historical
|
||||
PR and run links. It clarified that \emph{Build Now} uses the revision
|
||||
selected for that run and does not establish a clean workspace or the same
|
||||
commit as an earlier run; clean local reproduction now calls for a fresh
|
||||
clone and the recorded commit ID. It separated the observed delivery timeout
|
||||
from the suspected CPU/discovery cause and made timeout tuning conditional.
|
||||
At Vincent's direction, the theme plugins were left unchanged; the existing
|
||||
security-check result is explicitly limited to its 63 checked versions.
|
||||
|
||||
Outputs used: these corrections in \ChapterRef{JenkinsCI}, version 4.2,
|
||||
the dated Document History entry, and this record. Prior Billy/Claude
|
||||
records and original run-9 evidence are preserved. Hosts and Passwords
|
||||
tables are unchanged because no deployed service, account, or credential
|
||||
changed. The revision is checked through the complete local TinyTeX build,
|
||||
diagnostic inspection, and visual review of the affected PDF pages.
|
||||
No commit, push, remote configuration change, or submission is performed
|
||||
as part of this correction.
|
||||
|
||||
\section{Assignment 7 Monitoring Deployment, Tests, and Chapter}
|
||||
Date: October 27--28, 2026; Tool: Anthropic Claude Code (Claude Opus 5.5);
|
||||
Human: Billy Ye, with Vincent Sun as verifier and reviewer.
|
||||
Inputs: instructor manual version 1.42 (Chapter 5), found in Billy's
|
||||
downloads after Billy asked to implement ``chapter 5 of this manual''; the
|
||||
repository and its AI guidance; Billy's decisions (measure capacity before
|
||||
any resize and then try a capped deployment on the 1\,GiB plan, alerts to a
|
||||
Discord webhook, hostname \texttt{metrics.yebilly.me}, Claude running droplet
|
||||
commands over SSH with Billy approving each step, disabling four unused host
|
||||
services after Claude showed the disk and boot checks); Billy's DNS record,
|
||||
Discord channel and webhook, issue \#19, secrets file, Grafana login,
|
||||
screenshots, pushes, and improvement issues \#20 and \#21.
|
||||
|
||||
Claude synced both checkouts, measured the baseline, chose and verified
|
||||
pinned image digests, wrote the \texttt{monitoring/} configuration, the
|
||||
Caddy and Compose changes, the dashboard, alert rules, and README runbooks;
|
||||
validated them locally (Compose, \texttt{promtool}, \texttt{caddy validate},
|
||||
and a throwaway Grafana run); deployed them after backing up the Caddy files;
|
||||
ran the exposure, contact-point, capacity-alert, outage, persistence, and SLO
|
||||
queries; and wrote \ChapterRef{SREMonitoring}, the Hosts and Passwords
|
||||
updates, glossary terms, title page, abstract, and Document History. Billy
|
||||
typed every secret himself: Claude never saw the Grafana password or the
|
||||
webhook URL. API calls read the password from the Grafana container's
|
||||
environment without printing it.
|
||||
|
||||
Human/AI corrections: the local Grafana run rejected an alert template
|
||||
written with \texttt{\$\$labels}; the deployed Grafana could not read its
|
||||
configuration after the Windows upload (fixed with \texttt{chmod}); Grafana~13
|
||||
had removed the old contact-point test endpoint, so the replacement was found
|
||||
from its own error message; one Grafana login from Claude failed because a
|
||||
password was read from the file with untrimmed whitespace; the first
|
||||
build-check before the outage matched the \texttt{ps} header and aborted
|
||||
before anything was stopped; one SLO query was first evaluated at the wrong
|
||||
time and was rerun; Billy's partial home IP address was removed from the
|
||||
evidence file before commit; the push from Claude's shell failed
|
||||
authentication, so Billy pushed and re-authorized Git Credential Manager.
|
||||
Billy's questions about the CPU readings led to the I/O-wait finding and the
|
||||
dashboard change.
|
||||
|
||||
Review and corrections: at Billy's request, Claude had an independent
|
||||
subagent audit the chapter against the instructor's requirements. Claude
|
||||
checked its findings against the evidence (two of its ``unsupported''
|
||||
claims were supported by earlier output and a figure) and, with Billy's
|
||||
approval, added a collection-health rule and tested it by stopping Blackbox
|
||||
Exporter, ran Blackbox Exporter as non-root, compared CPU counters with
|
||||
\texttt{/proc/stat}, and corrected four figures and the overstated
|
||||
no-data claim. Billy replaced the Grafana administrator password himself;
|
||||
Claude confirmed the old value was rejected and removed it from the
|
||||
secrets file without printing it.
|
||||
|
||||
Outputs used: commits \texttt{d3a5e6b} and \texttt{b6cf080}, the chapter
|
||||
commits on \texttt{feature/issue-19-monitoring} (PR \#22);
|
||||
\texttt{monitoring/EVIDENCE.md}; \ChapterRef{SREMonitoring}; this record.
|
||||
Assumptions and unresolved items: the title-page assignment title comes
|
||||
from the Canvas page Billy showed (``\#7 Grafana and Promethous SRE --
|
||||
Group''), with the spelling of Prometheus corrected; the acknowledgement was given to Claude before the restart, and
|
||||
Billy's Discord reply came later; Billy created Vincent's Grafana
|
||||
account \texttt{vsun1} as Viewer; the 24-hour SLO was not evaluated; the manual-PDF build needs
|
||||
Vincent's runner when the branch is merged. No pull request, merge, or
|
||||
submission was performed by Claude.
|
||||
|
||||
\section{Assignment 7 Run-11 Review, TCP Evidence, and Final Corrections}
|
||||
Date: October 28, 2026; Tool: OpenAI Codex; Human: Vincent Sun.
|
||||
Inputs: Vincent's request to double-check Billy's completed Assignment 7,
|
||||
instructor manual version 1.42 Chapter 5, the run-11 artifact, repository AI
|
||||
guidance, versioned monitoring configuration and evidence, and public Gitea
|
||||
statuses and reviews. Vincent authorized the corrections and requested one
|
||||
locally compiled PDF in the repository, excluded from Git. Codex inspected
|
||||
the chapter and supporting figures, compared configuration and dashboard
|
||||
queries with the rubric, and verified the final PR head, approval, merge,
|
||||
and successful run-11 status. Chrome connected to Gitea; a subsequent
|
||||
project-tab operation timed out, so no authenticated Jenkins/Grafana audit
|
||||
or remote settings change was performed in this correction.
|
||||
|
||||
Human/AI corrections: Codex identified changing branch links, incomplete TCP
|
||||
evidence from HTTP code 000, outdated review timestamps, and conclusions
|
||||
stronger than the timing, sampling, or resource measurements supported.
|
||||
Vincent ran the supplied external PowerShell loop on his laptop and moved
|
||||
its CSV into the repository's ignored evidence directory. All 18 outcomes
|
||||
matched: TCP 80/443 succeeded and seven private ports failed on both IPv4
|
||||
and IPv6. Codex preserved the raw file and made a versioned copy replacing
|
||||
only the local Wi-Fi name with a generic network description. The reusable
|
||||
script preserves that loop with parameters; its syntax is checked without
|
||||
claiming another network test. The CSV timestamps are completion times.
|
||||
|
||||
Outputs used: version 5.1; the new TCP table and reproduction command;
|
||||
deployment links pinned to merge \texttt{34c4c74}; final approval/check and
|
||||
run-11 links; qualified notification-delay, missing-sample, and memory-pressure
|
||||
conclusions; a Document History entry; and this record. The local build helper
|
||||
now discovers the shared TinyTeX path from the actual repository nesting;
|
||||
local build instructions and PDF ignore rules retain one replaceable PDF.
|
||||
The complete TinyTeX build includes the bibliography, glossary, acronym list,
|
||||
index, and final reference passes, followed by diagnostic and visual review.
|
||||
Billy/Claude records and original evidence are preserved. Hosts and Passwords
|
||||
tables are unchanged because no deployed service, account, or credential
|
||||
changed. The missed pre-deployment build observation remains a limitation;
|
||||
later results do not recreate it. Commits, pushes, peer approval, and submission
|
||||
remain with the group. This local revision is not described as an Actions
|
||||
artifact or as already approved in Gitea.
|
||||
|
||||
\section{Assignment 8 Secure Delivery Preparation and Agent Setup}
|
||||
Date: November 14, 2026; Tool: OpenAI Codex; Human: Vincent Sun.
|
||||
Inputs: Vincent's request to implement the next assignment today, instructor
|
||||
manual 1.43 Chapter 6 and Examples.zip, the Canvas assignment page, repository
|
||||
AI requirements/guide, earlier configuration, and live read-only service checks.
|
||||
Vincent retained commits/pushes and reported Billy unavailable until tonight.
|
||||
Codex read the assignment, preserved prior work, verified remote main
|
||||
\texttt{8beefde}, and created \texttt{codex/assignment8-secure-delivery}.
|
||||
It adapted the instructor's v1 and Ansible starters, locked dependencies and
|
||||
tool images, prepared a dedicated delivery pipeline, scan policy, immutable
|
||||
release validation, idempotence gate, failure modes, observer and runbooks.
|
||||
The original instructor authorship remains identified.
|
||||
|
||||
Human/AI corrections and execution: Vincent supplied his encrypted-key SSH
|
||||
command and enabled Windows ssh-agent, initially also unloading the key; Codex
|
||||
explained reloading it and keeping passphrases out of chat. Browser-console
|
||||
and network limitations were distinguished from successful access. Vincent
|
||||
resized The-Ocean to 2\,GiB while retaining disk size and applied host updates;
|
||||
Codex verified resource and existing-service status. With authorization to
|
||||
continue setup, Codex backed up Jenkins/Gitea, configured the restricted deploy
|
||||
key and root sudo, separate package-scoped tokens under vsun1, folder-scoped
|
||||
Jenkins credentials, exclusive laptop agent and disabled release job. Secret
|
||||
values were transferred only through protected runtime storage and were not
|
||||
printed or placed in Git. Agent prerequisite build 1 passed with real credential
|
||||
binding, strict SSH host-key checking and noninteractive sudo.
|
||||
|
||||
Checks/corrections: local v1 tests passed; a generated wrong-price test failed
|
||||
as intended; the scanner-supported synthetic fixture blocked delivery; the
|
||||
dependency audit and final runtime-image gate passed their configured policies.
|
||||
Earlier Debian and installer-containing Alpine scans failed and were retained;
|
||||
Codex selected the Alpine runtime and removed unused pip/ensurepip without
|
||||
adding scanner exceptions. The installed Jenkins parser rejected the initial
|
||||
timestamps option because its plugin is absent; Codex removed that option and
|
||||
retained explicit UTC evidence. Browser editor insertion briefly concatenated
|
||||
two validation snippets; the editor was cleared and the read-only validation
|
||||
repeated successfully. The host setup script compiled against installed plugin
|
||||
classes before application. Ansible syntax and agent Compose checks passed.
|
||||
|
||||
Outputs used: \ChapterRef{SecureDelivery}, version 6.0 preparation, the adapted
|
||||
application/toolchain, pipeline and control tests, bootstrap, runbooks, issue
|
||||
draft, planned proxy and production-monitoring additions, actual prerequisite
|
||||
inventory, Hosts/Passwords hints, history and this record. Existing Billy/Claude
|
||||
records are unchanged. Source/configuration release SHAs and registry digests
|
||||
have not been invented. The local preflight image explicitly identifies itself
|
||||
as uncommitted preparation, not a reviewed release.
|
||||
|
||||
Unresolved items: application DNS requires the domain owner's access; distinct
|
||||
names are explicitly required, so path-only routing was rejected as a substitute.
|
||||
Vincent/Billy must create the issue, commit/push and review/merge v1 and later
|
||||
changes. Real Jenkins blocked-gate runs, v1/v2 publication, interactive production
|
||||
approvals, idempotence, both recovery exercises, timing/monitoring correlation
|
||||
and final submission review remain pending. Proxy/monitoring additions are not
|
||||
deployed before DNS and healthy production. No commit, push, peer review,
|
||||
production approval or submission was performed by Codex.
|
||||
|
||||
Later on November 14, Vincent explicitly authorized Codex to make the local
|
||||
preparation commit \texttt{bf28adc}; Vincent pushed it, and Codex verified the
|
||||
remote branch and passing Jenkins head check. At Vincent's further request,
|
||||
Codex prepared \path{delivery/BILLY-CLAUDE-DNS-HANDOFF.md} for Billy/Claude,
|
||||
including the two selected A records, Namecheap instructions checked against
|
||||
official documentation, current public DNS observations, verification commands
|
||||
and a DNS-only boundary. The provider's default nameservers and existing
|
||||
Gitea/Jenkins/Grafana A records were observed; the two new names still returned
|
||||
NXDOMAIN. No DNS setting was changed, and the handoff itself grants no account
|
||||
authorization. Billy must authorize DNS work in his own session.
|
||||
|
||||
Later that evening, Vincent directed moving the delivery agent onto the now
|
||||
2\,GiB droplet because campus Wi-Fi had blocked SSH and the final presentation
|
||||
must demonstrate the workflow. Codex checked repository state and host capacity,
|
||||
transferred the existing tool image with matching archive SHA-256 and image ID,
|
||||
stopped the laptop copy, and reused the protected node identity on The-Ocean.
|
||||
It added a private WebSocket route, host-gateway SSH mapping with the existing
|
||||
pinned key alias, 512/768 MiB agent and 256/384 MiB BuildKit RAM/RAM+swap caps,
|
||||
half a CPU each, a guarded laptop fallback and versioned verification helpers.
|
||||
The first builder setup exposed a socket-group mismatch (laptop 0, host 987);
|
||||
the helper was corrected to detect the host group, and Docker access succeeded.
|
||||
The first browser build request used stale session state; reloading allowed the
|
||||
existing preflight job to run. Build 2 passed with real credential binding,
|
||||
strict SSH verification and sudo. A separate 87-second preparation trial passed
|
||||
control/app tests, source/dependency checks, capped build, full image gate and
|
||||
temporary HTTP smoke. Swap increased and agent memory-limit events occurred;
|
||||
no OOM kill was recorded. Existing services passed private HTTP checks, and
|
||||
agent restart/reconnect passed. This does not establish full release performance.
|
||||
An initial CLI artifact download returned HTTP 403; evidence was retrieved over
|
||||
authorized SSH instead. A complex shell diagnostic had a quoting error and was
|
||||
replaced by a versioned read-only Python check. No credential values were output.
|
||||
|
||||
Codex updated the diagram, current host/credential hints, runbooks, DNS handoff,
|
||||
preparation evidence, history and this log, and rebuilt/reviewed the local manual.
|
||||
The older PDF runner remains on the laptop; campus browser access still needs
|
||||
rehearsal. Shared-host Docker administration is an explicit lab trade-off.
|
||||
No firewall rule, credential scope, review requirement or production approval
|
||||
was relaxed. DNS, assessed releases and recovery exercises remain pending.
|
||||
No additional commit or push was authorized or performed for this migration.
|
||||
|
||||
\section{Actions Runner Migration for the Presentation}
|
||||
Date requested: November 14, 2026; Tool: OpenAI Codex; Human: Vincent Sun.
|
||||
Vincent then explicitly requested moving the first (Gitea Actions) runner to
|
||||
the droplet too. Codex read the runner/workflow sources and repository rules,
|
||||
checked headroom, and transferred the tested compiler image with matching
|
||||
archive checksum and image ID. It stopped the idle laptop daemon before
|
||||
streaming the existing registration over pinned SSH into protected Docker
|
||||
storage. No registration value was printed, staged in the repository, or
|
||||
replaced; the legacy name/label and repository scope were preserved.
|
||||
|
||||
Codex added versioned remote Compose, admission, reconnect/import and read-only
|
||||
verification helpers plus a guarded laptop fallback. The first 96 MiB daemon
|
||||
cap was too low: a real OOM event and restart occurred during action setup.
|
||||
Codex canceled that attempt, retained its log and runtime evidence, raised
|
||||
the daemon to 192/256 MiB RAM/RAM+swap with 0.25 CPU, and retried. Separate
|
||||
compiler job limits remained 512/768 MiB and 0.5 CPU. Run 12 attempt 3, job 14,
|
||||
passed checkout, compilation and both uploads in 4m32s. It used reviewed main
|
||||
\texttt{8beefde}, not the uncommitted Assignment 8 source. After a browser
|
||||
download-wait timeout and debugger detachment, Vincent supplied diagnostics
|
||||
in run-12. Codex retrieved the exact PDF through read-only artifact metadata
|
||||
and storage over SSH, verified its checksum against those diagnostics, and
|
||||
visually checked \texttt{5.1+build.12.8beefde}. This does not demonstrate the
|
||||
pending application releases or recovery exercises.
|
||||
|
||||
The corrected daemon had no restart during the successful run; idle restart
|
||||
and declaration succeeded at 04:55:52 UTC on November 15. Codex identified
|
||||
the canceled job's orphaned resources for cleanup, preserved registration and
|
||||
shared services, and updated operations, migration evidence, host/credential
|
||||
hints, history and this record. Both active runners are on The-Ocean; no new
|
||||
cloud instance or resize was made. Resource admission does not coordinate
|
||||
Jenkins, so manual builds and delivery releases must run sequentially. Shared
|
||||
Docker authority remains a documented trust trade-off. Campus browser rehearsal,
|
||||
DNS and assessed delivery remain pending. No further commit or push was requested.
|
||||
|
||||
\section{DNS, HTTPS and Team Account Check}
|
||||
Date: November 15, 2026; Tool: OpenAI Codex; Human: Vincent Sun; DNS: Billy Ye.
|
||||
Vincent reported that Billy had added the records but HTTPS was unavailable,
|
||||
and asked for server-side correction. Codex checked repository instructions,
|
||||
status, official Caddy HTTPS documentation, live DNS, proxy configuration and
|
||||
container state. It verified that the prepared routes were absent and app
|
||||
backends undeployed. A guarded helper first stopped on CRLF/LF comparison;
|
||||
normalizing only line endings confirmed the earlier routes matched. Codex
|
||||
validated the candidate, saved a protected backup and gracefully reloaded Caddy
|
||||
while preserving the bind inode, prior routes, allowlists and certificate state.
|
||||
Google/Cloudflare answers and normal curl/Python checks verified DNS, trusted
|
||||
hostname-matching TLS and HTTP 308 redirects. HTTPS 502 was correctly recorded
|
||||
as missing backend deployment, not a certificate failure or healthy release.
|
||||
Existing service checks passed. No DNS account, firewall or application release
|
||||
was changed; production monitoring remains pending.
|
||||
|
||||
Vincent also requested a team-account check for access recovery. Codex queried
|
||||
only account IDs/status/role flags and Jenkins profile-header IDs, never password
|
||||
hashes, tokens or email fields. The expected Billy accounts were present, and
|
||||
the existing vsun1 Gitea site-admin role was confirmed and corrected in the
|
||||
hints table. Grafana's vsun1 remains Viewer. No password was recovered or reset,
|
||||
and no permission was changed. Codex explained the distinction between checking
|
||||
an account, recovering a password-manager copy and resetting an existing login.
|
||||
It updated current readiness records, the preserved DNS handoff, history and
|
||||
this log, then rebuilt and visually checked the local manual. Source changes
|
||||
remain uncommitted; peer review, app releases, approvals and recoveries remain pending.
|
||||
|
||||
@@ -34,16 +34,16 @@
|
||||
\definecolor{devopsLightBlue}{RGB}{232,240,247}
|
||||
|
||||
% Replace these values for each assignment.
|
||||
\newcommand{\AssignmentTitle}{Gitea + Jenkins Autobuild and Testing -- Group}
|
||||
\newcommand{\AssignmentNumber}{6}
|
||||
\newcommand{\DocumentVersion}{4.1}
|
||||
\newcommand{\AssignmentTitle}{Secure Delivery and Rollback -- Group}
|
||||
\newcommand{\AssignmentNumber}{8}
|
||||
\newcommand{\DocumentVersion}{6.0}
|
||||
\newcommand{\DocumentStatus}{Draft}
|
||||
\newcommand{\CourseNumber}{SSW 590}
|
||||
\newcommand{\CourseName}{DevOps}
|
||||
\newcommand{\Authors}{Vincent Sun and Billy Ye}
|
||||
\newcommand{\Organization}{Stevens Institute of Technology}
|
||||
\newcommand{\DocumentDate}{10/23/2026}
|
||||
\newcommand{\DueDate}{Friday by 11:59pm}
|
||||
\newcommand{\DocumentDate}{11/15/2026}
|
||||
\newcommand{\DueDate}{November 13, 2026 (team reports an extension)}
|
||||
% CI writes this ignored file in its checkout; ordinary local builds stay unchanged.
|
||||
\providecommand{\CIBuildSuffix}{}
|
||||
\InputIfFileExists{ci-build-metadata.tex}{}{}
|
||||
@@ -147,11 +147,13 @@
|
||||
\include{devopsGitea}
|
||||
\include{devopsAutomatedManualBuild}
|
||||
\include{devopsJenkins}
|
||||
\include{devopsSRE}
|
||||
\include{devopsSecureDelivery}
|
||||
\include{devopsHostsPasswords}
|
||||
|
||||
% Restore when a chapter cites devopsReferences.bib.
|
||||
%\bibliographystyle{IEEEtran}
|
||||
%\bibliography{devopsReferences}
|
||||
\bibliographystyle{IEEEtran}
|
||||
\bibliography{devopsReferences}
|
||||
|
||||
\appendix
|
||||
\include{devopsDocumentGuide}
|
||||
|
||||
@@ -42,6 +42,9 @@ The runner requests work from the same HTTPS service and has no public
|
||||
submission listener.
|
||||
|
||||
\section{Runner Setup}
|
||||
This section preserves the October 7 setup. The November migration recorded
|
||||
at the end of this chapter supersedes its laptop placement and start procedure.
|
||||
|
||||
The repository-scoped \gls{build-runner} \texttt{ssw590-vince-local}, version 2.3.0,
|
||||
runs as Docker container \texttt{ssw590-local-runner} on Vincent's Windows
|
||||
laptop using Docker Desktop's Linux engine. Its \texttt{latex-local} label
|
||||
@@ -353,4 +356,38 @@ was merged and issue \#12 is closed (re-checked in Gitea on October 22), and
|
||||
the merged-\texttt{main} workflow run~6 passed (verified by Vincent on
|
||||
October 21). The paragraph above is kept as the version 3.4 record.
|
||||
|
||||
\section{November 2026 Runner Migration}
|
||||
On November 14 Vincent requested moving this runner to the existing 2\,GiB
|
||||
The-Ocean droplet for the final demonstration. Codex stopped the laptop daemon,
|
||||
transferred the same compiler image with archive checksum and image-ID checks,
|
||||
and streamed the existing registration over pinned SSH directly into a protected
|
||||
Docker volume. No registration value entered the repository or output. The
|
||||
historical name \texttt{ssw590-vince-local} and label \texttt{latex-local} remain;
|
||||
the active container is \texttt{ssw590-manual-runner}. Repository scope is unchanged.
|
||||
|
||||
The first 96 MiB daemon trial exceeded its memory cap during action setup and
|
||||
restarted. Its attempt was canceled and retained as failure evidence. With the
|
||||
daemon raised to 192 MiB RAM / 256 MiB RAM+swap and 0.25 CPU, the
|
||||
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/actions/runs/12/jobs/14}{run 12 attempt 3 job}
|
||||
passed checkout, compilation and both uploads in 4m32s (compilation 1m42s).
|
||||
It rebuilt reviewed main commit \texttt{8beefde}, not Assignment 8's uncommitted
|
||||
preparation. Diagnostics and the retrieved PDF checksum match; the opened title
|
||||
shows \texttt{5.1+build.12.8beefde}. This is migration evidence, not an Assignment 8 release.
|
||||
|
||||
Compiler jobs have separate 512/768 MiB RAM/RAM+swap, 0.5 CPU and 256 PID
|
||||
caps. No host port or job Docker socket mount is added. TLS checks remain
|
||||
enabled. New-job admission pauses below 600 MiB available host RAM or 3 GiB
|
||||
free disk; it does not reserve resources or coordinate Jenkins. Run manual
|
||||
builds and delivery releases sequentially. The runner still has administrative
|
||||
Docker authority over the shared host, so workflow editors remain trusted.
|
||||
|
||||
The daemon uses \texttt{unless-stopped}; idle restart/reconnect passed at
|
||||
04:55:52 UTC on November 15 (the request was November 14 Eastern).
|
||||
\path{gitea/droplet-runner/README.md} records operations and fallback;
|
||||
\path{gitea/droplet-runner/EVIDENCE.md} links the dated evidence. The original
|
||||
laptop identity/image are retained but inactive. Its helper requires
|
||||
\texttt{-AllowLaptopFallback} after stopping the remote copy. VS maintains the
|
||||
runner and BY the host; no new cloud instance or resize was made. Hosts and
|
||||
hints-only Passwords tables reflect current placement.
|
||||
|
||||
\endgroup
|
||||
|
||||
@@ -12,6 +12,13 @@ link each entry to the changed chapter, table, figure, or controlled artifact.
|
||||
\multicolumn{4}{l}{\small\itshape Document Update History (continued)}\\
|
||||
\toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule
|
||||
\endhead \bottomrule \endlastfoot
|
||||
November 15, 2026 / 6.0 DNS and TLS readiness & BY, VS, CDX & Billy added staging/app DNS. Codex validated and gracefully applied the prepared Caddy routes, preserving prior services and storage; verified public DNS, trusted TLS and HTTP redirects. Recorded expected 502 responses while app backends remain undeployed. Updated current DNS/HTTPS inventory and the verified vsun1 Gitea administrator role. No passwords, permissions or releases changed. & \ChapterRef{SecureDelivery}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\
|
||||
November 14, 2026 / 6.0 Actions runner migration & VS, CDX & Moved the existing manual runner and compiler image to The-Ocean without re-registration. Corrected an initial low-memory failure, verified reviewed-main run 12 attempt 3, artifact checksum/title and idle restart. Added daemon/job caps, admission checks and fallback guards; updated current host/credential hints and retained October evidence. Both active runners now use the droplet. & \ChapterRef{AutomatedManualBuild}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\
|
||||
November 14, 2026 / 6.0 agent migration & VS, CDX & At Vincent's direction, moved the trusted delivery agent to the existing 2\,GiB droplet to remove campus SSH dependence. Added agent and builder resource caps, private deployment routing with pinned host verification, restart/fallback procedures, preflight build 2 and a passing bounded build/scan/smoke trial. Documented shared-host Docker authority, swap use and the unchanged laptop PDF runner. Updated the architecture, Hosts and hints-only Passwords tables, handoff and AI log; assessed releases and campus browser rehearsal remain pending. & \ChapterRef{SecureDelivery}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\
|
||||
November 14, 2026 / 6.0 preparation & VS, CDX & Prepared Assignment 8 with instructor v1 source, exact dependencies/base digest, trusted laptop Jenkins agent, security gates, Ansible, restricted production approval and recovery automation. Recorded actual local checks and passing agent prerequisite build 1. Vincent resized the droplet to 2\,GiB and updated packages; Codex configured deployment access, folder-scoped credentials and a disabled release job after backups. Added planned proxy/monitoring changes, architecture and runbooks. Updated Hosts and hints-only Passwords tables. Reviewed release commits, DNS/TLS, v1/v2 promotion, both recoveries and final evidence remain pending; this is a preparation draft. & \ChapterRef{SecureDelivery}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\
|
||||
October 28, 2026 / 5.1 & VS, CDX & Reviewed run-11 against instructor Chapter 5; added Vincent's external IPv4/IPv6 TCP retest (18 expected outcomes), pinned deployment links to the reviewed merge, recorded final PR approval and CI/build results, and qualified timing, sampling, and memory-pressure conclusions. Documented local TinyTeX builds to one ignored PDF. Hosts and Passwords tables are unchanged because no deployed service, account, or credential changed. & \ChapterRef{SREMonitoring}, \ChapterRef{AIPromptLog}\\
|
||||
October 28, 2026 / 5.0 & BY, CD & Assignment 7: added \ChapterRef{SREMonitoring}. Deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter on The-Ocean (pinned by digest, memory-capped, no host ports) after a capacity trial on the 1\,GiB plan; disabled four unused host services and added a second swap file; added \texttt{metrics.yebilly.me} behind the Jenkins allowlist and a private probe network. Recorded the dashboard, normal-build comparison, SLI/SLO worked example and measured window, contact-point, capacity-alert, collection-health, and Jenkins-outage tests with Discord notifications, restart persistence, blameless review, and improvement issues \#20 and \#21. After an independent review of the draft: added the collection-health rule and its test, replaced the initial Grafana administrator password, ran Blackbox Exporter as non-root, and added runbooks, network and storage detail in the diagram, host CPU checks, a targets table, citations with a Bibliography, and four corrected figures. \textbf{Updated the Hosts table} (monitoring containers, ports, volumes, \texttt{metrics} DNS, swap, monitoring and backup status) and \textbf{the Passwords table} (Grafana accounts, monitoring secrets file, Discord webhook). Set the Assignment 7 title page and abstract; added glossary terms. & Title and abstract, \ChapterRef{SREMonitoring}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\
|
||||
October 23, 2026 / 4.2 & VS, CDX & Corrected the Jenkins lockfile link to the recorded 63-plugin revision; clarified clean reproduction, Jenkins revision selection, and the unconfirmed webhook-timeout cause. Scoped the existing update-check result to the 63 checked plugins. Theme plugins are unchanged at Vincent's direction. Hosts and Passwords tables are unchanged because no service, account, or credential changed. & \ChapterRef{JenkinsCI}, \ChapterRef{AIPromptLog}\\
|
||||
October 23, 2026 / 4.1 & BY, CD & Corrected the Jenkins instructor access path to the Stevens campus network, with off-campus graders' addresses added on request; recorded the GlobalProtect test showing the Stevens VPN is split-tunnel and therefore not an access path, and Vincent's passing campus test on \texttt{Stevens-Net}; added the real webhook delivery table and diagnosis of one timed-out delivery, UML stereotypes on the deployment diagram, the stored Jenkins URL, free disk space, reconciled plugin counts, and corrected wording on push rights, resource limits, and corrective actions. Shortened AI initials in this table (CDX for Codex, CD for Claude). Hosts and Passwords tables are unchanged. & \ChapterRef{JenkinsCI}, \ChapterRef{AIPromptLog}\\
|
||||
October 22--23, 2026 / 4.0 & BY, VS, CD & Assignment 6: ran the guarded Jenkins capacity test on the resized 1\,GiB droplet; deployed Jenkins 2.580.1 LTS with a hashed plugin lockfile behind Caddy at \texttt{ci.yebilly.me} (Stevens and team allowlist); integrated Gitea via a private webhook and the \texttt{jenkins-bot} identity; required check \texttt{vpn-dns-gateway/pipeline/pr-main} on \texttt{main}; recorded PR~\#15's pass, blocked failure, repair, review, and merge, the restart-persistence and IPv4/IPv6 exposure tests, and the plugin-update check. \textbf{Updated the Hosts table} (resize, Jenkins, \texttt{ci} DNS, Color Buttons retired) and \textbf{the Passwords table} (Jenkins administrators, \texttt{jenkins-bot} account and token, CI allowlist file). Added glossary terms, set the Assignment 6 title page and abstract, and noted the completed Assignment 5 merge. & Title and abstract, \ChapterRef{JenkinsCI}, \ChapterRef{HostsPasswords}, \ChapterRef{AutomatedManualBuild}, \ChapterRef{AIPromptLog}\\
|
||||
October 21, 2026 / preparation & VS, CDX & Recorded core-test timing qualification and the Billy/Claude handoff; prepared the plugin/pipeline test and verified it locally after separating plugin resolution from runtime. The droplet run remains unverified. Hosts and Passwords tables are unchanged because no persistent Jenkins service or real integration credential was added. & \ChapterRef{AIPromptLog}\\
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
\newacronym{cd}{CD}{continuous delivery or continuous deployment}
|
||||
\newacronym{iac}{IaC}{infrastructure as code}
|
||||
\newacronym{slo}{SLO}{service-level objective}
|
||||
\newacronym{sli}{SLI}{service-level indicator}
|
||||
\newacronym{sla}{SLA}{service-level agreement}
|
||||
\newacronym{sre}{SRE}{site reliability engineering}
|
||||
\newacronym{vpn}{VPN}{virtual private network}
|
||||
\newacronym{dns}{DNS}{Domain Name System}
|
||||
\newacronym{swot}{SWOT}{strengths, weaknesses, opportunities, and threats}
|
||||
@@ -30,3 +33,9 @@
|
||||
\newglossaryentry{jenkinsfile}{name={Jenkinsfile},description={A version-controlled file at the repository root that defines a Jenkins pipeline's stages and steps}}
|
||||
\newglossaryentry{controller}{name={controller},description={The central Jenkins server that serves the web interface, stores configuration, and schedules builds; it can also run builds on its own executors}}
|
||||
\newglossaryentry{build-agent}{name={build agent},description={A separate machine or container that connects to a Jenkins controller and runs builds, isolating build code from the controller}}
|
||||
|
||||
\newglossaryentry{error-budget}{name={error budget},description={The amount of failure an SLO still allows in its window; for a 99\% target over 2,880 probes, 28.8 failed probes}}
|
||||
\newglossaryentry{exporter}{name={exporter},description={A small service that exposes measurements of another system, such as a host or a probed website, in Prometheus format for scraping}}
|
||||
\newglossaryentry{scrape}{name={scrape},description={Prometheus's periodic HTTP request to a target's metrics endpoint, which records each returned value with a timestamp}}
|
||||
\newglossaryentry{contact-point}{name={contact point},description={A Grafana alerting destination, such as a Discord channel, that receives firing and resolved notifications}}
|
||||
\newglossaryentry{blameless-review}{name={blameless review},description={An incident review that records impact, timeline, cause, and improvements without assigning personal blame}}
|
||||
|
||||
@@ -15,59 +15,113 @@ October 22--23, 2026 (\ChapterRef{JenkinsCI}) the droplet record was updated
|
||||
for the 1\,GiB resize, the Jenkins service, and \texttt{ci.yebilly.me}; the
|
||||
Color Buttons app was marked retired; and the Passwords table gained the
|
||||
Jenkins administrators, the \texttt{jenkins-bot} Gitea account, and its token.
|
||||
On October 28, 2026 (\ChapterRef{SREMonitoring}) the droplet record gained
|
||||
the four monitoring containers, \texttt{metrics.yebilly.me}, the second swap
|
||||
file, and real monitoring status; the Passwords table gained the Grafana
|
||||
accounts, the monitoring secrets file, and the Discord webhook.
|
||||
On November 14, 2026 (\ChapterRef{SecureDelivery}), Vincent resized the droplet
|
||||
to 2\,GiB and updated host packages. The tables gained deployment access and a
|
||||
trusted Jenkins agent. Later that evening the agent moved from the laptop to
|
||||
The-Ocean to avoid campus SSH restrictions. Vincent then requested migrating
|
||||
the original Actions runner too; both laptop daemons are now stopped, with
|
||||
their protected fallback state retained. On November 15 Billy added the pricing
|
||||
DNS records and Codex enabled Caddy HTTPS; certificates and redirects passed,
|
||||
while the undeployed application backends return 502.
|
||||
|
||||
\section{Hosts}
|
||||
\small
|
||||
\begin{tabularx}{\linewidth}{@{}L{3.3cm}Y@{}}
|
||||
\caption{Hosts\label{Table:Hosts}}\\
|
||||
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, ci.yebilly.me)}\\ \midrule
|
||||
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git, ci, metrics .yebilly.me)}\\ \midrule
|
||||
\endfirsthead
|
||||
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git.yebilly.me, ci.yebilly.me)}\\ \midrule
|
||||
\toprule \textbf{Field} & \textbf{Droplet The-Ocean (git, ci, metrics .yebilly.me)}\\ \midrule
|
||||
\endhead
|
||||
\bottomrule \endlastfoot
|
||||
Role & Gitea work hub (Gitea 1.27.3 behind Caddy 2.11.4 TLS proxy); since
|
||||
22 Oct 2026 also the Jenkins 2.580.1 LTS controller, which runs the CI builds.
|
||||
The Assignment 3 Color Buttons app (29 Sep 2026) is retired: container
|
||||
22 Oct 2026 also the Jenkins 2.580.1 LTS controller, which runs the CI builds;
|
||||
since 28 Oct 2026 also the monitoring stack (Prometheus 3.15.1, Grafana OSS
|
||||
13.2.5, Node Exporter 1.12.1, Blackbox Exporter 0.29.1). The Assignment 3 Color Buttons app (29 Sep 2026) is retired: container
|
||||
stopped with restart policy \texttt{no}; its Caddy route remains\\
|
||||
Delivery agent & Legacy node \texttt{ssw590-vince-delivery}, label
|
||||
\texttt{delivery-trusted}, one exclusive executor; image
|
||||
\texttt{ssw590-delivery-agent:20261114}. RAM / RAM+swap: 512 / 768 MiB,
|
||||
0.5 CPU; separate pinned BuildKit: 256 / 384 MiB, 0.5 CPU.
|
||||
Private WebSocket to Jenkins and SSH through Docker host gateway with pinned
|
||||
public-IP host-key alias. Docker socket control grants host administration.
|
||||
Named identity/workspace and BuildKit cache volumes stay outside Git;
|
||||
configuration under \path{/opt/ssw590-delivery-agent/}; restart unless stopped.
|
||||
Prerequisite build 2 and bounded build/scan/smoke trial passed; campus browser
|
||||
rehearsal and assessed delivery remain pending.\\
|
||||
Environment & Course production (team use)\\
|
||||
Provider & DigitalOcean, NYC1; Ubuntu 24.04 LTS; 1 vCPU; resized from
|
||||
512\,MB to the 1\,GiB Basic plan in October 2026 (961\,MiB reported, 25\,GB
|
||||
plan disk, 1\,GiB swap file)\\
|
||||
512\,MB to 1\,GiB in October, then to 2\,GiB on November 14, 2026
|
||||
(1,967\,MiB reported, original 25\,GB plan disk retained); swap files \texttt{/swapfile} and \texttt{/swapfile2}, 1\,GiB
|
||||
each (second added 28 Oct 2026); \texttt{multipathd}, \texttt{fwupd},
|
||||
\texttt{udisks2}, and \texttt{ModemManager} disabled and masked\\
|
||||
Public address / DNS & IPv4 \texttt{147.182.178.136}; \texttt{A} records
|
||||
\texttt{git}, \texttt{ci}, and \texttt{colors} \texttt{.yebilly.me}; public
|
||||
\texttt{git}, \texttt{ci}, \texttt{metrics}, \texttt{colors}, \texttt{staging}
|
||||
and \texttt{app} \texttt{.yebilly.me}; public
|
||||
IPv6 \texttt{2604:a880:400:d1:0:5:22d:6001} assigned but not published in DNS\\
|
||||
Private services & Gitea \texttt{:3000} and Jenkins \texttt{:8080} (512\,MiB
|
||||
RAM, 0.75 CPU cap; agent port disabled) on Docker network \texttt{gitea\_web},
|
||||
no host ports; SQLite file in volume \texttt{gitea\_gitea-data}; Jenkins state
|
||||
in volume \texttt{gitea\_jenkins-home}\\
|
||||
in volume \texttt{gitea\_jenkins-home}. Monitoring (Compose project
|
||||
\texttt{monitoring}, no host ports): Prometheus \texttt{:9090} (128\,MiB),
|
||||
Node Exporter \texttt{:9100} and Blackbox Exporter \texttt{:9115} (32\,MiB
|
||||
each; Blackbox runs as \texttt{nobody}) on network \texttt{monitoring\_monitoring}; Grafana \texttt{:3000}
|
||||
(192\,MiB) also on \texttt{gitea\_web}; Blackbox at \texttt{172.30.90.10} on
|
||||
\texttt{gitea\_probe} (172.30.90.0/28); volumes
|
||||
\texttt{monitoring\_prometheus\_data} (7\,d / 500\,MB) and
|
||||
\texttt{monitoring\_grafana\_data}\\
|
||||
Exposed ports & 443/TCP and 80/TCP to all; 22/TCP to approved team addresses only
|
||||
(Cloud Firewall \texttt{gitea-fw}); \texttt{ci.yebilly.me} answers only
|
||||
Stevens 155.246.0.0/16 and team addresses (Caddy allowlist), 403 otherwise\\
|
||||
(Cloud Firewall \texttt{gitea-fw}); \texttt{ci.yebilly.me} and
|
||||
\texttt{metrics.yebilly.me} answer only Stevens 155.246.0.0/16 and team
|
||||
addresses (Caddy allowlist; \texttt{ci} also the probe address), 403
|
||||
otherwise; monitoring ports 9090, 9100, 9115 not reachable\\
|
||||
Owner & BY (server administration); VS (review)\\
|
||||
HTTPS URLs & \url{https://git.yebilly.me}, \url{https://ci.yebilly.me/login}\\
|
||||
Backup status & No backup job; container-replacement persistence verified for
|
||||
Gitea (\ChapterRef{GiteaFoundation}) and restart persistence for Jenkins
|
||||
(\ChapterRef{JenkinsCI}) only\\
|
||||
Monitoring status & No alerting configured; checked manually with
|
||||
\texttt{docker compose ps}, \texttt{docker stats}, and logs\\
|
||||
HTTPS URLs & \url{https://git.yebilly.me}, \url{https://ci.yebilly.me/login},
|
||||
\url{https://metrics.yebilly.me/login}; \url{https://staging.yebilly.me} and
|
||||
\url{https://app.yebilly.me} have trusted certificates but return 502 until
|
||||
application deployment\\
|
||||
Backup status & No scheduled backup job; manual Gitea SQLite and Jenkins-home
|
||||
backups saved in a protected root directory before the November 14 delivery
|
||||
bootstrap. Container-replacement persistence verified for
|
||||
Gitea (\ChapterRef{GiteaFoundation}), restart persistence for Jenkins
|
||||
(\ChapterRef{JenkinsCI}) and for Prometheus and Grafana
|
||||
(\ChapterRef{SREMonitoring}); manual volume backup procedure in
|
||||
\texttt{monitoring/README.md}\\
|
||||
Monitoring status & Prometheus and Grafana: host CPU, memory, root disk, and
|
||||
HTTPS probes of Gitea and Jenkins every 30\,s; alerts \emph{HTTPS service
|
||||
down}, \emph{Root disk space low}, and \emph{Monitoring target down} to Discord \texttt{\#devops-alerts}.
|
||||
Shares the droplet's failure domain; no external check yet (issue~\#20)\\
|
||||
\end{tabularx}
|
||||
\normalsize
|
||||
|
||||
\small
|
||||
\begin{tabularx}{\linewidth}{@{}L{3.3cm}Y@{}}
|
||||
\caption{Local build runner host, added October 7, 2026\label{Table:HostsRunner}}\\
|
||||
\toprule \textbf{Field} & \textbf{Vincent's laptop (\texttt{ssw590-vince-local})}\\ \midrule
|
||||
\caption{Actions runner, added October 7 and migrated November 14, 2026\label{Table:HostsRunner}}\\
|
||||
\toprule \textbf{Field} & \textbf{Actions runner on The-Ocean}\\ \midrule
|
||||
\endfirsthead
|
||||
\toprule \textbf{Field} & \textbf{Vincent's laptop (\texttt{ssw590-vince-local})}\\ \midrule
|
||||
\toprule \textbf{Field} & \textbf{Actions runner on The-Ocean}\\ \midrule
|
||||
\endhead
|
||||
\bottomrule \endlastfoot
|
||||
Role & Repository-scoped Gitea Actions runner; manual compilation in temporary Docker job containers\\
|
||||
Environment & Windows laptop, Docker Desktop Linux engine; runner 2.3.0; capacity one job\\
|
||||
Provider / owner & Local device; VS maintains Docker Desktop, runner availability, and job image\\
|
||||
Role & Repository-scoped Gitea Actions runner; temporary manual compiler containers;
|
||||
historical registration name \texttt{ssw590-vince-local} retained\\
|
||||
Environment & Docker on The-Ocean's Ubuntu 24.04 host; runner 2.3.0;
|
||||
capacity one job; current container \texttt{ssw590-manual-runner}\\
|
||||
Provider / owner & Existing DigitalOcean host; VS maintains runner and image;
|
||||
BY retains server administration; no new instance or resize\\
|
||||
Network path & Outbound HTTPS to \texttt{git.yebilly.me:443} and GitHub Actions sources; Caddy forwards to private Gitea \texttt{:3000}; no public runner or Docker daemon port\\
|
||||
Execution label & \texttt{latex-local}; local image \texttt{ssw590-manual-ci:20261007}\\
|
||||
Persistent state & Runner registration in named Docker volume \texttt{ssw590-local-runner-data}; compiler image retained in Docker Desktop\\
|
||||
Availability & Start Docker Desktop and the versioned runner helper after reboot; laptop must remain awake for jobs\\
|
||||
Persistent state & Registration in Droplet volume \texttt{ssw590-local-runner-data},
|
||||
mode 0600; same tested compiler image on the host. Stopped laptop copy retains
|
||||
its original image and volume outside Git\\
|
||||
Availability / limits & Restart unless stopped; daemon 192/256 MiB RAM/RAM+swap,
|
||||
0.25 CPU; compiler job 512/768 MiB, 0.5 CPU. New jobs pause below 600 MiB
|
||||
available host RAM or 3 GiB free disk. Run manual and delivery work sequentially\\
|
||||
Laptop fallback & Both original daemons are stopped. Their helpers require
|
||||
\texttt{-AllowLaptopFallback} after stopping the corresponding remote copy;
|
||||
never run two copies of either identity. No active runner requires Docker Desktop\\
|
||||
Monitoring / backup & Runner logs and Gitea Actions checked manually; no automatic backup of runner registration configured\\
|
||||
\end{tabularx}
|
||||
\normalsize
|
||||
@@ -82,14 +136,32 @@ Monitoring / backup & Runner logs and Gitea Actions checked manually; no automat
|
||||
\toprule \textbf{Service / account} & \textbf{Owner} & \textbf{Where it is kept (hint)} & \textbf{Privilege}\\ \midrule
|
||||
\endhead
|
||||
\bottomrule \endlastfoot
|
||||
Gitea local runner identity & VS & Docker volume \texttt{ssw590-local-runner-data}, file \texttt{/data/.runner}; generated identity, no values in Git; registration token supplied privately from repository settings & Repository runner; Docker control on VS laptop\\
|
||||
Gitea Actions runner identity & VS & Droplet Docker volume \texttt{ssw590-local-runner-data},
|
||||
file \texttt{/data/.runner}, mode 0600; transferred over pinned SSH, no values in Git;
|
||||
stopped laptop fallback retains its copy & Repository runner; Droplet Docker control\\
|
||||
Jenkins delivery agent identity & VS & Protected Jenkins-generated identity and Droplet Docker volume
|
||||
\texttt{ssw590-delivery-identity}; stopped laptop fallback retains its copy; outside Git & Trusted Droplet agent; host Docker control\\
|
||||
Deployment SSH key & VS & Jenkins folder \texttt{secure-delivery}, credential
|
||||
\texttt{delivery-deploy-ssh}; encrypted in Jenkins home & \texttt{deploy} SSH;
|
||||
passwordless root sudo for Ansible\\
|
||||
Pinned deployment host key & VS & Same folder, file credential
|
||||
\texttt{delivery-known-hosts}; public key verified over existing pinned SSH &
|
||||
Strict host verification\\
|
||||
Package-write token & VS & Same folder, credential \texttt{delivery-registry-write};
|
||||
distinct named token under Gitea \texttt{vsun1}; no value in report & Package write only\\
|
||||
Package-read token & VS & Root Docker login configuration on The-Ocean;
|
||||
distinct named token under Gitea \texttt{vsun1}; bootstrap metadata retains name & Package read only\\
|
||||
Gitea \texttt{bill} & BY & BY's password manager & Site administrator\\
|
||||
Gitea \texttt{vsun1} & VS & VS's password manager & Repository administrator\\
|
||||
Gitea \texttt{vsun1} & VS & VS's password manager & Site administrator (verified November 15)\\
|
||||
Gitea \texttt{jenkins-bot} (added 22 Oct 2026) & BY & BY's password manager; used only to create its token & Write collaborator on \texttt{vpn-dns-gateway}\\
|
||||
\texttt{jenkins-bot} token \texttt{jenkins-ci} & BY & Jenkins credential ID \texttt{gitea-jenkins-bot} (System, Global), encrypted in volume \texttt{gitea\_jenkins-home}; revoke under the bot's Gitea Applications settings & Repository read/write; organization and user read\\
|
||||
Jenkins \texttt{billy} & BY & BY's password manager & Administer (all)\\
|
||||
Jenkins \texttt{vsun1} & VS & VS's password manager & Administer (all)\\
|
||||
Jenkins initial admin password & --- & One-time setup secret in \texttt{/var/jenkins\_home/secrets/}; read once by BY, superseded by named accounts & Setup only\\
|
||||
Grafana \texttt{billy} (added 28 Oct 2026) & BY & BY's password manager; the initial value set through the monitoring secrets file was replaced in Grafana on 28 Oct 2026 and removed from the file & Grafana Admin\\
|
||||
Grafana \texttt{vsun1} (added 28 Oct 2026) & VS & VS's password manager; temporary password set by BY and sent privately, to be changed by VS at first login & Viewer\\
|
||||
Monitoring secrets \texttt{.env.secret} & BY & \texttt{\textasciitilde/monitoring/.env.secret} on the droplet, mode 600, root; typed by BY; holds the Discord webhook URL (the initial Grafana admin password was removed after it was replaced); never in Git & n/a\\
|
||||
Discord webhook \texttt{Grafana} & BY & BY's password manager and the monitoring secrets file; revoke under \texttt{\#devops-alerts} $\rightarrow$ Integrations $\rightarrow$ Webhooks & Post to \texttt{\#devops-alerts}\\
|
||||
CI allowlist \texttt{.env} & BY & \texttt{\textasciitilde/gitea/.env} on the droplet, root-only; holds team and approved grader IP addresses (personal data, not a secret); grader entries are removed after grading & n/a\\
|
||||
DigitalOcean team & BY, VS & Each member's own login, in their password manager & Team member\\
|
||||
Namecheap (\texttt{yebilly.me}) & BY & BY's password manager & Domain owner\\
|
||||
@@ -99,8 +171,10 @@ Gitea database (SQLite) & --- & No credential; file access limited to droplet \t
|
||||
\end{tabularx}
|
||||
\normalsize
|
||||
|
||||
Multi-factor authentication and rotation status have not yet been recorded for
|
||||
these accounts. Some credentials also have local copies on members' devices;
|
||||
Multi-factor authentication: as reported by BY on 28 Oct 2026, his Discord
|
||||
account (which owns the \texttt{\#devops-alerts} webhook) and his GitHub
|
||||
account use MFA. MFA status for the other accounts, and rotation status for
|
||||
all of them, has not yet been recorded. Some credentials also have local copies on members' devices;
|
||||
moving them into the password managers is an open follow-up.
|
||||
|
||||
\fussy
|
||||
|
||||
@@ -42,8 +42,8 @@ The versioned
|
||||
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/deploy/jenkins/Dockerfile}{\texttt{deploy/jenkins/Dockerfile}}
|
||||
adds only \texttt{python3} (Python 3.13.5; Git 2.47.3 is already in the
|
||||
image) because builds run on the controller. Plugins come from the lockfile
|
||||
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/420ba4c56b1c3efa50099a85c16c750a9815091a/deploy/jenkins/plugins.txt}{\texttt{deploy/jenkins/plugins.txt}},
|
||||
which pins every plugin's version and SHA-256. The image build downloads each
|
||||
\href{https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/commit/ac18f1118601157da356d09d4aa28c4084dc86eb/deploy/jenkins/plugins.txt}{\texttt{deploy/jenkins/plugins.txt}},
|
||||
which pins each listed plugin's version and SHA-256. The image build downloads each
|
||||
archive and verifies its hash. Table~\ref{Table:JenkinsPlugins} lists the
|
||||
plugins the pipeline relies on; the full lockfile holds 63 plugins including
|
||||
dependencies.
|
||||
@@ -410,12 +410,15 @@ Delivery~3 is a real failure. Gitea recorded \texttt{Post
|
||||
"http://jenkins:8080/gitea-webhook/post": context deadline exceeded
|
||||
(Client.Timeout exceeded while awaiting headers)}. Diagnosis: Jenkins did
|
||||
receive the event, because Gitea shows PR-15's status ``Build queued'' at
|
||||
23:02:01, two seconds later, and run~1 passed at 23:02:18. Jenkins answered
|
||||
after Gitea's delivery timeout because it was busy with the PR discovery on
|
||||
its 0.75-CPU limit. No action was needed; had the build not started,
|
||||
\emph{Redeliver} on that delivery, or \emph{Scan Multibranch Pipeline Now},
|
||||
would recover it, and raising Gitea's \texttt{webhook.DELIVER\_TIMEOUT}
|
||||
would prevent repeats. General procedure if a push does not start a build:
|
||||
23:02:01, two seconds later, and run~1 passed at 23:02:18. Gitea did not
|
||||
receive a response before its delivery timeout. PR discovery under the
|
||||
0.75-CPU limit is a suspected cause of the delay, not a measured diagnosis.
|
||||
No action was needed because the build completed. If a build does not
|
||||
start, inspect the delivery and Jenkins logs, then use \emph{Redeliver}
|
||||
or \emph{Scan Multibranch Pipeline Now} after correcting the cause.
|
||||
Raising Gitea's \texttt{webhook.DELIVER\_TIMEOUT} may help if slow responses
|
||||
are confirmed, but does not guarantee successful delivery.
|
||||
General procedure if a push does not start a build:
|
||||
(1) open \emph{Repository Settings
|
||||
$\rightarrow$ Webhooks $\rightarrow$ jenkins-ci $\rightarrow$ Recent
|
||||
Deliveries} and read the response; (2) ``can only call allowed HTTP
|
||||
@@ -467,11 +470,15 @@ raises \texttt{ValueError}. Expected passing output ends in
|
||||
\end{itemize}
|
||||
\textbf{Dependencies:} Python 3.13.5 and Git 2.47.3 come from the Debian
|
||||
packages in the Jenkins image; the tests use only the standard library.
|
||||
\textbf{Clean run:} on any machine with Python 3, check out a commit and run
|
||||
\textbf{Clean run:} on a machine with Python 3, clone the repository into a
|
||||
new directory and check out the recorded commit ID of the run to reproduce.
|
||||
From that repository root, run
|
||||
\texttt{python3 -m py\_compile pricing.py} then
|
||||
\texttt{python3 -m unittest discover -s tests -v} from the repository root.
|
||||
In Jenkins, \emph{Build Now} on a branch or PR job repeats the run in a fresh
|
||||
checkout of the same commit.
|
||||
In Jenkins, \emph{Build Now} on a branch or PR job builds the revision selected
|
||||
for that run. Verify the checked-out commit ID in its log; it may differ from
|
||||
an earlier run after a new push. The pipeline's \texttt{checkout scm} step
|
||||
does not explicitly clean the workspace.
|
||||
|
||||
Figure~\ref{Figure:JenkinsStages} shows the distinct stage results of a run,
|
||||
here the deliberate failure, with the tested commit identified in its log.
|
||||
@@ -623,8 +630,8 @@ dependencies make 63 locked; Jenkins reports 66 installed, the other three
|
||||
being the theme plugins described in Section~\ref{Section:JenkinsQuality},
|
||||
which this check did not cover.) One newer version exists
|
||||
(\texttt{workflow-api} \texttt{1413.v2ff1a\_5e720fa\_} $\rightarrow$
|
||||
\texttt{1429.v7a\_1b\_efb\_a\_f7c5}); no security warning matches any installed
|
||||
version. The update was deferred: it is not a security fix and would change
|
||||
\texttt{1429.v7a\_1b\_efb\_a\_f7c5}); no security warning matched the 63
|
||||
checked plugin versions. The update was deferred: it is not a security fix and would change
|
||||
the tested set. Updates are applied by regenerating the lockfile, rebuilding
|
||||
the image, and recreating the container.
|
||||
|
||||
|
||||
@@ -4,3 +4,53 @@
|
||||
publisher = {IT Revolution Press},
|
||||
year = {2018}
|
||||
}
|
||||
|
||||
@book{SREWorkbook,
|
||||
author = {Beyer, Betsy and Murphy, Niall Richard and Rensin, David K. and Kawahara, Kent and Thorne, Stephen},
|
||||
title = {The Site Reliability Workbook: Practical Ways to Implement {SRE}},
|
||||
publisher = {O'Reilly Media},
|
||||
year = {2018},
|
||||
note = {Chapter 2, ``Implementing SLOs,'' \url{https://sre.google/workbook/implementing-slos/}, accessed Oct. 28, 2026}
|
||||
}
|
||||
|
||||
@misc{PrometheusDocs,
|
||||
author = {{Prometheus Authors}},
|
||||
title = {Prometheus Documentation: Configuration, Storage, and Querying},
|
||||
howpublished = {\url{https://prometheus.io/docs/prometheus/latest/}},
|
||||
note = {Version 3.15; accessed Oct. 28, 2026}
|
||||
}
|
||||
|
||||
@misc{NodeExporter,
|
||||
author = {{Prometheus Authors}},
|
||||
title = {Node Exporter},
|
||||
howpublished = {\url{https://github.com/prometheus/node_exporter}},
|
||||
note = {Release v1.12.1; accessed Oct. 28, 2026}
|
||||
}
|
||||
|
||||
@misc{BlackboxExporter,
|
||||
author = {{Prometheus Authors}},
|
||||
title = {Blackbox Exporter},
|
||||
howpublished = {\url{https://github.com/prometheus/blackbox_exporter}},
|
||||
note = {Release v0.29.1; accessed Oct. 28, 2026}
|
||||
}
|
||||
|
||||
@misc{GrafanaDocker,
|
||||
author = {{Grafana Labs}},
|
||||
title = {Run {Grafana} {Docker} Image},
|
||||
howpublished = {\url{https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/}},
|
||||
note = {{Grafana OSS} 13.2; accessed Oct. 28, 2026}
|
||||
}
|
||||
|
||||
@misc{GrafanaAlerting,
|
||||
author = {{Grafana Labs}},
|
||||
title = {Grafana Alerting: Provision Alerting Resources and Configure Contact Points},
|
||||
howpublished = {\url{https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/}},
|
||||
note = {{Grafana OSS} 13.2; accessed Oct. 28, 2026}
|
||||
}
|
||||
|
||||
@misc{MicrosoftTestNetConnection,
|
||||
author = {{Microsoft}},
|
||||
title = {{Test-NetConnection}},
|
||||
howpublished = {\url{https://learn.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection}},
|
||||
note = {Accessed Oct. 28, 2026}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
\chapter{Secure Delivery and Rollback}
|
||||
\ChapterLabel{SecureDelivery}
|
||||
\index{secure delivery}\index{rollback}\index{Ansible}\index{immutable image}
|
||||
|
||||
\section{Scope and Current Status}
|
||||
Assignment 8 implements Chapter 6 of instructor manual version 1.43, using its
|
||||
Startup Pricing Service and the existing Gitea, Jenkins, Caddy and monitoring
|
||||
foundation. The Canvas page lists November 13, 2026 at 11:59pm; Vincent reports
|
||||
an extension. This version records preparation begun November 14 and DNS/TLS
|
||||
readiness verified November 15, not a completed release exercise.
|
||||
\textbf{It is not ready for submission.} Reviewed v1/v2
|
||||
publication, promotion, production rollback, staging failure/recovery and
|
||||
monitoring correlation remain pending. No approval, release digest or successful
|
||||
deployment is inferred from a tool installation or local smoke test.
|
||||
|
||||
The instructor's v1 source and tests were copied from
|
||||
\path{Examples/dosSecureDelivery/v1/} to \path{delivery/app/}. Flask validates
|
||||
requests and calculates the price; Gunicorn serves it with one worker on private
|
||||
port 8000. There is no payment processing, customer data or application volume.
|
||||
For three units v1 returns USD 30; the separate v2 source/test change must return
|
||||
USD 36. The image embeds its actual source commit during the build. Health,
|
||||
identity and pricing are verified separately.
|
||||
|
||||
\section{Deployment and Trust Boundaries}
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\renewcommand{\theHfigure}{delivery.\arabic{figure}}
|
||||
\resizebox{\linewidth}{!}{%
|
||||
\begin{tikzpicture}[
|
||||
box/.style={draw=devopsBlue,rounded corners,align=center,text width=3.6cm,
|
||||
minimum height=1.5cm,font=\footnotesize,fill=white},
|
||||
data/.style={box,draw=devopsGray,fill=gray!12,font=\scriptsize},
|
||||
planned/.style={box,dashed,fill=devopsLightBlue},
|
||||
flow/.style={-{Latex},thick}, note/.style={font=\scriptsize,align=center,fill=white,inner sep=1pt}]
|
||||
\node[box] (agent) at (4.8,2.7) {Droplet delivery agent\\512 MiB / 0.5 CPU\\Docker, scans and Ansible};
|
||||
\node[data,text width=3.8cm] (local) at (0,2.7) {Agent volumes on droplet\\\texttt{ssw590-delivery-identity}\\\texttt{ssw590-delivery-workspace}};
|
||||
\node[box] (builder) at (9.6,2.7) {Pinned BuildKit builder\\256 MiB / 0.5 CPU\\Private Docker control};
|
||||
\node[box] (git) at (0,0) {Gitea + OCI registry\\\texttt{git.yebilly.me}\\SQLite retained};
|
||||
\node[box] (jenkins) at (4.8,0) {Jenkins controller\\\texttt{ci.yebilly.me}\\Schedules trusted job};
|
||||
\node[box] (host) at (9.6,0) {The-Ocean host\\\texttt{deploy} SSH account\\Python, Docker/Compose};
|
||||
\node[box] (monitor) at (0,-2.8) {Prometheus, Grafana,\\Blackbox and Node Exporter\\Private metrics ports};
|
||||
\node[box] (proxy) at (4.8,-2.8) {Caddy TLS proxy\\Public 80/443\\Private \texttt{gitea\_web} network};
|
||||
\node[planned] (stage) at (9.6,-2.8) {Planned staging app\\\texttt{staging.yebilly.me}\\{\scriptsize\texttt{pricing-staging:8000}}};
|
||||
\node[planned] (prod) at (9.6,-5.2) {Production app (planned)\\\texttt{app.yebilly.me}\\{\scriptsize\texttt{pricing-production:8000}}};
|
||||
\node[data,text width=12.9cm,align=left] (storage) at (4.8,-8.45) {
|
||||
\textbf{Persistent state and read-only mounts on The-Ocean}\\[3pt]
|
||||
\begin{tabular}{@{}ll@{}}
|
||||
Gitea & \texttt{gitea\_gitea-data} $\rightarrow$ \texttt{/data} (includes SQLite)\\
|
||||
Jenkins & \texttt{gitea\_jenkins-home} $\rightarrow$ \texttt{/var/jenkins\_home}\\
|
||||
Caddy certificates & \texttt{gitea\_caddy-data} $\rightarrow$ \texttt{/data}\\
|
||||
Caddy configuration & \texttt{gitea\_caddy-config} $\rightarrow$ \texttt{/config}\\
|
||||
Prometheus & \texttt{monitoring\_prometheus\_data} $\rightarrow$ \texttt{/prometheus}\\
|
||||
Grafana & \texttt{monitoring\_grafana\_data} $\rightarrow$ \texttt{/var/lib/grafana}\\
|
||||
Proxy bind mount & \texttt{/root/gitea/Caddyfile} $\rightarrow$ \texttt{/etc/caddy/Caddyfile} (ro)\\
|
||||
Monitoring mounts & \texttt{/root/monitoring/}: configuration (ro); host \texttt{/} $\rightarrow$ \texttt{/host} (ro)\\
|
||||
Planned app config & \texttt{/opt/startup/pricing-\{staging,production\}}; no app data volume
|
||||
\end{tabular}};
|
||||
\node[draw,dashed,rounded corners,fit=(agent)(local)(builder)(git)(host)(monitor)(prod)(storage),
|
||||
inner sep=0.55cm,label={[font=\small]below:Existing droplet: 1 vCPU, 2 GiB RAM, 25 GB plan disk}] {};
|
||||
\draw[flow,dotted] (local)--(agent);
|
||||
\draw[flow] (agent)--node[note,right,pos=0.25]{private WS}(jenkins);
|
||||
\draw[flow] (agent)--node[note,above]{build}(builder);
|
||||
\draw[flow] (agent.south west)--node[note,above,sloped]{Git / OCI}(git.north east);
|
||||
\draw[flow] (agent.south east)--node[note,above,sloped]{SSH}(host.north west);
|
||||
\draw[flow] (git)--node[note,above]{hook}(jenkins);
|
||||
\draw[flow,dashed] (host)--node[note,right]{apply}(stage);
|
||||
\draw[flow,dashed] (host.east)--++(0.35,0)|-(prod.east);
|
||||
\draw[flow,dashed] (monitor)--node[note,above]{probe}(proxy);
|
||||
\draw[flow,dashed] (proxy)--node[note,above]{HTTP}(stage);
|
||||
\draw[flow,dashed] (proxy.south east)--node[note,above,sloped]{HTTP}(prod.north west);
|
||||
\end{tikzpicture}}
|
||||
\caption{Preparation architecture. Solid boxes are installed; dashed blue boxes
|
||||
and connections are planned application work. Gray boxes identify durable state
|
||||
or read-only mounts. Pricing is stateless; each environment retains only its
|
||||
Compose and release files on the host. The agent and builder now share the
|
||||
droplet; deployment SSH uses Docker's host gateway with the original pinned
|
||||
host-key alias. Browser access remains through Caddy HTTPS.}
|
||||
\label{Figure:SecureDeliveryArchitecture}
|
||||
\end{figure}
|
||||
|
||||
The exclusive node \texttt{ssw590-vince-delivery} has one executor and label
|
||||
\texttt{delivery-trusted}. Originally installed on Vincent's laptop, it now runs
|
||||
on The-Ocean because campus networking blocks SSH from the laptop. Its legacy
|
||||
node name is retained and its description records the new location. It connects
|
||||
to \texttt{jenkins:8080} over private HTTP/WebSocket, with no published agent
|
||||
or Docker API port. Docker socket membership (group 987 on this host) grants
|
||||
administrative control over the same host as Jenkins, Gitea and monitoring;
|
||||
containerization is not isolation from malicious Docker-authorized jobs.
|
||||
The \texttt{deploy} account's
|
||||
\texttt{NOPASSWD} sudo permits root commands for Ansible; a separate account
|
||||
does not remove that administrative authority. Its authorized key disables SSH
|
||||
forwarding and PTY allocation. The host's ED25519 key was read through the
|
||||
existing strictly pinned administrator SSH connection and stored as a Jenkins
|
||||
file credential; verification is not disabled. A mounted SSH configuration
|
||||
maps the existing inventory address to \texttt{host.docker.internal}, retaining
|
||||
\texttt{HostKeyAlias 147.182.178.136}. Thus neither the Jenkins-agent connection
|
||||
nor deployment SSH crosses campus Wi-Fi. Campus browser HTTPS access still
|
||||
needs rehearsal. The Gitea Actions PDF runner subsequently moved to The-Ocean
|
||||
too; \ChapterRef{AutomatedManualBuild} records its separate migration and real
|
||||
workflow verification. Neither active runner now requires Docker Desktop.
|
||||
Keep manual compilation and delivery releases sequential on the shared host.
|
||||
|
||||
The agent is capped at 512 MiB RAM / 768 MiB RAM+swap and 0.5 CPU, with a
|
||||
96 MiB Java heap. Its separate pinned BuildKit container is capped at 256 MiB /
|
||||
384 MiB and 0.5 CPU; builds explicitly select that builder because a Docker
|
||||
socket does not make child containers inherit agent limits. Both use
|
||||
\texttt{unless-stopped}. Agent restart/reconnect was verified at 03:57:57 UTC.
|
||||
The laptop copy is stopped and its helper now requires an explicit fallback
|
||||
switch; two copies must never connect as the same node. VS maintains the agent;
|
||||
BY retains host administration. No extra instance or plan resize was made.
|
||||
|
||||
Deployment credentials belong to the \texttt{secure-delivery} Jenkins folder,
|
||||
not the root multibranch PR job. That job retains its earlier ordinary tests,
|
||||
plus Python syntax and release-control tests; it does not bind delivery
|
||||
credentials or a Docker socket. The new release job loads
|
||||
\path{delivery/Jenkinsfile} from protected main and is currently disabled.
|
||||
Only trusted reviewed code may use the privileged node. Exclusive scheduling
|
||||
is not a defense against an administrator or an author permitted to select that
|
||||
node; the two-member repository and Jenkins administration remain trust boundaries.
|
||||
Shared proxy-network membership is a lab simplification, not strong lateral
|
||||
isolation. Both environments share the droplet's failure domain.
|
||||
|
||||
\section{Installation Inventory and Preparation Evidence}
|
||||
\small
|
||||
\begin{longtable}{@{}L{3.0cm}L{9.9cm}@{}}
|
||||
\toprule Item & Verified selection or result\\\midrule\endhead
|
||||
Trusted agent & Python 3.13.5; Ansible core 2.21.6 in
|
||||
\texttt{/opt/delivery-tools}; community.docker 5.4.0 and its
|
||||
community.library\_inventory\_filtering\_v1 dependency 1.1.5.\\
|
||||
Build and scan tools & Docker 29.9.3, Compose 5.7.1, Trivy 0.76.2 and
|
||||
pip-audit 2.10.1. Base tool images are pinned in the agent Dockerfile;
|
||||
direct/transitive Python tools and collections are locked in Git.\\
|
||||
Target & Ubuntu 24.04 LTS; Python 3.12.3; Docker 29.9.3 and Compose 5.7.1.
|
||||
At 20:46 UTC: 1,967 MiB RAM, 878 MiB available, 102 MiB swap used; root
|
||||
filesystem 41\% used. This is one prerequisite sample, not a load test.\\
|
||||
Runtime image & Python 3.13 Alpine, Linux/amd64, selected registry digest:
|
||||
\newline\texttt{sha256:9ef1a599f863231c3d91e941389bfdc4}\allowbreak%
|
||||
\texttt{a2d6070557243d54df1a4e57015b960e}.\\
|
||||
Application lock & Flask 3.1.3; Gunicorn 23.0.0; blinker 1.9.0; click 8.5.1;
|
||||
itsdangerous 2.2.0; Jinja2 3.1.6; MarkupSafe 3.0.4; packaging 26.3;
|
||||
Werkzeug 3.1.9. No claim is made that a pinned version remains vulnerability-free.\\
|
||||
Runtime constraints & UID 10001; one Gunicorn worker; 64 MiB RAM / 96 MiB
|
||||
RAM+swap; 0.25 CPU; 64 PIDs; read-only root; 16 MiB temporary filesystem;
|
||||
all capabilities dropped and no host application port.\\
|
||||
Initial Jenkins prerequisite run &
|
||||
\href{https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/1/}{Agent preflight build 1}
|
||||
passed on November 14 at 20:46 UTC, including strict-key SSH as deploy and
|
||||
noninteractive sudo. \path{delivery/evidence/agent-preflight-1.txt} preserves
|
||||
its non-secret inventory. This run did not deploy an application.\\
|
||||
Remote agent migration &
|
||||
At 03:47 UTC on November 15 (November 14 Eastern),
|
||||
\href{https://ci.yebilly.me/job/secure-delivery/job/agent-preflight/2/}{preflight build 2}
|
||||
passed on The-Ocean with real credentials, pinned host verification and sudo.
|
||||
\path{delivery/evidence/agent-preflight-2.txt} preserves the inventory.\\
|
||||
Remote capacity trial & At 03:50--03:51 UTC, a preparation snapshot passed
|
||||
12 control tests, 3 app tests, source/dependency gates, a limited image build,
|
||||
the full image gate and a temporary 64 MiB HTTP smoke test. Its source identity
|
||||
was \texttt{uncommitted-remote-preflight}; nothing was published or promoted.
|
||||
Observed available RAM exceeded 700 MiB; swap used rose from 263 to 372 MiB.
|
||||
Agent memory-limit events occurred, but no OOM kill was recorded. This short
|
||||
trial does not establish full release or presentation performance.\\
|
||||
Local tests & Three Flask tests passed; a generated wrong-price assertion
|
||||
failed as intended; twelve release/security-control tests passed. Gunicorn
|
||||
health/identity/price/invalid-input smoke checks passed under the stated cap.
|
||||
Its baked identity was explicitly \texttt{uncommitted-preflight}, not a release SHA.\\
|
||||
Local scans & Source/dependency gates passed; a generated synthetic secret
|
||||
blocked the gate. At 20:32 UTC the complete runtime-image gate passed with no
|
||||
HIGH/CRITICAL findings. Reports and exit codes remain in ignored local evidence.
|
||||
Assessed Jenkins gate runs and published-image scans remain pending.\\
|
||||
\bottomrule
|
||||
\end{longtable}
|
||||
\normalsize
|
||||
|
||||
Vincent resized the droplet while keeping its 25 GB plan disk, then updated
|
||||
packages. Post-maintenance checks found all seven earlier containers running,
|
||||
no failed systemd services, no required reboot marker, and HTTP 200 for Gitea,
|
||||
Jenkins and Grafana from the laptop. Before administrator bootstrap, a protected
|
||||
consistent Jenkins-home archive and an online Gitea SQLite backup were saved
|
||||
under \path{/root/ssw590-delivery-bootstrap/}. The one-time setup then created
|
||||
the deploy key, distinct package-only tokens under \texttt{vsun1}, the folder,
|
||||
node and disabled release job. No token or private key was printed or copied
|
||||
into the repository. Private bootstrap inputs were removed after Jenkins stored
|
||||
the credentials; generated agent identity stays in protected named volumes.
|
||||
|
||||
\section{Prepared Pipeline and Release Records}
|
||||
The normal release path is checkout of reviewed main ancestry, control and
|
||||
application tests, repository-secret and dependency checks, build, image scan,
|
||||
registry push/pull, exact digest recording, staging deployment, unchanged rerun,
|
||||
human approval, and production deployment. Existing commit tags are reused on
|
||||
retry rather than overwritten. A new image is scanned before push and again by
|
||||
its registry digest. The same digest is promoted without rebuilding. Concurrent
|
||||
delivery builds are disabled. Release and scan reports are archived on failure
|
||||
and before the approval prompt.
|
||||
|
||||
The policy in \path{delivery/SECURITY.md} was selected before the scans: block
|
||||
detected secrets, HIGH/CRITICAL image findings (including unfixed issues), all
|
||||
reported Python dependency advisories, scanner errors and missing/malformed
|
||||
reports. No exceptions are approved. A proposed exception requires instructor
|
||||
acceptance, advisory ID, owner, rationale, controls and expiry. Earlier Debian
|
||||
and installer-containing Alpine preflight scans failed; their reports were
|
||||
retained. The runtime was changed to the pinned Alpine base and unneeded pip/
|
||||
ensurepip were removed; the scanner policy was not weakened.
|
||||
|
||||
The release record contains source and configuration commits, exact registry
|
||||
digest, version/expected total, environment, public URL, proxy network, build
|
||||
URL and creation time. Both commits must be ancestors of protected main. Only
|
||||
the expected team registry, URL/environment pair and metadata fields are
|
||||
accepted. Production requires an input restricted to \texttt{billy,vsun1},
|
||||
with a 20-minute timeout; the actual human approval and UTC time are recorded.
|
||||
Administrators retain their normal override powers. No unattended approval is
|
||||
claimed. Ansible restores the selected playbook/template from the recorded
|
||||
configuration commit, deploys without rebuilding, waits for health, then checks
|
||||
HTTPS health, version, source commit and price. A separate JSON recap records
|
||||
timing and makes a nonzero changed count on the unchanged rerun a blocking error.
|
||||
|
||||
\small
|
||||
\begin{tabularx}{\linewidth}{L{2.1cm}Y Y}
|
||||
\toprule Traceability field & v1 & v2\\\midrule
|
||||
Source / config commits & Pending review and merge & Separate change pending\\
|
||||
Registry digest / Jenkins release build & Not published / not run & Not published / not run\\
|
||||
Staging + unchanged rerun & Pending & Pending\\
|
||||
Production approval / result & No approval or promotion yet & No approval or promotion yet\\
|
||||
Recovery evidence & Healthy rollback pending & Staging failure/recovery pending\\
|
||||
\bottomrule
|
||||
\end{tabularx}
|
||||
\normalsize
|
||||
|
||||
\section{Release, Recovery and Monitoring Runbooks}
|
||||
The versioned \path{delivery/RUNBOOKS.md} gives the executable sequence.
|
||||
Vincent handles commits/pushes; Billy reviews repository changes. Once reviewed
|
||||
v1 is on main and DNS/TLS are ready, enable the delivery job, demonstrate
|
||||
\texttt{blocked-test} and \texttt{blocked-secret}, then run \texttt{release}.
|
||||
Verify staging and changed=0 before a real human approval promotes v1. Save and
|
||||
review its generated staging/production records. Apply the supplied v2 source
|
||||
and test changes in another reviewed commit and repeat, expecting 36.
|
||||
|
||||
For healthy production rollback, record detection/decision time, start the
|
||||
HTTPS observer, select the committed v1 production record and approve the
|
||||
operation. Ansible restores its original image and configuration, then verifies
|
||||
v1, original source SHA and total 30. Preserve start, recovery, verification and
|
||||
sampled interruption. A zero-failure sample set cannot prove zero downtime
|
||||
between requests.
|
||||
|
||||
For failed staging deployment recovery, use a separate reviewed configuration
|
||||
commit to bind Gunicorn to 8001 only in staging while the image healthcheck
|
||||
still probes 8000. Run \texttt{staging-failure} with the good v2 staging release
|
||||
record and bad configuration SHA. Compose wait must fail and Jenkins must stop
|
||||
before production. Restore/review the correct template and rerun
|
||||
\texttt{recover-staging} with the original good record. Verify v2, its source,
|
||||
total 36 and changed=0. Do not alter shared infrastructure or data to create
|
||||
the failure.
|
||||
|
||||
The production \texttt{/health} probe and Grafana availability panel are prepared
|
||||
in Git but not deployed while production is absent. Apply them after health is
|
||||
verified, keeping existing Gitea/Jenkins probes and host metrics. Correlate real
|
||||
Prometheus/Grafana samples with release/rollback times; 30-second scrapes and
|
||||
alert durations can miss a brief interruption. Uptime probes do not verify
|
||||
pricing. The observer in \path{delivery/ci/observe.py} records finer HTTPS
|
||||
samples without treating an intended failure as an observer-script failure.
|
||||
|
||||
This stateless service needs no database restore. A real incompatible schema,
|
||||
external payment or stored state could make image-only rollback unsafe. A
|
||||
compatible expand/migrate/contract approach keeps both old and new code working
|
||||
during migration and delays destructive changes until rollback is no longer
|
||||
needed. This assignment does not add a database.
|
||||
|
||||
\section{Outstanding Work and Cleanup Boundary}
|
||||
Billy added A records for \texttt{staging} and \texttt{app}. On November 15,
|
||||
Google and Cloudflare both returned \texttt{147.182.178.136} for each name,
|
||||
with no AAAA answer. Codex validated the prepared Caddy additions, saved the
|
||||
previous configuration and gracefully reloaded it while preserving the earlier
|
||||
routes, allowlists, volumes and bind-mounted inode. Normal curl and Python TLS
|
||||
checks confirmed trusted hostname-matching certificates, TLS 1.3 and HTTP 308
|
||||
redirects. HTTPS currently returns 502 because the pricing backends have not
|
||||
been deployed; this is not evidence of application health. Certificate and DNS
|
||||
details are recorded in \path{delivery/evidence/https-20261115.md}. Existing
|
||||
Gitea/Jenkins/Grafana checks still passed. The public application port is HTTPS
|
||||
443, with internal port 8000 remaining private. Distinct DNS hostnames satisfy
|
||||
the planned routing boundary; reviewed application releases remain outstanding.
|
||||
|
||||
Vincent pushed preparation commit \texttt{bf28adc}; PR~\#24 exists. The later
|
||||
agent migration and documentation changes remain local and uncommitted.
|
||||
Issue creation, peer review/merge, both assessed releases, production approvals,
|
||||
both recovery demonstrations, final traceability and monitoring evidence, and
|
||||
the final submission review remain outstanding. Local checks are not a
|
||||
replacement for those executions.
|
||||
|
||||
After grading, only when instructed, retain required evidence and remove only
|
||||
the two pricing projects, their routes, monitoring additions and test DNS.
|
||||
Revoke their package tokens; retire deploy access and the delivery node/folder
|
||||
after preserving job history. Do not prune Docker or use \texttt{down -v}.
|
||||
Preserve earlier Gitea/Jenkins/proxy/monitoring services and all shared volumes.
|
||||
The stopped laptop fallback, active remote agent, cache/identity volumes and protected remote backup are retained
|
||||
while work and assessment remain in progress.
|
||||
|
After Width: | Height: | Size: 199 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 196 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 97 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 454 KiB |
|
After Width: | Height: | Size: 480 KiB |
|
After Width: | Height: | Size: 426 KiB |
|
After Width: | Height: | Size: 62 KiB |
@@ -36,15 +36,16 @@ try {
|
||||
exit 0
|
||||
}
|
||||
|
||||
$repoDirectory = Split-Path -Parent $projectDirectory
|
||||
$manualDirectory = Split-Path -Parent $projectDirectory
|
||||
$repoDirectory = Split-Path -Parent $manualDirectory
|
||||
$projectsDirectory = Split-Path -Parent $repoDirectory
|
||||
$toolDirectories = @()
|
||||
if ($env:DEVOPS_LATEX_BIN) {
|
||||
$toolDirectories += $env:DEVOPS_LATEX_BIN
|
||||
}
|
||||
$toolDirectories += @(
|
||||
(Join-Path $env:APPDATA 'TinyTeX\bin\windows'),
|
||||
(Join-Path $projectsDirectory 'Tools\LaTeX\TinyTeX\bin\windows'),
|
||||
(Join-Path $env:APPDATA 'TinyTeX\bin\windows'),
|
||||
(Join-Path $env:LOCALAPPDATA 'Programs\MiKTeX\miktex\bin\x64'),
|
||||
'C:\Program Files\MiKTeX\miktex\bin\x64'
|
||||
)
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
# Assignment 7 raw evidence (droplet The-Ocean, captured by Claude over SSH, approved by Billy)
|
||||
|
||||
## Baseline 2026-10-28 04:34 UTC
|
||||
|
||||
Ubuntu 24.04.5 LTS, kernel 6.8.0-147-generic x86_64, 1 vCPU; Docker 29.8.1, Compose v5.5.1; disk /dev/vda1 24883167232 B, 18784387072 B available (25% used); gitea_web 172.18.0.0/16; global IPv6 2604:a880:400:d1:0:5:22d:6001/64, no AAAA records; uptime 6 days, load 0.05.
|
||||
|
||||
Containers: gitea-jenkins-1 325.4MiB/512MiB, gitea-caddy-1 10.85MiB, gitea-gitea-1 98.21MiB. Host RSS: java 318.1, gitea 122.0, dockerd 50.0, multipathd 26.5, containerd 23.5, caddy 16.7 MiB.
|
||||
|
||||
```
|
||||
Wed Oct 28 04:34:27 UTC 2026
|
||||
total used free shared buff/cache available
|
||||
Mem: 1008177152 778825728 101543936 3424256 281452544 229351424
|
||||
Swap: 1073737728 479457280 594280448
|
||||
Filesystem 1B-blocks Used Available Use% Mounted on
|
||||
/dev/vda1 24883167232 6082015232 18784374784 25% /
|
||||
NAME TYPE SIZE USED PRIO
|
||||
/swapfile file 1024M 457.2M -2
|
||||
gitea-jenkins-1 0.17% 326.3MiB / 512MiB
|
||||
gitea-caddy-1 0.00% 11MiB / 961.5MiB
|
||||
gitea-gitea-1 0.20% 102.9MiB / 961.5MiB
|
||||
```
|
||||
|
||||
## Unused host services disabled
|
||||
|
||||
```
|
||||
2026-10-28 04:52:51 UTC disabled+masked: multipathd(.service,.socket), fwupd(+fwupd-refresh.timer), udisks2, ModemManager
|
||||
before: Mem total 1008177152 used 798810112 available 209367040
|
||||
after (04:52:59): used 786944000 available 221233152 ; 04:53:0x: available 238510080, Mlocked 0
|
||||
apt-daily.service ran 04:52:52-04:53:24 (40.8M peak, triggered by systemd reload); after: available 364957696, swap used 503414784
|
||||
checks before change: multipath -ll empty; dmsetup ls "No devices found"; root=UUID cc6f3ac6 (/dev/vda1, LABEL cloudimg-rootfs); multipath-tools-boot not installed; initramfs multipath files 0
|
||||
post: gitea-jenkins-1, gitea-caddy-1, gitea-gitea-1 Up; git login 200 1.09s, ci login 200 0.38s
|
||||
undo: systemctl unmask multipathd fwupd udisks2 ModemManager && systemctl enable --now multipathd udisks2 ModemManager
|
||||
```
|
||||
|
||||
## Image pins chosen 2026-10-28 (registry index digests)
|
||||
|
||||
- prom/prometheus:v3.15.1 sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2 (released 2026-10-21)
|
||||
- grafana/grafana:13.2.5 sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84 (2026-10-27; 13.3.0 skipped as one day old)
|
||||
- quay.io/prometheus/node-exporter:v1.12.1 sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0 (2026-07-14)
|
||||
- quay.io/prometheus/blackbox-exporter:v0.29.1 sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13 (2026-10-21)
|
||||
|
||||
## Local validation 2026-10-28 (laptop Docker 29.8.2)
|
||||
|
||||
- docker compose config --quiet: monitoring and deploy valid; promtool check config SUCCESS; caddy validate: Valid configuration.
|
||||
- Grafana smoke run: first run rejected "{{ $$labels.instance }}" (bad character $); fixed to {{ .Labels.instance }}; rerun: both rules health ok, probes Normal from laptop, disk rule Pending (NoData) without node-exporter, dashboard group1-sre in folder SRE.
|
||||
|
||||
## Deploy 2026-10-28 (UTC)
|
||||
|
||||
- Issue #19; branch feature/issue-19-monitoring from main 9b0dc4d (Jenkins pipeline/head + Automated Manual Build success on 9b0dc4d).
|
||||
- 14:40:23 second swapfile: /swapfile2 1 GiB added (fstab); swap total 2147475456 B. Disk 24883167232 B, 17710153728 B available after.
|
||||
- 14:40:40 backup ~/gitea/backup-20261028T144040Z (docker-compose.yml, Caddyfile). Staged files validated on droplet (caddy validate: Valid configuration; compose config valid). Diffs = probe network + aliases; ci allowlist +172.30.90.10/32; metrics block.
|
||||
- 14:40:57-14:41:09 `docker compose up -d --no-deps caddy` (recreate). gitea_probe 172.30.90.0/28; caddy gitea_probe=172.30.90.2 (aliases git/ci), gitea_web=172.18.0.3. Let's Encrypt: "certificate obtained successfully" metrics.yebilly.me. Laptop: git 200 0.049s, ci 200 0.289s, metrics 502 (Grafana not started).
|
||||
- docker-proxy now targets 172.30.90.2 (probe network) for 80/443; IPv6/hairpin clients would appear as 172.30.90.1, not allowlisted (only .10/32).
|
||||
- ~/monitoring copied (700). .env.secret created by Billy: 600 root; names GF_SECURITY_ADMIN_PASSWORD, DISCORD_WEBHOOK_URL; no empty values; no "$".
|
||||
- 14:50:45-14:51:51 pull. promtool: SUCCESS. RepoDigests (amd64) match pins; sizes: prometheus 381400167, grafana 1949552290, node-exporter 40992821, blackbox 58273564 B. Before up: avail 241209344 B, swap used 520241152 B; disk 39% used.
|
||||
- 14:52:04-14:52:08 `docker compose up -d`. Samples (avail MiB / swap used MiB): 14:52:23 228/578, 14:52:43 230/666, 14:53:02 159/668, 14:53:22 195/692, 14:53:40 211/700, 14:53:57 218/700, 14:54:14 189/705, 14:54:32 156/707. Peaks: grafana 136.6/192 MiB, prometheus 26.6/128, blackbox 15.3/32, node-exporter 13.6/32. No OOM in dmesg. Within abort limits.
|
||||
- Grafana "permission denied" on /etc/grafana/provisioning/* (scp-created 700 dirs). Fix 14:55: dirs 755 / files 644 under grafana, prometheus, blackbox; restart 14:55:08; provisioning datasources, alerting, dashboards finished.
|
||||
- Targets (14:5x): prometheus, node, blackbox, https x2 all up. probe_success 1 both; status 200; duration ci 0.686s, git 0.193s.
|
||||
- 14:56: rules "HTTPS service down" (ci, git Normal) and "Root disk space low" (Normal), health ok; contact point team-alerts discord url set; dashboard Group 1 SRE /d/group1-sre.
|
||||
- Host verification 14:56:37: root fs labels device=/dev/vda1 fstype=ext4 mountpoint=/; size 24883167232 = df; avail 15281520640 vs df 15281516544. MemTotal 1008177152 = free total; MemAvailable 293392384 vs free available 301010944 (seconds apart).
|
||||
- Laptop after start: git 200 0.53s, ci 200 0.064s, metrics /login 200 1.68s, metrics /metrics 302.
|
||||
|
||||
## External exposure tests 2026-10-28 14:57 UTC (Billy's laptop, home network on the team allowlist, IPv6 available)
|
||||
|
||||
- Raw ports 3000, 3001, 8080, 9090, 9100, 9115, 50000 on 147.182.178.136 and [2604:a880:400:d1:0:5:22d:6001]: all no connection (curl 000, 5 s connect timeout).
|
||||
- https://metrics.yebilly.me/metrics -> 302 to /login?redirectTo=%2Fmetrics (GF_METRICS_ENABLED=false); /api/dashboards/uid/group1-sre -> 401; /api/datasources/proxy/uid/prometheus/api/v1/query?query=up -> 401 (no anonymous access).
|
||||
- https://git.yebilly.me/metrics -> 404; https://ci.yebilly.me/prometheus/ -> 403 (no app metrics endpoints).
|
||||
- http://metrics.yebilly.me -> 308 to https.
|
||||
- IPv6 (--resolve to droplet IPv6, no AAAA records): ci /login 403, metrics /login 403, git /user/login 200. IPv4 from allowlisted laptop: ci 200, metrics 200. Confirms docker-proxy gateway (172.30.90.1) is not allowlisted.
|
||||
|
||||
## Grafana login and contact-point test 2026-10-28
|
||||
|
||||
- ~15:01 UTC (11:01 EDT): Billy logged in at https://metrics.yebilly.me as billy; dashboard Group 1 SRE showed all 7 panels with data (screenshot).
|
||||
- Contact point is provisioned, so the UI offers no Test button. Legacy POST /api/alertmanager/grafana/config/api/v1/receivers/test -> 410 Gone ("use /apis/notifications.alerting.grafana.app/v1beta1/namespaces/{namespace}/receivers/{uid}/test").
|
||||
- One failed admin auth at ~15:04 UTC from the droplet host (password read from file included compose-trimmed whitespace); later calls used the container's environment.
|
||||
- 15:05:55 UTC: POST .../receivers/dGVhbS1hbGVydHM/test with integration team-alerts-discord, secureFields.url=true -> {"status":"success","duration":"866ms"}.
|
||||
|
||||
## Normal Jenkins build vs host metrics 2026-10-28 (UTC; EDT = UTC-4)
|
||||
|
||||
- Before (15:10:40): cpu 48.6% (2m rate, during a periodic burst), MemAvailable 169.3 MiB, swap used 651.4 MiB; jenkins 348.3 MiB, 0.15% CPU.
|
||||
- Commit d3a5e6b pushed by Billy; Gitea statuses on d3a5e6b: pending 15:17:36, pending 15:17:51, success 15:17:53 (vpn-dns-gateway/pipeline/head).
|
||||
- Jenkins vpn-dns-gateway » feature/issue-19-monitoring #1: queued 15:17:33.9, started 15:17:41.3, duration 11.825 s, finished ~15:17:53.1, SUCCESS, "Ran 2 tests ... OK". Executed on the controller (built-in node; workspace /var/jenkins_home/workspace/eway_feature_issue-19-monitoring), single executor, no agents.
|
||||
- Prometheus 30 s samples 15:12:00-15:22:00 (cpu = 100*(1-avg(rate(idle[1m]))), MiB, MiB, load1):
|
||||
15:12:00 38.5/186/652/0.79, 15:13:00 48.8/205/710/0.41, 15:14:00 8.3/224/708/0.15, 15:15:00 38.8/136/673/0.38, 15:16:00 15.0/169/695/0.14, 15:16:30 8.3/175/688/0.15, 15:17:00 39.4/104/650/0.29, **15:17:30 19.0/116/675/0.33, 15:18:00 32.1/196/691/0.41 (build window)**, 15:18:30 43.7/221/680/0.31, 15:19:00 46.4/133/652/0.84, 15:20:00 17.1/221/702/0.51, 15:21:00 35.7/114/651/0.47, 15:22:00 11.2/209/691/0.21.
|
||||
- Result: no change attributable to the 11.8 s build; it is shorter than the 30 s scrape interval and its samples fall inside the background range (8-49%). Whole-host measurements cannot attribute CPU/RAM to Jenkins.
|
||||
- Background pattern: bursts about every 2 min (CPU 35-49%, MemAvailable -80..-120 MiB). docker stats 15:23:39-15:25:47 every ~8 s: containers mostly <2% CPU; burst at 15:24:38-15:24:46 = gitea 13.7% CPU, 23->93 MiB, grafana 15.4%, 73->140 MiB, MemAvailable 118 MiB.
|
||||
- CPU by mode, 15 min to ~15:26: idle 74.3%, iowait 14.7%, system 4.5%, user 4.0%, steal 1.6%. vmstat burst: si 2189 pages/s, wa 10%. Interpretation: memory pressure causes swap-in I/O wait; CPU work itself is ~8.5%.
|
||||
- Dashboard v2 (15:26): CPU panel adds "of which I/O wait" = 100*avg(rate(node_cpu_seconds_total{mode="iowait"}[2m])).
|
||||
|
||||
## Capacity alert test (Root disk space low) 2026-10-28 (UTC; EDT = UTC-4)
|
||||
|
||||
- Before: rule inactive, instance Normal since 14:56:20. Root fs ~61% available. Final file backed up on the droplet.
|
||||
- 15:36:48 temporary change on the droplet only: threshold `lt 15` -> `lt 70` in grafana/provisioning/alerting/sre.yaml; POST /api/admin/provisioning/alerting/reload -> "Alerting config reloaded" (no restart). Git kept 15.
|
||||
- 15:36:50 Pending; polled every ~15 s; 15:41:50 Alerting/firing (pending period 5 m as configured). Notification expected ~15:42:00 (group_wait 10 s).
|
||||
- 15:42:24 restored `lt 15` from the backup; reload -> "Alerting config reloaded". 15:42:41 rule inactive, no instances; Grafana Alertmanager active alerts: [] (resolved).
|
||||
- Droplet rule file SHA-256 1614a4490202de44ec75c958ade3b79a3c207cc60e712a6be9804f3f01e49d9e = Git working copy.
|
||||
- Side note: 15:30:05 GET /api/annotations returned 500 after 3.96 s during a dashboard load (memory pressure).
|
||||
- Discord #devops-alerts (screenshots): 11:42 EDT "[FIRING:1] Root disk space low" Value A=61.343850329350225, C=1, labels device=/dev/vda1 fstype=ext4 mountpoint=/ owner=billy severity=warning, runbook_url present; then "[RESOLVED] Root disk space low" with grafana_state_reason=Updated (resolution came from the restored rule definition; at that moment free space 61.3% > 15%, so the restored condition is false). The summary text is static ("below 15% free") and did not reflect the temporary 70% threshold.
|
||||
|
||||
## Controlled incident: Jenkins outage 2026-10-28 (UTC; EDT = UTC-4)
|
||||
|
||||
- Pre-check: no Jenkins build process (python3/sh/git/durable) in gitea-jenkins-1; ci probe 1; HTTPS rule instances ci Normal, git Normal. (A first attempt aborted before injection because the check matched the ps header line.)
|
||||
- 16:05:00 INJECT `cd ~/gitea && docker compose stop jenkins`; container stopped 16:05:06.
|
||||
- Prometheus ci probe_success samples: 16:04:50 = 1; 16:05:20 = 0 (first failing probe); 0 at 16:05:50, 16:06:20, 16:06:50.
|
||||
- probe_http_status_code (ci): 200 at 16:04:20, 16:04:50; 502 (Caddy, upstream down) 16:05:20-16:09:50; 0 (no HTTP response while Jenkins was starting) at 16:10:20; 200 at 16:10:50.
|
||||
- Grafana rule HTTPS service down, instance ci: Normal until ~16:05:48; Pending observed 16:05:54; Alerting observed 16:06:52 (poll every ~6 s). Gitea instance Normal throughout.
|
||||
- 16:07 (12:07 PM EDT) Discord "[FIRING:1] HTTPS service down SRE https://ci.yebilly.me/login (https billy critical)", Value A=0, C=1, runbook_url present (screenshot).
|
||||
- Acknowledgement: Billy sent the FIRING screenshot to the operator (Claude session) before the restart; a Discord "ack" reply was posted afterward (its timestamp is later than the restart).
|
||||
- 16:09:48 RESTART `cd ~/gitea && docker compose start jenkins` (4 min 48 s after injection).
|
||||
- Jenkins log: 16:10:45.113 "Completed initialization"; 16:10:45.275 "Jenkins is fully up and running".
|
||||
- ci probe_success: 0 at 16:09:50, 16:10:20; 1 at 16:10:50 (first successful probe). Rule ci instance Alerting until ~16:11:20; Normal observed 16:11:27. Gitea instance Normal throughout.
|
||||
- (Host-side check with --resolve to 127.0.0.1 returned 403 throughout: the droplet's own loopback request arrives through docker-proxy as the probe gateway 172.30.90.1, which the allowlist denies. Not a service signal.)
|
||||
- Measured: injection -> first failing sample 20 s; injection -> firing ~1 m 52 s (16:06:52); injection -> Discord ~2 m (16:07); restart -> Jenkins fully up 57 s; restart -> first successful probe sample 62 s; restart -> rule Normal ~1 m 32-39 s; probe-observed outage 16:05:20 -> 16:10:50 (5 m 30 s). Configured worst-case detection = scrape 30 s + evaluation 30 s + pending 60 s + group_wait 10 s = 2 m 10 s; observed ~2 m.
|
||||
- 16:12 (12:12 PM EDT) Discord "[RESOLVED] HTTPS service down SRE https://ci.yebilly.me/login", Value A=1, C=0 (resolved by evaluation, no state-reason override) (screenshot). Notification receipt -> resolved message ~5 m.
|
||||
- 16:11:46 laptop: https://ci.yebilly.me/login 200 0.254 s; https://git.yebilly.me/user/login 200 0.050 s.
|
||||
|
||||
## Restart persistence 2026-10-28 (UTC)
|
||||
|
||||
- Before 16:12:05: oldest TSDB sample 14:52:16; 160 `up{job="prometheus"}` samples in 2 h; dashboard Group 1 SRE v2 (7 panels); data source Prometheus http://prometheus:9090; rules HTTPS service down + Root disk space low (inactive); contact point team-alerts.
|
||||
- 16:12:09 `docker compose restart prometheus`; answering 16:12:15. After: oldest sample still 14:52:16 (history kept on volume monitoring_prometheus_data). Raw scrapes node 16:11:36, 16:12:06, 16:12:36, 16:13:06; https 16:11:50, 16:12:20, 16:12:50: no gap > 35 s (restart fell between scrapes).
|
||||
- 16:12:56 `docker compose restart grafana`; at 16:13:44 dashboard v2 7 panels, data source, both rules, contact point all present; admin login unchanged (volume monitoring_grafana_data). A restart shows persistence, not a backup restore.
|
||||
|
||||
## SLI short window around the incident (UTC)
|
||||
|
||||
- Window [10m] 16:03:00-16:13:00, evaluation time 2026-10-28 16:13:00 UTC, scrape interval 30 s (expected ~20 samples). Queries: 100*avg_over_time(probe_success{job="https",instance="<url>"}[10m]), count_over_time(...), sum_over_time(...).
|
||||
- Gitea https://git.yebilly.me/user/login: 100% (20 received, 20 successes).
|
||||
- Jenkins https://ci.yebilly.me/login: 45% (20 received, 9 successes, 11 failures). Raw: 1 at 16:03:20-16:04:50; 0 at 16:05:20-16:10:20; 1 at 16:10:50-16:12:50. No missing samples, so no unknown time; boundary: the first sample in the window is 16:03:20.
|
||||
- (First attempt evaluated at the wrong epoch, 16:23:00, giving 100%/20 for both; rerun with date -d.)
|
||||
|
||||
## Post-recovery verification (UTC)
|
||||
|
||||
- Billy pushed b6cf080 (d3a5e6b..b6cf080) after re-authorising Git Credential Manager (stale OAuth refresh token removed).
|
||||
- Gitea status vpn-dns-gateway/pipeline/head on b6cf080: pending 16:36:27, success 16:37:08 (webhook + status integration working after the outage).
|
||||
- Jenkins feature/issue-19-monitoring #2: start 16:36:34.6, duration 33.923 s, SUCCESS, "Ran 2 tests ... OK", commit b6cf08061815acd628bf3caaa90e38c46d57a8e7 (slower than #1's 11.8 s, consistent with swap pressure after the restarts).
|
||||
- Manual PDF build (Gitea Actions, runner latex-local on Vincent's laptop) runs only on pushes to main; it is verified at merge.
|
||||
|
||||
## Improvement issues from the blameless review
|
||||
|
||||
- #20 "Add an off-droplet uptime check for git, ci, and metrics" (priority 1, owner @vsun1) and #21 "Remove swap churn on The-Ocean (memory headroom)" (priority 2, owner @bill), opened by bill 2026-10-28.
|
||||
|
||||
## Grafana accounts
|
||||
|
||||
- 2026-10-28 17:03:14 UTC Billy created Grafana user vsun1 (Vincent Sun), org role Viewer, not server admin. Org users: billy Admin, vsun1 Viewer.
|
||||
|
||||
## Grafana administrator password replaced
|
||||
|
||||
- ~17:2x UTC Billy changed the billy password in Grafana (Profile -> Change password); the new value is only in his password manager and Grafana's database.
|
||||
- 17:29:34 UTC the previous value (still in the running container's environment) returned HTTP 401 on /api/user: the initial credential is no longer valid.
|
||||
- GF_SECURITY_ADMIN_PASSWORD line removed from ~/monitoring/.env.secret (now only DISCORD_WEBHOOK_URL; mode 600 root); `docker compose config --quiet` valid. The stale value leaves the container environment at the next Grafana recreate.
|
||||
|
||||
## Audit follow-up checks 2026-10-28 (UTC)
|
||||
|
||||
- Baseline detail (first sample 04:34:10): free -b available 154066944 B (146.9 MiB), swap used 434180096 B (414.1 MiB); second sample 04:34:27 available 229351424 B (218.7 MiB). Docker 29.8.1, Compose v5.5.1, kernel 6.8.0-147-generic.
|
||||
- 14:56 target check: all five targets up, lastError none, lastScrapeDuration 0.031-0.226 s.
|
||||
- 17:30:59 CPU counters, /proc/stat (USER_HZ 100) vs node_cpu_seconds_total: user 4100.8 / 4099.5 s, system 1768.9 / 1768.0, idle 562052.6 / 562034.4, iowait 2080.2 / 2078.2, steal 1727.5 / 1726.4 (difference consistent with the <=30 s scrape age).
|
||||
- 17:3x targets: blackbox 0.004 s, https git 0.128 s, https ci 0.064 s, node 0.062 s, prometheus 0.022 s; all up, no error.
|
||||
- Container identities and mounts: prometheus uid 65534 (nobody), /prometheus = volume monitoring_prometheus_data, /etc/prometheus/prometheus.yml bind ro; grafana uid 472, /var/lib/grafana = volume monitoring_grafana_data, /etc/grafana/provisioning and /var/lib/grafana-dashboards bind ro; node-exporter uid 65534, /host bind ro; blackbox-exporter uid 0 (image default), /config/blackbox.yml bind ro -> changed to user 65534:65534 (see below).
|
||||
|
||||
## Collection-health rule and non-root Blackbox (UTC)
|
||||
|
||||
- Local smoke run: new rule "Monitoring target down" (expr `up`, < 1 for 1 m, no data -> Alerting, error -> Error) loaded healthy and went Pending for the absent node target; blackbox-exporter as uid 65534 probed successfully.
|
||||
- 17:33:23 deployed sre.yaml (third rule), compose.yaml (blackbox `user: "65534:65534"`), README (runbook, password prompt); `docker compose up -d grafana blackbox-exporter`. 17:33:57 "finished to provision alerting", no errors. blackbox id uid=65534(nobody). Old admin password no longer in the Grafana container environment. 17:34:15 all five targets up.
|
||||
|
||||
## Collection-health test: Blackbox Exporter stopped (UTC; EDT = UTC-4)
|
||||
|
||||
- Pre: up blackbox=1, prometheus=1, https=1 (x2), node=1.
|
||||
- 17:34:44 INJECT `docker compose stop blackbox-exporter`.
|
||||
- 17:34:56 first failed scrape: up blackbox=0, one https target 0; 17:35:07 both https targets 0; count(probe_success) returned no series from 17:35:07 until the restore (probe series absent, not 0).
|
||||
- 17:37:52 RESTORE `docker compose start blackbox-exporter`; 17:38:25 all five targets up; blackbox uid 65534.
|
||||
- Grafana alert state could not be read through the API (admin password now known only to Billy); notifications are evidenced by the Discord screenshots.
|
||||
- Discord #devops-alerts (screenshots), EDT: 1:36 PM "[FIRING:1] Monitoring target down" instance blackbox-exporter:9115 job blackbox, A=0; same minute "[FIRING:1] HTTPS service down" for ci and for git with grafana_state_reason=NoData, A=-1 (probe series absent -> no-data policy Alerting); 1:37 PM "[FIRING:3] Monitoring target down" (blackbox plus both https targets); RESOLVED (A=1) for HTTPS service down git and ci (1:39 PM for ci) and "[RESOLVED] Monitoring target down" for all three at 1:39 PM.
|
||||
|
||||
## Review gate on PR #22 (UTC)
|
||||
|
||||
- PR #22 feature/issue-19-monitoring -> main, opened by Billy.
|
||||
- Gitea reviews: vsun1 APPROVED 17:09:21 (head b6cf080) and 17:13:53 (head 336eaae); each dismissed as stale when a later commit arrived (branch protection dismisses stale approvals).
|
||||
- vpn-dns-gateway/pipeline/pr-main: success on 336eaae at 17:12:32; success on 249488d by 17:54:22. Merge still requires a fresh approval of the final head.
|
||||
- 17:56 live verification: deployed config files byte-identical to Git (9 files, SHA-256); running containers match documented users, memory caps, networks, no host ports except Caddy, no Docker socket, not privileged; image digests match pins; 3 alert rules in grafana.db (for 60 s / 60 s / 300 s, no data -> Alerting, error -> Error); users billy (admin), vsun1; 0 OOM events.
|
||||
@@ -0,0 +1,151 @@
|
||||
# Monitoring (Assignment 7 / Instructor Manual Chapter 5)
|
||||
|
||||
Assignment 8 prepares a production pricing `/health` target and Grafana panel
|
||||
in the versioned configuration. Apply those additions only after the service
|
||||
is healthy; they are not yet deployed. See `../delivery/RUNBOOKS.md`.
|
||||
|
||||
Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter on the droplet
|
||||
**The-Ocean**, beside Gitea, Jenkins, and Caddy (`deploy/`). Grafana is the only
|
||||
web entry point: `https://metrics.yebilly.me` (same allowlist as Jenkins, then
|
||||
Grafana login). No monitoring port is published on the host.
|
||||
|
||||
| Service | Image (pinned in `compose.yaml`) | Private address | Networks | Memory cap | State |
|
||||
|---|---|---|---|---|---|
|
||||
| Prometheus | `prom/prometheus:v3.15.1` | `prometheus:9090` | monitoring | 128 MiB | volume `monitoring_prometheus_data` (7 d / 500 MB) |
|
||||
| Grafana OSS | `grafana/grafana:13.2.5` | `grafana:3000` | monitoring, `gitea_web` | 192 MiB | volume `monitoring_grafana_data` |
|
||||
| Node Exporter | `quay.io/prometheus/node-exporter:v1.12.1` | `node-exporter:9100` | monitoring | 32 MiB | none (read-only host `/`) |
|
||||
| Blackbox Exporter | `quay.io/prometheus/blackbox-exporter:v0.29.1` | `blackbox-exporter:9115`, `172.30.90.10` | monitoring, `gitea_probe` | 32 MiB | none |
|
||||
|
||||
Configuration in Git: `prometheus/prometheus.yml`, `blackbox/blackbox.yml`,
|
||||
`grafana/provisioning/` (data source, dashboard provider, alert rules, contact
|
||||
point), and `grafana/dashboards/sre.json`. Provisioned items are read-only in
|
||||
the UI; change them here, copy to the droplet, and restart Grafana.
|
||||
|
||||
## Secrets (never in Git)
|
||||
|
||||
`~/monitoring/.env.secret` on the droplet, mode `600`, owner root:
|
||||
|
||||
```
|
||||
GF_SECURITY_ADMIN_PASSWORD=<from the team password manager>
|
||||
DISCORD_WEBHOOK_URL=<webhook for #devops-alerts>
|
||||
```
|
||||
|
||||
The admin password applies only when Grafana first creates its database. At
|
||||
first login, change it in Grafana (Profile → Change password), store the new
|
||||
value in the password manager, and delete the `GF_SECURITY_ADMIN_PASSWORD`
|
||||
line from `.env.secret`; on The-Ocean this was done on 28 Oct 2026.
|
||||
|
||||
## Deploy
|
||||
|
||||
Prerequisite: `deploy/` is current on the droplet and Caddy has been recreated
|
||||
once (`cd ~/gitea && docker compose up -d caddy`), which creates the
|
||||
`gitea_probe` network and the `metrics.yebilly.me` route.
|
||||
|
||||
```bash
|
||||
scp -r monitoring root@<droplet-ip>:~/monitoring # from the laptop
|
||||
cd ~/monitoring && chmod 700 .
|
||||
# scp from Windows creates 700 directories; Grafana (uid 472) must read its config.
|
||||
find grafana prometheus blackbox -type d -exec chmod 755 {} + && find grafana prometheus blackbox -type f -exec chmod 644 {} +
|
||||
install -m 600 /dev/null .env.secret && nano .env.secret # typed by a team member
|
||||
docker compose config --quiet
|
||||
docker compose pull
|
||||
docker compose run --rm --no-deps --entrypoint /bin/promtool prometheus check config /etc/prometheus/prometheus.yml
|
||||
docker compose up -d
|
||||
docker compose ps
|
||||
docker compose logs --tail=50 prometheus grafana node-exporter blackbox-exporter
|
||||
docker image inspect --format '{{.RepoDigests}}' prom/prometheus:v3.15.1 # repeat per image
|
||||
```
|
||||
|
||||
Startup order does not matter: Grafana retries the data source and Prometheus
|
||||
retries scrapes. All four services restart `unless-stopped`.
|
||||
|
||||
## Operate, update, back up, roll back
|
||||
|
||||
- Pause/resume: `docker compose stop` / `docker compose start`. **Never**
|
||||
`docker compose down -v`; it deletes both named volumes.
|
||||
- Config change: edit in Git, copy the file, then
|
||||
`docker compose restart prometheus` (or `grafana`). Validate Prometheus config
|
||||
with the `promtool` line above first.
|
||||
- Upgrade one image at a time: back up, read the release notes, change the tag
|
||||
and digest in `compose.yaml`, `docker compose pull <svc> && docker compose up -d <svc>`,
|
||||
then check targets, dashboard, and alert rules. Do not assume an older Grafana
|
||||
or Prometheus can read data written by a newer one: restore the backup instead.
|
||||
- Contact-point test (the provisioned contact point has no Test button in the UI;
|
||||
Grafana 13 removed the old test endpoint). Sends one message to `#devops-alerts`
|
||||
using the stored URL, which is never printed:
|
||||
|
||||
```bash
|
||||
GIP=$(docker inspect monitoring-grafana-1 --format '{{(index .NetworkSettings.Networks "monitoring_monitoring").IPAddress}}')
|
||||
read -rs -p 'Grafana password for billy: ' P; echo # typed, never stored
|
||||
curl -s -u "billy:$P" -H 'Content-Type: application/json' -X POST \
|
||||
-d '{"integration":{"uid":"team-alerts-discord","type":"discord","version":"v1","settings":{},"secureFields":{"url":true}}}' \
|
||||
"http://$GIP:3000/apis/notifications.alerting.grafana.app/v1beta1/namespaces/default/receivers/dGVhbS1hbGVydHM/test"
|
||||
unset P # expect {"status":"success",...}; dGVhbS1hbGVydHM is base64 of "team-alerts"
|
||||
```
|
||||
|
||||
- Backup (state not rebuildable from Git: Grafana users/passwords, alert state,
|
||||
metric history):
|
||||
|
||||
```bash
|
||||
cd ~/monitoring && docker compose stop grafana prometheus
|
||||
docker run --rm -v monitoring_grafana_data:/g:ro -v monitoring_prometheus_data:/p:ro \
|
||||
-v /root/backups:/b alpine:3.22 tar czf /b/monitoring-$(date -u +%Y%m%dT%H%M%SZ).tgz /g /p
|
||||
docker compose start grafana prometheus
|
||||
```
|
||||
|
||||
Restore (same image versions only): `docker compose stop grafana prometheus`,
|
||||
empty both volumes, then
|
||||
`docker run --rm -v monitoring_grafana_data:/g -v monitoring_prometheus_data:/p -v /root/backups:/b alpine:3.22 tar xzf /b/monitoring-<stamp>.tgz -C /`
|
||||
and `docker compose start grafana prometheus`.
|
||||
|
||||
- Remove the stack entirely: `docker compose stop && docker compose rm -f`
|
||||
(volumes kept), then revert the `metrics` block and probe allowlist entry in
|
||||
`deploy/Caddyfile` and recreate Caddy.
|
||||
|
||||
## Runbook: Monitoring target down
|
||||
|
||||
Alert `Monitoring target down` (critical, owner Billy, backup Vincent): a
|
||||
Prometheus scrape target (`up`) has failed for 1 minute, or no target data
|
||||
exists. While it fires, the dashboard and the other alerts are partly blind.
|
||||
|
||||
1. Acknowledge in `#devops-alerts` with your name and the time.
|
||||
2. The `job` label names the broken collector: `blackbox` or `https` means
|
||||
Blackbox Exporter, `node` means Node Exporter, `prometheus` means Prometheus.
|
||||
3. On the droplet: `cd ~/monitoring && docker compose ps`, then
|
||||
`docker compose logs --tail=50 <service>`.
|
||||
4. Stopped: `docker compose start <service>`. Running but failing:
|
||||
`docker compose restart <service>`. Never use `down -v`.
|
||||
5. Confirm all targets are up again (dashboard *Scrape health* panel) and that
|
||||
Discord shows the resolved message.
|
||||
|
||||
## Runbook: HTTPS service down
|
||||
|
||||
Alert `HTTPS service down` (critical, owner Billy, backup Vincent): a login
|
||||
page's `probe_success` has been 0 for 1 minute. If the probe series disappears
|
||||
instead, this rule can resolve; `Monitoring target down` reports that case.
|
||||
|
||||
1. Acknowledge in `#devops-alerts` with your name and the time.
|
||||
2. Open the `Group 1 SRE` dashboard. Is only one service down, or both?
|
||||
- Both down, and the scrape health panel also shows failures: check Caddy and the droplet first.
|
||||
- Missing data rather than 0: the monitoring stack itself is failing (`docker compose ps` in `~/monitoring`).
|
||||
3. On the droplet: `cd ~/gitea && docker compose ps`, then `docker compose logs --tail=50 <gitea|jenkins|caddy>`.
|
||||
4. If the service container is stopped: `docker compose start <service>`. If it
|
||||
is running but unhealthy: `docker compose restart <service>`. Never use
|
||||
`down -v`.
|
||||
5. Confirm the probe returns to 1 and Discord shows the resolved message. For
|
||||
Jenkins, also run a pipeline and confirm the Gitea status check.
|
||||
6. Record the timeline in the incident log or manual.
|
||||
|
||||
## Runbook: Root disk space low
|
||||
|
||||
Alert `Root disk space low` (warning, owner Billy): available space on `/`
|
||||
(`/dev/vda1`, ext4) has stayed below 15% for 5 minutes. 15% of 24.9 GB is
|
||||
about 3.7 GB: enough to act before Gitea, Jenkins, or Prometheus fail to write.
|
||||
|
||||
1. Acknowledge in `#devops-alerts`.
|
||||
2. `df -h /` and `docker system df` to find the growth.
|
||||
3. Safe first actions: `docker builder prune` (build cache), `journalctl --vacuum-size=200M`,
|
||||
remove obsolete images with `docker image prune`. Do not delete volumes.
|
||||
4. Prometheus is capped at 500 MB / 7 days; if it is the cause, lower the cap
|
||||
rather than deleting its volume.
|
||||
5. If space cannot be recovered, plan a disk resize (permanent, costs more) with the team.
|
||||
@@ -0,0 +1,14 @@
|
||||
# Success = DNS answer, valid certificate for the hostname, redirects followed,
|
||||
# and a final 2xx on the login page. TLS verification stays on.
|
||||
modules:
|
||||
http_2xx:
|
||||
prober: http
|
||||
timeout: 10s
|
||||
http:
|
||||
method: GET
|
||||
preferred_ip_protocol: ip4
|
||||
valid_status_codes: [] # empty = any 2xx
|
||||
follow_redirects: true
|
||||
fail_if_not_ssl: true
|
||||
tls_config:
|
||||
insecure_skip_verify: false
|
||||
@@ -0,0 +1,97 @@
|
||||
# Monitoring stack on The-Ocean (Assignment 7 / Instructor Manual Chapter 5).
|
||||
# Four project-published images, pinned by tag and digest (the repository ignores
|
||||
# .env files, so versions live here). No service publishes a host port:
|
||||
# Caddy reaches grafana:3000 on gitea_web; Prometheus and the exporters stay on
|
||||
# the private "monitoring" network. Pause with stop/start; never "down -v".
|
||||
name: monitoring
|
||||
|
||||
services:
|
||||
prometheus:
|
||||
image: prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=7d
|
||||
- --storage.tsdb.retention.size=500MB # whichever limit is hit first
|
||||
environment:
|
||||
- GOMEMLIMIT=96MiB # Go GC target below the container cap
|
||||
volumes:
|
||||
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- prometheus_data:/prometheus
|
||||
networks: [monitoring]
|
||||
mem_limit: 128m
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:13.2.5@sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84
|
||||
restart: unless-stopped
|
||||
# Root-only, untracked: GF_SECURITY_ADMIN_PASSWORD and DISCORD_WEBHOOK_URL (see README).
|
||||
env_file: [.env.secret]
|
||||
environment:
|
||||
GF_SERVER_ROOT_URL: https://metrics.yebilly.me/
|
||||
GF_SECURITY_ADMIN_USER: billy
|
||||
GF_SECURITY_COOKIE_SECURE: "true"
|
||||
GF_SECURITY_DISABLE_GRAVATAR: "true"
|
||||
GF_AUTH_ANONYMOUS_ENABLED: "false"
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
GF_METRICS_ENABLED: "false" # no public /metrics through the HTTPS hostname
|
||||
# 1 GiB droplet: skip plugin downloads, news, and phone-home checks.
|
||||
GF_PLUGINS_PREINSTALL_DISABLED: "true"
|
||||
GF_NEWS_NEWS_FEED_ENABLED: "false"
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: "false"
|
||||
GOMEMLIMIT: 150MiB
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./grafana/dashboards:/var/lib/grafana-dashboards:ro
|
||||
networks: [monitoring, web]
|
||||
mem_limit: 192m
|
||||
|
||||
node-exporter:
|
||||
image: quay.io/prometheus/node-exporter:v1.12.1@sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0
|
||||
restart: unless-stopped
|
||||
pid: host
|
||||
command:
|
||||
- --path.rootfs=/host
|
||||
- --path.procfs=/host/proc
|
||||
- --path.sysfs=/host/sys
|
||||
# Only what the dashboard and alerts use: CPU, memory, root disk.
|
||||
- --collector.disable-defaults
|
||||
- --collector.cpu
|
||||
- --collector.meminfo
|
||||
- --collector.filesystem
|
||||
- --collector.loadavg
|
||||
- --collector.uname
|
||||
volumes:
|
||||
- /:/host:ro,rslave # read-only host view; no Docker socket, not privileged
|
||||
networks: [monitoring]
|
||||
mem_limit: 32m
|
||||
|
||||
blackbox-exporter:
|
||||
image: quay.io/prometheus/blackbox-exporter:v0.29.1@sha256:ea1c7aa3ef3f307cd03e85f34abb604478ccb90b567fc690da0cd9776da76b13
|
||||
restart: unless-stopped
|
||||
user: "65534:65534" # image default is root; HTTP probes need no privileges
|
||||
command: ["--config.file=/config/blackbox.yml"]
|
||||
volumes:
|
||||
- ./blackbox/blackbox.yml:/config/blackbox.yml:ro
|
||||
networks:
|
||||
monitoring:
|
||||
probe:
|
||||
# The only private address allowed past the ci.yebilly.me allowlist.
|
||||
ipv4_address: 172.30.90.10
|
||||
mem_limit: 32m
|
||||
|
||||
networks:
|
||||
monitoring:
|
||||
web:
|
||||
external: true
|
||||
name: gitea_web
|
||||
probe:
|
||||
external: true
|
||||
name: gitea_probe # defined in deploy/docker-compose.yml; Caddy answers git/ci there
|
||||
|
||||
volumes:
|
||||
prometheus_data:
|
||||
grafana_data:
|
||||
@@ -0,0 +1,30 @@
|
||||
# External TCP evidence, 28 October 2026
|
||||
|
||||
Vincent ran the PowerShell loop in the Codex conversation on his external
|
||||
Wi-Fi connection, outside SSH. `ports-20261028-154000.csv` retains all 18
|
||||
connection outcomes and UTC completion timestamps from that run. Only the
|
||||
local Wi-Fi name in `Network` has been replaced by a generic description;
|
||||
the original CSV is retained under ignored `build/evidence/assignment7-port-tests/`.
|
||||
|
||||
The tests ran 19:32:40-19:40:00 UTC (15:32:40-15:40:00 EDT). TCP 443 and 80
|
||||
succeeded on both droplet addresses. TCP 3000, 3001, 8080, 9090, 9100, 9115,
|
||||
and 50000 failed on both. The 443 controls passed before the negative tests.
|
||||
These results establish reachability from the tested client network at that
|
||||
time; they do not identify which networking layer blocked a connection or
|
||||
test TLS, redirects, or application authentication.
|
||||
|
||||
`test-ports.ps1` preserves the executed loop as a reusable script, with network
|
||||
description and output location exposed as parameters. This saved script was
|
||||
syntax-checked; the historical evidence comes from Vincent's earlier run of
|
||||
the conversational loop, not a subsequent execution of this file.
|
||||
|
||||
To repeat from repository root in Windows PowerShell:
|
||||
|
||||
```powershell
|
||||
./monitoring/evidence/test-ports.ps1 -NetworkDescription 'External Wi-Fi'
|
||||
```
|
||||
|
||||
A failed HTTPS control makes that address family's remaining tests
|
||||
inconclusive and skips them. Keep the new date and results; do not replace
|
||||
the historical evidence. See Microsoft's
|
||||
[Test-NetConnection documentation](https://learn.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection?view=windowsserver2025-ps).
|
||||
@@ -0,0 +1,19 @@
|
||||
TimeUTC,Network,Target,Port,ExpectedReachable,TcpTestSucceeded,Result
|
||||
2026-10-28T19:32:40.4700276Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,443,True,True,MATCH
|
||||
2026-10-28T19:32:49.7334208Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,80,True,True,MATCH
|
||||
2026-10-28T19:33:24.9527541Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,3000,False,False,MATCH
|
||||
2026-10-28T19:34:00.0160397Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,3001,False,False,MATCH
|
||||
2026-10-28T19:34:35.0118147Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,8080,False,False,MATCH
|
||||
2026-10-28T19:35:10.1101959Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,9090,False,False,MATCH
|
||||
2026-10-28T19:35:44.9897149Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,9100,False,False,MATCH
|
||||
2026-10-28T19:36:19.9643517Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,9115,False,False,MATCH
|
||||
2026-10-28T19:36:54.9233170Z,External Wi-Fi (Vincent laptop; local network name redacted),147.182.178.136,50000,False,False,MATCH
|
||||
2026-10-28T19:36:55.4230345Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,443,True,True,MATCH
|
||||
2026-10-28T19:36:55.8361207Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,80,True,True,MATCH
|
||||
2026-10-28T19:37:22.1944035Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,3000,False,False,MATCH
|
||||
2026-10-28T19:37:48.6712583Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,3001,False,False,MATCH
|
||||
2026-10-28T19:38:15.0191304Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,8080,False,False,MATCH
|
||||
2026-10-28T19:38:41.1817674Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,9090,False,False,MATCH
|
||||
2026-10-28T19:39:07.6837526Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,9100,False,False,MATCH
|
||||
2026-10-28T19:39:34.1413090Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,9115,False,False,MATCH
|
||||
2026-10-28T19:40:00.0333941Z,External Wi-Fi (Vincent laptop; local network name redacted),2604:a880:400:d1:0:5:22d:6001,50000,False,False,MATCH
|
||||
|
@@ -0,0 +1,39 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$NetworkDescription,
|
||||
[string]$OutputDirectory = 'build/evidence/assignment7-port-tests'
|
||||
)
|
||||
|
||||
# Run on an external Windows client, outside the droplet's SSH session.
|
||||
# Use a generic network description; do not include a personal address or SSID.
|
||||
$targets = @('147.182.178.136', '2604:a880:400:d1:0:5:22d:6001')
|
||||
$results = @()
|
||||
foreach ($target in $targets) {
|
||||
foreach ($port in @(443, 80, 3000, 3001, 8080, 9090, 9100, 9115, 50000)) {
|
||||
Write-Host "Testing $target port $port..."
|
||||
$test = Test-NetConnection -ComputerName $target -Port $port `
|
||||
-InformationLevel Detailed -WarningAction SilentlyContinue
|
||||
$reachable = [bool]$test.TcpTestSucceeded
|
||||
$expected = $port -in @(80, 443)
|
||||
$result = [pscustomobject]@{
|
||||
TimeUTC = (Get-Date).ToUniversalTime().ToString('o')
|
||||
Network = $NetworkDescription
|
||||
Target = $target
|
||||
Port = $port
|
||||
ExpectedReachable = $expected
|
||||
TcpTestSucceeded = $reachable
|
||||
Result = if ($port -eq 443 -and !$reachable) {
|
||||
'INCONCLUSIVE: HTTPS control failed'
|
||||
} elseif ($reachable -eq $expected) { 'MATCH' } else { 'UNEXPECTED' }
|
||||
}
|
||||
$results += $result
|
||||
$result | Format-Table Target, Port, TcpTestSucceeded, Result -AutoSize
|
||||
if ($port -eq 443 -and !$reachable) {
|
||||
Write-Host 'Skipping remaining ports for this address.'
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $OutputDirectory | Out-Null
|
||||
$file = Join-Path $OutputDirectory ("ports-{0}.csv" -f (Get-Date -Format 'yyyyMMdd-HHmmss'))
|
||||
$results | Export-Csv -LiteralPath $file -NoTypeInformation
|
||||
Write-Host "Results saved to $file"
|
||||
@@ -0,0 +1,660 @@
|
||||
{
|
||||
"uid": "group1-sre",
|
||||
"title": "Group 1 SRE",
|
||||
"tags": [
|
||||
"sre",
|
||||
"assignment7"
|
||||
],
|
||||
"timezone": "America/New_York",
|
||||
"refresh": "30s",
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"schemaVersion": 41,
|
||||
"version": 2,
|
||||
"editable": false,
|
||||
"graphTooltip": 1,
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "timeseries",
|
||||
"title": "Droplet CPU utilization (%)",
|
||||
"description": "Whole-droplet CPU busy %, averaged across CPUs: 100 minus the idle-time rate over 2m. Counts every workload on the host, not one container. The I/O wait line is the part spent waiting on disk (on this 1 GiB droplet, mostly swap-in), not computation.",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percent",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "linear",
|
||||
"thresholdsStyle": {
|
||||
"mode": "line"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0,
|
||||
"max": 100
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "100 * (1 - avg(rate(node_cpu_seconds_total{job=\"node\",mode=\"idle\"}[2m])))",
|
||||
"legendFormat": "CPU busy"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "100 * avg(rate(node_cpu_seconds_total{job=\"node\",mode=\"iowait\"}[2m]))",
|
||||
"legendFormat": "of which I/O wait"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "timeseries",
|
||||
"title": "Available memory (bytes)",
|
||||
"description": "MemAvailable: the kernel's estimate of memory available to start new applications without swapping (not just unused RAM).",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 0,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "linear",
|
||||
"thresholdsStyle": {
|
||||
"mode": "line"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "red",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "green",
|
||||
"value": 104857600
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "node_memory_MemAvailable_bytes{job=\"node\"}",
|
||||
"legendFormat": "available"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "timeseries",
|
||||
"title": "Root filesystem available (%)",
|
||||
"description": "Available bytes / size bytes for the host root filesystem (/dev/vda1, ext4, mounted at /). Alert fires below 15% for 5m.",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percent",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "linear",
|
||||
"thresholdsStyle": {
|
||||
"mode": "line"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "red",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "green",
|
||||
"value": 15
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0,
|
||||
"max": 100
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "100 * node_filesystem_avail_bytes{job=\"node\",mountpoint=\"/\",fstype=\"ext4\"} / node_filesystem_size_bytes{job=\"node\",mountpoint=\"/\",fstype=\"ext4\"}",
|
||||
"legendFormat": "/ available"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "timeseries",
|
||||
"title": "Gitea HTTPS availability (probe_success)",
|
||||
"description": "1 = Blackbox Exporter fetched the Gitea login page with valid TLS and a 2xx; 0 = the probe failed.",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 8,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "none",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "stepAfter",
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"mappings": [
|
||||
{
|
||||
"type": "value",
|
||||
"options": {
|
||||
"0": {
|
||||
"text": "DOWN",
|
||||
"color": "red"
|
||||
},
|
||||
"1": {
|
||||
"text": "UP",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "probe_success{job=\"https\",instance=\"https://git.yebilly.me/user/login\"}",
|
||||
"legendFormat": "Gitea"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "timeseries",
|
||||
"title": "Jenkins HTTPS availability (probe_success)",
|
||||
"description": "1 = Blackbox Exporter fetched the Jenkins login page with valid TLS and a 2xx; 0 = the probe failed.",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "none",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "stepAfter",
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"mappings": [
|
||||
{
|
||||
"type": "value",
|
||||
"options": {
|
||||
"0": {
|
||||
"text": "DOWN",
|
||||
"color": "red"
|
||||
},
|
||||
"1": {
|
||||
"text": "UP",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "probe_success{job=\"https\",instance=\"https://ci.yebilly.me/login\"}",
|
||||
"legendFormat": "Jenkins"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "timeseries",
|
||||
"title": "HTTPS probe duration (s)",
|
||||
"description": "Total time of each probe (DNS, connect, TLS, request), one line per service.",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 16,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "linear",
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "probe_duration_seconds{job=\"https\",instance=\"https://git.yebilly.me/user/login\"}",
|
||||
"legendFormat": "Gitea"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "probe_duration_seconds{job=\"https\",instance=\"https://ci.yebilly.me/login\"}",
|
||||
"legendFormat": "Jenkins"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"type": "timeseries",
|
||||
"title": "Scrape health (up)",
|
||||
"description": "Optional: 1 = Prometheus scraped the target. For the https job, up=1 can coexist with probe_success=0 (collection worked, the probed request failed).",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 24,
|
||||
"w": 24,
|
||||
"h": 6
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "none",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "stepAfter",
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"mappings": [
|
||||
{
|
||||
"type": "value",
|
||||
"options": {
|
||||
"0": {
|
||||
"text": "DOWN",
|
||||
"color": "red"
|
||||
},
|
||||
"1": {
|
||||
"text": "UP",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "up",
|
||||
"legendFormat": "{{job}} {{instance}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"type": "timeseries",
|
||||
"title": "Pricing production HTTPS availability (probe_success)",
|
||||
"description": "1 = production /health returned 2xx with valid TLS; pricing and source identity are verified separately by the release pipeline.",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 30,
|
||||
"w": 24,
|
||||
"h": 8
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "none",
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"lineWidth": 2,
|
||||
"fillOpacity": 10,
|
||||
"showPoints": "never",
|
||||
"lineInterpolation": "stepAfter",
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"mappings": [
|
||||
{
|
||||
"type": "value",
|
||||
"options": {
|
||||
"0": {
|
||||
"text": "DOWN",
|
||||
"color": "red"
|
||||
},
|
||||
"1": {
|
||||
"text": "UP",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "multi",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "probe_success{job=\"https\",instance=\"https://app.yebilly.me/health\"}",
|
||||
"legendFormat": "Pricing production"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": {
|
||||
"type": "grafana",
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
# Grafana-managed alerts. Grafana expands $VAR in the contact point, which keeps the
|
||||
# webhook URL out of Git; templates use .Labels instead of $labels to avoid "$".
|
||||
apiVersion: 1
|
||||
|
||||
contactPoints:
|
||||
- orgId: 1
|
||||
name: team-alerts
|
||||
receivers:
|
||||
- uid: team-alerts-discord
|
||||
type: discord
|
||||
settings:
|
||||
url: $DISCORD_WEBHOOK_URL # from the untracked .env.secret
|
||||
disableResolveMessage: false # resolved notifications on
|
||||
|
||||
groups:
|
||||
- orgId: 1
|
||||
name: sre
|
||||
folder: SRE
|
||||
interval: 30s # matches the scrape interval
|
||||
rules:
|
||||
- uid: https-service-down
|
||||
title: HTTPS service down
|
||||
condition: C
|
||||
data:
|
||||
- refId: A
|
||||
relativeTimeRange: {from: 300, to: 0}
|
||||
datasourceUid: prometheus
|
||||
model:
|
||||
refId: A
|
||||
expr: probe_success{job="https"}
|
||||
instant: true
|
||||
- refId: C
|
||||
datasourceUid: __expr__
|
||||
model:
|
||||
refId: C
|
||||
type: threshold
|
||||
expression: A
|
||||
conditions:
|
||||
- evaluator: {type: lt, params: [1]}
|
||||
for: 1m
|
||||
# A missing series or a failed query is a monitoring failure, not health.
|
||||
noDataState: Alerting
|
||||
execErrState: Error
|
||||
labels: {severity: critical, owner: billy}
|
||||
annotations:
|
||||
summary: "{{ .Labels.instance }} HTTPS probe is failing"
|
||||
description: "probe_success has been 0 for at least 1 minute. Owner: Billy (backup: Vincent)."
|
||||
runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-https-service-down
|
||||
notification_settings:
|
||||
receiver: team-alerts
|
||||
group_by: [alertname, instance]
|
||||
group_wait: 10s
|
||||
group_interval: 1m
|
||||
repeat_interval: 4h
|
||||
|
||||
- uid: root-disk-low
|
||||
title: Root disk space low
|
||||
condition: C
|
||||
data:
|
||||
- refId: A
|
||||
relativeTimeRange: {from: 300, to: 0}
|
||||
datasourceUid: prometheus
|
||||
model:
|
||||
refId: A
|
||||
expr: 100 * node_filesystem_avail_bytes{job="node",mountpoint="/",fstype="ext4"} / node_filesystem_size_bytes{job="node",mountpoint="/",fstype="ext4"}
|
||||
instant: true
|
||||
- refId: C
|
||||
datasourceUid: __expr__
|
||||
model:
|
||||
refId: C
|
||||
type: threshold
|
||||
expression: A
|
||||
conditions:
|
||||
- evaluator: {type: lt, params: [15]}
|
||||
for: 5m
|
||||
noDataState: Alerting
|
||||
execErrState: Error
|
||||
labels: {severity: warning, owner: billy}
|
||||
annotations:
|
||||
summary: "Root filesystem on The-Ocean below 15% free"
|
||||
description: "Available space on / has stayed under 15% for 5 minutes. Owner: Billy (backup: Vincent)."
|
||||
runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-root-disk-space-low
|
||||
notification_settings:
|
||||
receiver: team-alerts
|
||||
group_by: [alertname]
|
||||
group_wait: 10s
|
||||
group_interval: 1m
|
||||
repeat_interval: 4h
|
||||
|
||||
# Collection health: one series per scrape target, so a stopped exporter or a
|
||||
# probe series that disappears is reported instead of silently resolving.
|
||||
- uid: monitoring-target-down
|
||||
title: Monitoring target down
|
||||
condition: C
|
||||
data:
|
||||
- refId: A
|
||||
relativeTimeRange: {from: 300, to: 0}
|
||||
datasourceUid: prometheus
|
||||
model:
|
||||
refId: A
|
||||
expr: up
|
||||
instant: true
|
||||
- refId: C
|
||||
datasourceUid: __expr__
|
||||
model:
|
||||
refId: C
|
||||
type: threshold
|
||||
expression: A
|
||||
conditions:
|
||||
- evaluator: {type: lt, params: [1]}
|
||||
for: 1m
|
||||
noDataState: Alerting # no up series at all: Prometheus has lost every target
|
||||
execErrState: Error # Prometheus itself unreachable
|
||||
labels: {severity: critical, owner: billy}
|
||||
annotations:
|
||||
summary: "{{ .Labels.job }} target {{ .Labels.instance }} is not being collected"
|
||||
description: "Prometheus could not scrape this target for 1 minute; panels and alerts that depend on it are blind. Owner: Billy (backup: Vincent)."
|
||||
runbook_url: https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/src/branch/main/monitoring/README.md#runbook-monitoring-target-down
|
||||
notification_settings:
|
||||
receiver: team-alerts
|
||||
group_by: [alertname]
|
||||
group_wait: 10s
|
||||
group_interval: 1m
|
||||
repeat_interval: 4h
|
||||
@@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: sre
|
||||
folder: SRE
|
||||
type: file
|
||||
allowUiUpdates: false # Git is the source of truth for the dashboard
|
||||
options:
|
||||
path: /var/lib/grafana-dashboards
|
||||