Add the locked pricing service, trusted-agent pipeline, Ansible deployments, security gates, recovery runbooks, prerequisite evidence, and preparation manual. Prepared with Codex assistance. Vincent explicitly authorized this local commit and will handle the push. Assessed releases and recovery exercises remain pending.
125 lines
6.6 KiB
Markdown
125 lines
6.6 KiB
Markdown
# Release, recovery and cleanup
|
|
|
|
These are execution instructions, not completed release evidence.
|
|
|
|
## Authority and preparation
|
|
|
|
Billy reviews code; Vincent commits/pushes. Jenkins users `billy` or `vsun1`
|
|
may approve production interactively; administrators retain override authority.
|
|
The laptop 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 laptop
|
|
observer, 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 laptop agent is capped at 2 GiB/2 CPU. 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 local agent; remove only its 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.
|