89 lines
18 KiB
TeX
89 lines
18 KiB
TeX
\chapter{Secure Delivery and Rollback}
|
|
\ChapterLabel{SecureDeliveryRollback}
|
|
\section{Scope and architecture}
|
|
The stateless Startup Pricing Service uses Flask and Gunicorn. A trusted Jenkins agent runs tests, scans, image publication and Ansible; the controller schedules work and records human approval. Ansible connects by pinned SSH to the Droplet and manages separate staging and production Compose projects. Caddy terminates public HTTPS and forwards private container traffic to port 8000. The Gitea registry stores immutable images. Prometheus probes HTTPS through Blackbox Exporter; Grafana displays metrics. All services share one Droplet, so neither availability nor tenant isolation is equivalent to a multi-host deployment.
|
|
|
|
\begin{figure}[p]
|
|
\centering
|
|
\begin{tikzpicture}[x=1cm,y=1cm, every node/.style={draw,rounded corners,align=center,font=\scriptsize,inner sep=3pt}, arrow/.style={-{Stealth},thick}]
|
|
\node (client) at (0,0) {Team / grader\\public HTTPS};
|
|
\node[draw,dashed,minimum width=13.6cm,minimum height=9.4cm,label={[draw=none]above:Existing single DigitalOcean Droplet}] (host) at (7,-5.6) {};
|
|
\node (proxy) at (6.9,-1.7) {Caddy container\\TLS / reverse proxy};
|
|
\node (stage) at (10.8,-3.1) {Staging Compose\\pricing-staging :8000};
|
|
\node (prod) at (10.8,-4.4) {Production Compose\\pricing-production :8000};
|
|
\node (git) at (2.2,-3.4) {Gitea + SQLite\\OCI registry};
|
|
\node (controller) at (5.7,-4.1) {Jenkins controller};
|
|
\node (agent) at (5.7,-5.6) {Trusted agent container\\Ansible process};
|
|
\node (docker) at (8.4,-6.5) {Host SSH account\\Docker Engine + Compose};
|
|
\node (mon) at (2.5,-7.5) {Prometheus + Grafana\\Blackbox + Node Exporter};
|
|
\node (dirs) at (10.5,-8.0) {Host deployment directories\\pricing-staging / pricing-production};
|
|
\draw[arrow] (client) -- (proxy);
|
|
\draw[arrow] (proxy) -- (stage); \draw[arrow] (proxy) -- (prod);
|
|
\draw[arrow] (controller) -- (agent); \draw[arrow] (agent) -- node[draw=none,above,font=\tiny]{SSH} (docker);
|
|
\draw[arrow] (docker) -- (stage); \draw[arrow] (docker) -- (prod); \draw[arrow] (docker) -- (dirs);
|
|
\draw[arrow] (agent) -- (git); \draw[arrow] (mon) -- node[draw=none,left,font=\tiny]{HTTPS probe} (proxy);
|
|
\end{tikzpicture}
|
|
\caption{Actual single-host delivery: external HTTPS, private container paths, and Ansible SSH to the host. Application containers are stateless.}
|
|
\label{Fig:A8Architecture}
|
|
\end{figure}
|
|
\begin{table}[p]
|
|
\centering\footnotesize
|
|
\begin{tabularx}{\linewidth}{L{3.4cm}Y}
|
|
\toprule Component & Actual persistent volume or host bind mount \\ \midrule
|
|
Gitea / SQLite & \path{myfileagent-gitea_gitea-data} and \path{myfileagent-gitea_gitea-config} \\
|
|
Jenkins controller & \path{myfileagent-gitea_jenkins-home} \\
|
|
Caddy & \path{myfileagent-gitea_caddy-data}, \path{myfileagent-gitea_caddy-config}; \path{/home/codex/myfileagent-gitea/Caddyfile} \\
|
|
Prometheus & \path{myfileagent-monitoring_prometheus_data}; \path{/home/codex/myfileagent-gitea/assignment7-monitoring/monitoring/prometheus/prometheus.yml} \\
|
|
Grafana & \path{myfileagent-monitoring_grafana_data}; \path{/home/codex/myfileagent-gitea/assignment7-monitoring/monitoring/grafana/provisioning} \\
|
|
Blackbox / Node & \path{/home/codex/myfileagent-gitea/assignment7-monitoring/monitoring/blackbox/blackbox.yml}; host \path{/} mounted read-only for Node \\
|
|
Agent & Docker socket \path{/var/run/docker.sock}; separate agent workspace volumes; no Ansible service container \\
|
|
Applications & \path{/opt/startup/pricing-staging}, \path{/opt/startup/pricing-production}; no persistent application volume \\ \bottomrule
|
|
\end{tabularx}
|
|
\caption{Observed durable volumes and host mounts in the single-Droplet architecture. Exporters have no data volumes.}
|
|
\end{table}
|
|
The diagram is logical: the probe reaches the application through Caddy, and Ansible changes the host over SSH, not inside an application container. The agent has the Docker socket and the dedicated \texttt{a8deploy} account has passwordless root sudo; both confer effective host-administrator rights. Only authorized operators and reviewed code may use those privileges. Separate registry write and read credentials are held in Jenkins; target root Docker authentication is stored without encryption and must be restricted and removed after assessment. No credentials belong in source, screenshots or reports.
|
|
|
|
Persistent volumes retained are \path{myfileagent-gitea_gitea-data}, \path{myfileagent-gitea_gitea-config}, \path{myfileagent-gitea_jenkins-home}, \path{myfileagent-gitea_caddy-data}, \path{myfileagent-gitea_caddy-config}, \path{myfileagent-monitoring_prometheus_data}, and \path{myfileagent-monitoring_grafana_data}. Gitea uses SQLite within its existing data. The Caddyfile and monitoring configuration are host bind mounts under \path{/home/codex/myfileagent-gitea/}; Node Exporter reads the host root and Blackbox has no data volume. Ansible's application directories are \path{/opt/startup/pricing-staging} and \path{/opt/startup/pricing-production}; the pricing containers have no persistent application volume. The application ports are private. Shared proxy-network membership permits more lateral access than dedicated isolation.
|
|
|
|
\section{Build inputs and security}
|
|
On the trusted agent the recorded versions were Python 3.13.5, Git 2.47.3, Docker CLI 26.1.5, Ansible core 2.22.0 and community.docker 5.0.4; the target reported Docker 29.8.1 and Compose 5.5.1 on x86\_64. The release Dockerfile pins \path{python:3.13-alpine@sha256:7984cf56ceaddebe4fefeb75d64000b9f45d8b77b11a09b24524da6cdc3af0c8}; exact dependencies, including Flask 3.1.3 and Gunicorn 23.0.0, are in the linked requirements file. The image runs as UID 10001; Compose drops capabilities and uses a read-only root filesystem with writable temporary storage.
|
|
|
|
The release gates run unit tests, \texttt{pip-audit}, repository secret scanning and Trivy HIGH/CRITICAL image scanning. A finding, scanner error, or unavailable database blocks release unless an instructor accepts a documented, time-limited exception; false positives and unfixed findings require explicit triage, not silent suppression. Scan results are time-specific and do not prove absence of vulnerabilities. A disposable private-key fixture blocked \href{https://ci.myfileagent.tech/job/assignment8-secret-gate-demo/4/console}{secret gate \#4}; the fixture was removed. A controlled test failure blocked \href{https://ci.myfileagent.tech/job/assignment8-test-gate-demo/1/console}{test gate \#1}. The corrected audit covers all nine locked packages; the earlier validation \#9 summary has an evidence-contamination limitation and is not used as release evidence.
|
|
|
|
\section{Release traceability and evidence}
|
|
Times below are UTC on 7 November 2026. The abbreviated identifiers identify the linked full commits; the full digests are recorded in the Jenkins artifacts and handoff. The same published digest was used for each release's staging and production deployment. Both staging reruns reported \texttt{changed=0}. Human approver Gowri Das Lovely approved each restricted Jenkins input; the agent did not approve it.
|
|
\begin{longtable}{L{1.4cm}L{3.8cm}L{3.4cm}L{5.4cm}}
|
|
\toprule Release & Source and config commit & Registry digest (SHA-256 prefix) & Verified pipeline and production approval \\ \midrule\endhead
|
|
v1 & \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/commit/0cb5a34cc4c2709ea3eb95f58bf5b0b2fa350ef2}{\texttt{0cb5a34}} & \texttt{715a3c80d5fff431} & \href{https://ci.myfileagent.tech/job/assignment8-release/3/}{Jenkins release \#3}; approval 22:44:27; finished 22:46:08; health OK, v1, quantity 3 total 30. \\
|
|
v2 & \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/commit/ee128d18bddd1763b916b40f05829f2e769f0654}{\texttt{ee128d1}} & \texttt{2ab86894ada4c12b} & \href{https://ci.myfileagent.tech/job/assignment8-release/4/}{Jenkins release \#4}; approval 23:03:50; finished 23:05:41; health OK, v2, quantity 3 total 36. \\ \bottomrule
|
|
\end{longtable}
|
|
Full immutable registry references (the source and configuration commits are linked above):\par
|
|
\path{myfileagent.tech/myfileagent/pricing@sha256:715a3c80d5fff4319e275583e73e58cd80bffadea6e25796dd4867135ff036c2}\par
|
|
\path{myfileagent.tech/myfileagent/pricing@sha256:2ab86894ada4c12bd066ae1d29be40a296b1a037f379c494dead5cad4d8b88f9}\par
|
|
Both release runs passed their tests, dependency and secret gates, syntax and image checks, and included authenticated publication and pull. Trivy 0.69.1 reported zero HIGH/CRITICAL findings in both release image reports; the dependency reports list all nine locked packages with zero known findings, and secret summaries report exit status 0. The reports record scan timestamps, but the exact vulnerability database version was not retained and cannot be reconstructed. Findings may change. \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/pulls/17}{PR \#17} covered its reviewed head; later fixes were independently reviewed and merged in \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/pulls/18}{PR \#18}. The health-timeout mitigation and v2 source were separately reviewed in \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/pulls/19}{PR \#19} and \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/pulls/20}{PR \#20}. Earlier release \#2 reached staging but failed the unchanged rerun after health-check timeouts; it did not reach production. The later successes do not establish a guaranteed fix under every load.
|
|
|
|
\subsection{Direct evidence and source links}
|
|
A checked, redacted \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/src/branch/main/documentation/evidence/assignment8}{repository evidence bundle} preserves the selected reports, release records, recovery responses, checksums and excerpts. The bundle includes a separate timestamped current-state check; it is not substituted for historical data. The v1 and v2 runs retain redacted evidence: dependency reports (\href{https://ci.myfileagent.tech/job/assignment8-release/3/artifact/reports/dependency-audit.json}{v1}, \href{https://ci.myfileagent.tech/job/assignment8-release/4/artifact/reports/dependency-audit.json}{v2}), image scans (\href{https://ci.myfileagent.tech/job/assignment8-release/3/artifact/reports/image-scan.json}{v1}, \href{https://ci.myfileagent.tech/job/assignment8-release/4/artifact/reports/image-scan.json}{v2}), secret summaries (\href{https://ci.myfileagent.tech/job/assignment8-release/3/artifact/reports/secret-scan-summary.json}{v1}, \href{https://ci.myfileagent.tech/job/assignment8-release/4/artifact/reports/secret-scan-summary.json}{v2}), and target pulls (\href{https://ci.myfileagent.tech/job/assignment8-release/3/artifact/reports/target-pull.txt}{v1}, \href{https://ci.myfileagent.tech/job/assignment8-release/4/artifact/reports/target-pull.txt}{v2}). The unchanged staging reruns are linked for \href{https://ci.myfileagent.tech/job/assignment8-release/3/artifact/reports/staging-second-run.txt}{v1} and \href{https://ci.myfileagent.tech/job/assignment8-release/4/artifact/reports/staging-second-run.txt}{v2}; each reported nine tasks OK, zero changes and zero failures.
|
|
|
|
Release records: \href{https://ci.myfileagent.tech/job/assignment8-release/3/artifact/releases/generated/v1-staging.yml}{v1 staging}, \href{https://ci.myfileagent.tech/job/assignment8-release/3/artifact/releases/generated/v1-production.yml}{v1 production}, \href{https://ci.myfileagent.tech/job/assignment8-release/4/artifact/releases/generated/v2-staging.yml}{v2 staging} and \href{https://ci.myfileagent.tech/job/assignment8-release/4/artifact/releases/generated/v2-production.yml}{v2 production}. Each release's console contains the checked Ansible health, identity and price assertions. Approval events occurred at 22:44:27 and 23:03:50 UTC; the associated approval files were written at 22:44:31 and 23:03:54 respectively.
|
|
|
|
The reviewed \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/src/commit/0cb5a34cc4c2709ea3eb95f58bf5b0b2fa350ef2/secure-delivery/v1}{v1 source, tests, Dockerfile and lockfile} and \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/src/commit/ee128d18bddd1763b916b40f05829f2e769f0654/secure-delivery/v1}{v2 source, tests, Dockerfile and lockfile} are distinct revisions of the same application. The \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/src/commit/ee128d18bddd1763b916b40f05829f2e769f0654/secure-delivery/Jenkinsfile.release.draft}{reviewed release pipeline}, \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/src/commit/ee128d18bddd1763b916b40f05829f2e769f0654/secure-delivery/ansible}{inventory, playbook and template}, and \href{https://ci.myfileagent.tech/job/assignment8-agent-check/2/console}{agent version check} complete the implementation links. Despite its historical filename, the linked release pipeline was executed in releases \#3 and \#4.
|
|
|
|
\section{Recovery exercises and monitoring}
|
|
\href{https://ci.myfileagent.tech/job/assignment8-rollback-v1/1/}{Rollback \#1} checked healthy production v2 and restored the matching reviewed v1 configuration and digest. Gowri approved at 23:12:50; Ansible began at 23:13:01 and verified v1 at 23:14:37. HTTP samples observed 502 from 23:13:49 through 23:13:55, a timeout at 23:13:57 and 200 at 23:14:01. Samples bound observations, not exact interruption duration. The archived \href{https://ci.myfileagent.tech/job/assignment8-rollback-v1/1/artifact/reports/after-identity.json}{identity}, \href{https://ci.myfileagent.tech/job/assignment8-rollback-v1/1/artifact/reports/after-health.json}{health}, \href{https://ci.myfileagent.tech/job/assignment8-rollback-v1/1/artifact/reports/after-price.json}{price} and \href{https://ci.myfileagent.tech/job/assignment8-rollback-v1/1/artifact/reports/availability-samples.txt}{samples} show v1, the full v1 commit and total 30.
|
|
|
|
In staging only, configuration commit \texttt{c0cdd915} bound Gunicorn to 8001 while its image health check remained on 8000. \href{https://ci.myfileagent.tech/job/assignment8-staging-failure/1/}{Failure run \#1} stopped after Compose reported unhealthy at 23:21 on 7 November. A session interruption delayed recovery overnight. \href{https://ci.myfileagent.tech/job/assignment8-staging-recovery/1/}{Recovery run \#1} restored reviewed v2 configuration and digest starting 15:54:48 on 8 November; Ansible verified recovery at 15:56:45. Archived staging \href{https://ci.myfileagent.tech/job/assignment8-staging-recovery/1/artifact/reports/health.json}{health}, \href{https://ci.myfileagent.tech/job/assignment8-staging-recovery/1/artifact/reports/identity.json}{identity} and \href{https://ci.myfileagent.tech/job/assignment8-staging-recovery/1/artifact/reports/price.json}{price} confirmed v2/36. A separate current HTTPS observation at 16:29:04 UTC on 8 November showed production v1/30 and staging v2/36; it does not replace earlier release evidence. There was no continuous availability measurement for the whole staging interval.
|
|
|
|
On 8 November at 16:01:05, the production \url{https://app.myfileagent.tech/health} target was added to the existing HTTPS Blackbox job; Gitea, Jenkins and host metrics were retained. Prometheus accepted the configuration and reported all three HTTPS \texttt{probe\_success} values as 1 afterward. The provisioned Grafana dashboard displayed the production probe with latest value 1 when checked on 8 November. Since the production probe was added after the promotions and rollback, it cannot establish their historical availability or alert behavior. A 30-second scrape may miss a short interruption, and a status probe cannot validate price or source identity.
|
|
|
|
\section{Operations and grader access}
|
|
\textbf{Release:} review the exact source and configuration, input locks, security reports, staging behavior and immutable digest. Run the release job on reviewed main; verify health, identity and price, then the unchanged Ansible rerun. An authorized human reviews and approves the restricted Jenkins input before production. Promote the same digest and verify again; record the approver, times and artifacts.
|
|
|
|
\textbf{Failed staging deployment:} stop promotion, preserve logs and release metadata, inspect the health failure, restore the last reviewed configuration and corresponding image record, run Ansible and verify health, identity and price. The playbook does not automatically roll back.
|
|
|
|
\textbf{Production rollback:} an authorized human decides and approves a rollback; check the current release, restore the reviewed earlier image \emph{and} matching configuration, run Ansible, verify health, source and price, and record start, recovery and sampled interruption. A real database migration, external payment, or incompatible stored state may make image-only rollback unsafe. Prefer an expand-and-contract migration compatible with both versions; this stateless exercise did not test a database rollback.
|
|
|
|
\textbf{Cleanup:} after grading and only when retention permits, remove application projects, their Caddy routes, test DNS and dedicated credentials; retain earlier services, their volumes and required evidence. Do not prune Docker or use \texttt{compose down -v}. The single Droplet has shared CPU, memory and failure domain; earlier health-check timeouts illustrate that capacity matters.
|
|
|
|
Source, tests, Dockerfile, release intent, Ansible inventory, playbook and template are available in the \href{https://myfileagent.tech/myfileagent/myfileagent-pipeline/src/branch/main/secure-delivery}{Gitea secure-delivery directory}. Jenkins links above contain run logs and redacted artifacts. The grader needs a team-provided authorized Gitea/Jenkins account and network access; this grader access has not been independently tested. Request access from the team without sending credentials in the submission. This PDF records results so a live pipeline run is not needed to understand them.
|