Finalize Chapter 6 manual with verified visual evidence
startup-product-gitea-ci/pipeline/pr-main This commit looks good

This commit is contained in:
2026-11-26 04:06:57 -05:00
parent a96c88800f
commit 651acc63aa
20 changed files with 237 additions and 407 deletions
+232 -403
View File
@@ -1,410 +1,239 @@
\chapter{Secure Delivery and Rollback}
\label{chap:secure-delivery}
\section{Overview}
This chapter documents the secure deployment of the Startup Pricing
Service to the DigitalOcean staging environment. The deployment
process uses versioned Docker images, Ansible automation, container
resource restrictions, and HTTP health verification.
Two application releases are maintained:
\newcommand{\sixrepo}{https://git.nageshwaran.dev/SSW590-Startup/startup-product}
\newcommand{\sixfile}[1]{\href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/#1}{\nolinkurl{#1}}}
\section{Scope and architecture}
This revision records the November 24--26, 2026 secure delivery exercise for the Startup Pricing Service. Staging and production are separate containers on the existing DigitalOcean host. They share the host failure domain; this is not high availability. Gitea, Jenkins, Caddy and the existing monitoring stack remain in service.
\begin{figure}[H]\centering
\begin{tikzpicture}[node distance=8mm, every node/.style={font=\small}, b/.style={draw,rounded corners,align=center,minimum height=9mm}]
\node[b](git){Gitea\\source and registry};
\node[b,right=of git](ci){Jenkins\\Mac agent};
\node[b,right=of ci](gate){Security gates\\human approval};
\node[b,below=of ci](stage){Staging\\Gunicorn :5000};
\node[b,right=of stage](prod){Production\\Gunicorn :5000};
\node[b,below=of stage](proxy){Caddy HTTPS};
\node[b,right=of proxy](mon){Blackbox /\\Prometheus / Grafana};
\draw[->](git)--(ci);\draw[->](ci)--(gate);\draw[->](ci)--(stage);\draw[->](gate)--(prod);\draw[->](proxy)--(stage);\draw[->](proxy)--(prod);\draw[->](mon)--(proxy);
\end{tikzpicture}
\caption{Logical delivery and observation paths; both application environments share one Droplet.}
\end{figure}
\section{Release integrity and locked inputs}
The registry repository is \nolinkurl{git.nageshwaran.dev/}\allowbreak\nolinkurl{ssw590-startup/startup-pricing}. Deployments select immutable registry references rather than mutable tags or local image identifiers alone.
\begin{description}
\item[V1 index digest]\leavevmode\par\nobreak {\footnotesize\nolinkurl{sha256:d0d0a2c2052b01a33ce12fd2b278e906552ea9797b5b918f44e5065f444d3027}}
\item[V1 amd64 manifest]\leavevmode\par\nobreak {\footnotesize\nolinkurl{sha256:be7e0a6d6bb82b78e68616ecb905c3232e59715490143e36d0bb71172da31a7c}}
\item[V2 index digest]\leavevmode\par\nobreak {\footnotesize\nolinkurl{sha256:14d520f6fbe60c9cc5e661551a03e944de3a2ad777a64c316ec397ee765db22d}}
\item[V2 amd64 manifest]\leavevmode\par\nobreak {\footnotesize\nolinkurl{sha256:158f8cd88eef9af7d057b8810651ae60b010ea3c598e8f04694926f0cac8ab5f}}
\item[Hardened V2 base]\leavevmode\par\nobreak {\footnotesize\nolinkurl{python:3.13-alpine@sha256:9ef1a599f863231c3d91e941389bfdc4a2d6070557243d54df1a4e57015b960e}}
\end{description}
Both releases were pulled by immutable reference. Index and platform manifest digests identify different registry objects. The hardened V2 uses hash-locked Python dependencies, including Flask 3.1.3 and Gunicorn 23.0.0. The production lock file is \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/requirements-production.lock.txt}{production dependency lock file}. Historical image-to-source commit provenance is not established; the recovery release records are reconstructed, not original reviewed release attestations.
\begin{center}\small\begin{tabularx}{\linewidth}{lYY}\toprule
& V1 & Hardened V2\\\midrule
Business response & Basic 10, Pro 25, Enterprise 50; total 85 & Starter 5, Basic 12, Pro 30, Enterprise 60; total 107\\
Health & Healthy; no version field & Healthy; version v2\\
Source commit & Unverified & Unverified\\
Recovery configuration & Reconstructed V1 record & Reconstructed V2 record; healthy staging Compose template\\
Delivery evidence & Live rollback journal & Jenkins delivery build 7; live restoration journal\\\bottomrule\end{tabularx}\end{center}
The observed totals are 85 and 107, not the course reference totals of 30 and 36. The application does not expose a source commit in its health response. These are outstanding rubric gaps, not verified equivalence.
\section{Container hardening and Ansible deployment}
The application runs as non-root \texttt{appuser}, with a read-only root filesystem, all capabilities dropped, no-new-privileges, 64 MiB memory, 128 MiB memory plus swap, half a CPU, 64 processes and a 16 MiB restricted temporary filesystem. Staging uses one Gunicorn worker; production uses two. Host mappings are loopback-only (5062 staging and 5061 production); Caddy provides HTTPS. Jenkins reaches staging through its internal Docker network.
\par Configuration and automation: \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/recovery/staging/compose.yml}{\nolinkurl{compose.yml}}, \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/ansible/staging-recovery.yml}{\nolinkurl{staging-recovery.yml}}, and \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/ansible/production-recovery-transaction.yml}{production recovery transaction}. The healthy staging Compose configuration checks the application on port 5000. The recovery transaction uses a shared production lock to exclude competing promotion operations.
\par The November 26 guarded unchanged staging run reported ok=9, changed=0, failed=0, skipped=8. Replacement was explicitly disabled for that run; it demonstrates verification without mutation, not unrestricted deployment idempotence. Production HTTPS remained healthy.
\section{Jenkins delivery and security gates}
The dedicated \href{https://ci.nageshwaran.dev/job/startup-product-chapter6-delivery/7/}{delivery build 7} completed successfully on November 26. Gitleaks reported no leaks, pip-audit reported no known vulnerabilities, and Trivy reported zero HIGH or CRITICAL findings for the configured scan of hardened V2. This does not establish absence of all vulnerabilities. Earlier image scans motivated the hardened rebuild. A narrowly scoped Gitleaks exception identifies a public Python signing fingerprint, not a secret.
\par Production approval was recorded as \texttt{chapter6-approver}. The developer was denied approval in build 6, which was subsequently aborted. The restricted deployment account uses a forced-command SSH gateway and narrowly scoped sudo helpers. A root-managed, time-limited, single-use authorization file is consumed before promotion. The authorization file is not cryptographically bound to a Jenkins build; privileged administrators and races within its validity window remain trust considerations.
\par Build 7 verified staging, promoted the immutable V2 release, retained the previous production container and independently verified production HTTPS. The promotion log recorded start at 06:18:42 UTC and completion at 06:19:01 UTC, with Jenkins HTTPS verification by 06:19:06. A transient 502 was observed; continuous downtime was not measured for this promotion.
\par The separate \href{https://ci.nageshwaran.dev/job/chapter6-synthetic-secret-test/3/}{synthetic-secret build 3} detected a generated test token, exited 42, skipped the delivery sentinel and finished FAILURE. This was an isolated negative-test job, not a negative run of the full production pipeline.
\par \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/pulls/13}{PR 13} had a successful Jenkins build 8 before the final recovery evidence commit. Final-head CI, independent review and merge must be verified separately.
\section{Production rollback and restoration}
On November 26 an authorized Ansible transaction ran on the host under systemd, independently of the initiating SSH connection. It acquired the promotion lock, verified V2, preserved the original container, deployed cached V1, verified its HTTPS health and business response, then restored the original V2 container and verified its identity and response. Emergency restoration was exercised in simulation before the live drill.
\begin{center}\small\begin{tabularx}{\linewidth}{lY}\toprule UTC & Observed event\\\midrule
07:50:37.935 & Lock acquired\\
07:50:42.066 & V2 verified\\
07:50:44.469 & Rollback decision\\
07:50:44.475 & Rollback started\\
07:50:58.351 & V1 recovery verified\\
07:51:08.370 & V2 restoration started\\
07:51:25.439 & Original V2 recovered\\
07:51:25.446 & Lock released\\\bottomrule\end{tabularx}\end{center}
Rollback took 13.877 seconds from recorded start to verification; restoration took 17.069 seconds. Independent HTTPS sampling recorded 21 failed probes among 45 drill-window samples. The two failure timestamp spans were 9.264 and 10.036 seconds; surrounding healthy-probe brackets were 11.272 and 14.121 seconds. These are sampled estimates, not exact continuous downtime. The original V2 container was restored and the transaction reported success. Host crash or forced process termination can still require manual recovery.
\section{Staging configuration failure and recovery}
A separate authorized drill used \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/recovery/staging/compose.failure.yml}{\nolinkurl{compose.failure.yml}} to override Gunicorn's bind port to 8001 while leaving the health check on 5000. No Docker daemon or proxy failure was induced. Compose wait returned 1 with an unhealthy container; the Ansible deployment gate failed with exit 2. Production health assertions passed before and after the operation.
\begin{center}\small\begin{tabularx}{\linewidth}{lY}\toprule UTC & Observed event\\\midrule
08:22:39 & Failure exercise started\\
08:23:01.334 & First failed staging probe\\
08:23:29.391 & Compose failure returned\\
08:24:21 & Restoration exercise started\\
08:24:34.262 & Healthy Compose deployment started\\
08:24:50.900 & First subsequent healthy staging probe\\
08:24:55.937 & Compose healthy, exit 0\\
08:25:02 & HTTPS health and pricing verification complete\\\bottomrule\end{tabularx}\end{center}
Restoration used the healthy template without the failure override. Ansible reported ok=12, changed=1, failed=0. Staging returned healthy V2 and all four expected plans; production returned healthy V2. Staging recorded 88 failed probes in 111 drill-window samples, a failure timestamp span of 108.437 seconds and first-failure-to-recovery interval of 109.566 seconds. Production recorded zero failures in 111 samples (100 percent sampled availability). These are not continuous availability guarantees. The Ansible gate rejection is verified; a Jenkins rejection during the staging outage is not evidenced.
\section{Monitoring and operational runbooks}
The existing Prometheus, Grafana and Blackbox stack monitors HTTPS availability and latency alongside host metrics. Production health is \url{https://pricing.nageshwaran.dev/health}; staging health is \url{https://staging-pricing.nageshwaran.dev/health}. PricingServiceDown uses probe failure for one minute; PricingServiceHighLatency uses duration above two seconds for two minutes. Configuration validation and rule loading were observed; alert firing during the drills is not established. The independent CSV probes provide the recovery measurements above.
\begin{description}
\item[Release] Developer opens a PR; reviewer checks source, locked inputs and tests. Require passing security gates, immutable registry identity and staging health/business checks. Authorized approver reviews the exact release before promotion. Verify production and retain evidence.
\item[Failure] Stop promotion on any failed scan, health check or identity mismatch. Record UTC time, build, digest and configuration; inspect scoped container logs and monitoring. Do not bypass gates or restart unrelated services.
\item[Rollback] Obtain authorization, confirm cached immutable release and matching configuration, verify capacity and acquire the shared lock through the recovery transaction. Verify health and business output after rollback and restoration. Escalate if emergency restoration fails.
\item[State compatibility] The observed pricing exercise does not demonstrate database or payment rollback. For future persistent state use expand-and-contract migrations, backward-compatible schemas and tested backups; do not reverse a destructive migration blindly or replay payments without idempotency controls.
\item[Cleanup] Preserve previous releases, logs, configuration backups and persistent service volumes. Inspect disk and memory before any operation. Remove only explicitly reviewed obsolete artifacts after backup and authorization; never use blanket prune or volume deletion on this shared host.
\end{description}
\section{Evidence and remaining limitations}
Recovery evidence is committed in \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/commit/a96c888}{commit a96c888}. The following paths identify the original evidence; raw logs and reports must be reviewed for sensitive content before publication.
\begin{itemize}
\item Version 1: \texttt{startup-pricing:release-v1-20261113}
\item Version 2: \texttt{startup-pricing:release-v2-20261113}
\item \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/chapter6-evidence/06-rollback-recovery/production-recovery-final-20261126-075316.log}{\nolinkurl{production-recovery-final-20261126-075316.log}}
\item \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/chapter6-evidence/06-rollback-recovery/production-downtime-analysis-20261126-075411.log}{\nolinkurl{production-downtime-analysis-20261126-075411.log}}
\item \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/chapter6-evidence/06-rollback-recovery/staging-failure-20261126-082239.log}{\nolinkurl{staging-failure-20261126-082239.log}}
\item \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/chapter6-evidence/06-rollback-recovery/staging-restoration-20261126-082421.log}{\nolinkurl{staging-restoration-20261126-082421.log}}
\item \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/chapter6-evidence/06-rollback-recovery/staging-downtime-analysis-20261126-082556.log}{\nolinkurl{staging-downtime-analysis-20261126-082556.log}}
\end{itemize}
Additional local evidence directories contain registry, Jenkins, dependency and monitoring reports; publication and grader access must be confirmed. Outstanding items include historical source provenance, reference pricing totals, Jenkins staging-outage rejection, independent final PR approval, and final-head CI verification. No credit is claimed for unobserved tests. ChatGPT assisted with recovery planning, evidence interpretation and drafting on November 26, 2026; the team is responsible for checking the report against actual execution records.
The staging environment currently runs version 2. The deployment
process verifies the image identity and running container before
deciding whether replacement is required.
\clearpage
\section{Selected screenshot evidence}
These original captures supplement the execution records. Build 5 is historical gate evidence; build 7 records actual production delivery. Historical PR 12 is not the final PR 13 review.
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/build5-gitleaks.png}
\caption{Delivery build 5: Gitleaks scanned 23 commits and reported no leaks.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/build5-pip-audit.png}
\caption{Delivery build 5: dependency audit reported no known vulnerabilities.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/build5-trivy.png}
\caption{Delivery build 5: Trivy scan of the immutable V2 image, configured for HIGH and CRITICAL severity.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/build5-smoke.png}
\caption{Delivery build 5: staging digest verification and smoke tests before approval.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/restricted-ssh.png}
\caption{Restricted deployment account: authorized verification succeeded and an unauthorized command was denied.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/build6-denied.png}
\caption{Delivery build 6: unauthorized production approval rejection.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/step240-build7-designated-human-approval.png}
\caption{Delivery build 7: designated human approval.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/step241-build7-fullscreen-production-success.png}
\caption{Delivery build 7: successful production delivery.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/prometheus-alert-rules-validation-20261123.png}
\caption{Production monitoring: Prometheus alert configuration validation.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/step295A-unchanged-staging-check.png}
\caption{November 26 unchanged staging dry run: replacement not required, health and pricing checks passed, changed=0.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/grafana-pricing-availability.png}
\caption{November 23 Grafana dashboard: pricing HTTPS probe returned 1 (healthy), alongside Jenkins, Gitea and host metrics. This predates the recovery drills.}
\end{figure}
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.65\textheight,keepaspectratio]{img/chapter6-selected/historical-pr12.png}
\caption{Historical PR 12 reviewer approval and merge into main; not evidence of final PR 13 approval.}
\end{figure}
\section{Release Image Integrity}
\subsection{Versioned Docker Images}
The application is packaged into separately tagged Docker release
images. This approach allows a deployment to identify a specific
application release rather than relying on a mutable image tag.
The DigitalOcean release inspection recorded the following images:
\begin{table}[htbp]
\centering
\caption{Verified pricing service release images}
\label{tab:pricing-release-images}
\begin{tabularx}{\textwidth}{l X l}
\toprule
\textbf{Release} & \textbf{Image ID} & \textbf{Platform} \\
\midrule
v1 &
\texttt{sha256:d0d0a2c2052b01a33ce12fd2b278e906552ea9797b5b918f44e5065f444d3027}
& linux/amd64 \\
v2 &
\texttt{sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707}
& linux/amd64 \\
\bottomrule
\end{tabularx}
\end{table}
Both release images were inspected on the DigitalOcean host.
The inspection also confirmed that the application runs using
the non-root account \texttt{appuser}.
The image identifier provides a more precise reference to the
release than its human-readable tag alone.
\section{Container Security Configuration}
\subsection{Resource Restrictions}
The staging container is configured with explicit resource limits
to reduce the impact of excessive resource consumption.
\begin{table}[htbp]
\centering
\caption{Staging container resource restrictions}
\label{tab:pricing-resource-limits}
\begin{tabular}{ll}
\toprule
\textbf{Setting} & \textbf{Configured value} \\
\midrule
Memory limit & 64 MiB \\
Memory plus swap & 128 MiB \\
CPU limit & 0.5 CPU \\
Process limit & 64 \\
Temporary filesystem & 16 MiB \\
Worker processes & 1 \\
\bottomrule
\end{tabular}
\end{table}
\subsection{Container Hardening}
The staging deployment applies several Docker security controls:
\begin{itemize}
\item \textbf{Read-only root filesystem:}
The container filesystem is mounted read-only.
\item \textbf{Temporary filesystem:}
The \texttt{/tmp} directory uses a limited writable
temporary filesystem with \texttt{nosuid} and
\texttt{nodev} options.
\item \textbf{Capability restrictions:}
All Linux capabilities are dropped using
\texttt{--cap-drop ALL}.
\item \textbf{Privilege escalation restriction:}
Docker uses \texttt{no-new-privileges:true}.
\item \textbf{Non-root application user:}
The release image runs as \texttt{appuser}.
\item \textbf{Restricted network publishing:}
The application port is published only on
\texttt{127.0.0.1:5062} on the DigitalOcean host.
\end{itemize}
These controls reduce the container's privileges and limit
its resource consumption. They do not replace application-level
security, host security, or network firewall configuration.
\section{Ansible Deployment Automation}
\subsection{Deployment Playbook}
Ansible is used to automate the staging deployment on the
DigitalOcean host.
The playbook is located at:
\begin{verbatim}
pricing-service/ansible/deploy-staging.yml
\end{verbatim}
The playbook defines the following release variables:
\begin{verbatim}
container_name: startup-pricing-staging
release_image: startup-pricing:release-v2-20261113
\end{verbatim}
The deployment process performs these operations:
\begin{enumerate}
\item Inspect the current staging container.
\item Confirm that the desired release image exists.
\item Retrieve the desired image ID.
\item Retrieve the currently deployed image ID.
\item Determine whether the existing container requires
replacement.
\item Stop and remove the existing container when replacement
is necessary.
\item Start the new container with the configured security
restrictions.
\item Wait for the staging health endpoint.
\item Assert that the service reports a healthy v2 release.
\end{enumerate}
The replacement decision considers whether the current container
exists, whether its image ID matches the desired release, and
whether the container is running.
This prevents unnecessary container replacement when the
desired release is already deployed.
\subsection{Ansible Verification}
The staging verification playbook was executed against the
DigitalOcean host.
The observed Ansible recap was:
\begin{verbatim}
\clearpage
\section{Recovery and security execution evidence}
The following selected output is transcribed from the recorded execution results, not new screenshots or simulated tests. The complete recovery logs are linked in Section 6.8. All recovery timestamps are UTC on November 26, 2026.
\subsection*{Production rollback and restoration}
Selected transaction events, presented as a compact transcription of the journal timeline:
\begin{lstlisting}
07:50:37.934593 PRODUCTION_LOCK_ACQUIRED
07:50:44.468507 ROLLBACK_DECISION
07:50:44.474884 ROLLBACK_STARTED
07:50:58.351494 ROLLBACK_RECOVERED
07:51:08.369626 RESTORATION_STARTED
07:51:25.438908 RESTORATION_RECOVERED
07:51:25.444577 RECOVERY_TRANSACTION_SUCCESS
07:51:25.445828 PRODUCTION_LOCK_RELEASED
\end{lstlisting}
The production recovery journal reported successful restoration of the original V2 container. V1 returned the three expected plans (total 85); restored V2 returned four plans (total 107). See the full \href{https://git.nageshwaran.dev/SSW590-Startup/startup-product/src/commit/a96c888/pricing-service/chapter6-evidence/06-rollback-recovery/production-recovery-final-20261126-075316.log}{production recovery record}. Independent probes recorded two interruption spans, as described in Section 6.5.
\subsection*{Staging configuration failure}
Selected lines from the recorded Ansible failure output:
\begin{lstlisting}
container startup-pricing-staging is unhealthy
Compose deployment failed; delivery blocked
ANSIBLE_EXIT_CODE=2
Health=unhealthy Command=["gunicorn","--workers","1",
"--bind","0.0.0.0:8001","app:app"]
=== PRODUCTION HEALTH ===
{"status":"healthy","version":"v2"}
\end{lstlisting}
The Compose return code was 1. Ansible rejected the deployment. The Jenkins outage-specific failure was not captured; this is an Ansible gate result, not a Jenkins failure result.
\clearpage\subsection*{Healthy restoration and HTTPS verification}
Selected output from the recorded restoration run (08:24:21--08:25:02):
\begin{lstlisting}
Container startup-pricing-staging Healthy
PLAY RECAP
digitalocean:
ok=4
changed=0
unreachable=0
failed=0
skipped=0
\end{verbatim}
The verification confirmed that the existing staging deployment
was healthy and running version 2.
The result demonstrates that the verification operation did not
need to modify the existing deployment.
\section{Deployment Idempotency}
Idempotency is an important property of infrastructure automation.
Repeated execution against an already-correct environment should
not cause unnecessary changes.
The deployment verification recorded the following container
information:
\begin{verbatim}
ContainerID:
49b27eaa9b37d8929165de042bbcfee85953e1038ea8b0f8df6c2d7cdd590377
Status=running
RestartCount=0
ImageID:
sha256:008f4481d5cff032ceef48a45acb0cc7c17c2e99c1e4830e62205bc75e8e4707
\end{verbatim}
The container remained running without an additional restart.
Its image ID matched the intended v2 release.
The verification therefore provides evidence that the existing
staging deployment was retained rather than unnecessarily
recreated.
\section{Staging Health Verification}
\subsection{Health Endpoint}
The service exposes a health endpoint at:
\begin{verbatim}
/health
\end{verbatim}
The endpoint was tested from the DigitalOcean host and returned
HTTP status 200 with the following JSON response:
\begin{verbatim}
{
"status": "healthy",
"version": "v2"
}
\end{verbatim}
The deployment verification checks both the health status and
the expected application version.
\subsection{Pricing Endpoint}
The pricing endpoint was also tested:
\begin{verbatim}
/pricing
\end{verbatim}
The observed response contained four pricing plans:
\begin{verbatim}
{
"plans": [
{"name": "Starter", "price": 5},
{"name": "Basic", "price": 12},
{"name": "Pro", "price": 30},
{"name": "Enterprise", "price": 60}
],
"service": "Startup Pricing Service",
"version": "v2"
}
\end{verbatim}
The endpoint returned HTTP 200. The response confirmed the
expected plan names, prices, service identity, and application
version.
\section{Rollback and Recovery Procedure}
\subsection{Release-Based Rollback Strategy}
Maintaining separate versioned images allows an earlier release
to remain available when a newer release must be withdrawn.
The previously inspected v1 image is:
\begin{verbatim}
startup-pricing:release-v1-20261113
\end{verbatim}
If version 2 causes a deployment problem, the intended recovery
strategy is to deploy the previously verified v1 image.
The rollback process should include:
\begin{enumerate}
\item Confirm that the previous release image exists.
\item Inspect the current staging container.
\item Select the previous versioned release image.
\item Replace the staging container using the same security
restrictions.
\item Verify that the container is running.
\item Request the health endpoint.
\item Confirm that the application reports version 1.
\item Test the pricing endpoint and compare its response
with the expected v1 behavior.
\end{enumerate}
\subsection{Rollback Playbook Considerations}
The current staging playbook asserts that the expected application
version is v2.
Before using it for a v1 rollback, the expected version should
become a configurable variable rather than a hard-coded assertion.
For example:
\begin{verbatim}
expected_version: v2
\end{verbatim}
The version assertion can then reference:
\begin{verbatim}
staging_health.json.version == expected_version
\end{verbatim}
A rollback invocation can override both the release image and
expected version:
\begin{verbatim}
ansible-playbook ansible/deploy-staging.yml \
-e release_image=startup-pricing:release-v1-20261113 \
-e expected_version=v1
\end{verbatim}
This command represents the intended rollback approach after
the playbook has been updated to use the configurable
\texttt{expected\_version} variable.
The rollback must not be considered verified until the v1
deployment and its health and pricing checks have actually
succeeded.
\section{Operational Security and Recovery Controls}
The secure delivery process uses several complementary controls:
\begin{itemize}
\item Version-specific release image tags.
\item Image ID inspection before deployment.
\item Non-root application execution.
\item Container memory, CPU, and process restrictions.
\item Read-only root filesystem.
\item Dropped Linux capabilities.
\item Restricted host port publishing.
\item Automated Ansible deployment and verification.
\item Health and application-version assertions.
\item Retention of the previous release image for recovery.
\end{itemize}
Deployment credentials and private SSH keys must remain outside
the Git repository. The manual must not contain passwords,
private keys, API tokens, or other authentication secrets.
\section{Verification Summary}
The following results were observed during the staging
deployment exercise:
\begin{enumerate}
\item Versioned v1 and v2 Docker images were present on
the DigitalOcean host.
\item The v2 image was verified using its Docker image ID.
\item The staging container was running with the configured
resource and security restrictions.
\item Ansible verification completed with zero changes
and zero failures.
\item The staging container retained its identity and
reported a restart count of zero during verification.
\item The health endpoint returned HTTP 200 and reported
a healthy v2 service.
\item The pricing endpoint returned HTTP 200 and all
four expected v2 pricing plans.
\item The v2-to-v1 rollback was successfully executed and
verified using the health and pricing endpoints.
\item The v2 release was successfully restored and verified
with all four expected pricing plans.
\end{enumerate}
The v1 rollback was executed against the staging environment.
The previous v2 container was replaced by the v1 release image.
The v1 health endpoint returned HTTP 200, and the pricing
endpoint returned the expected v1 pricing plans.
After verification, the v2 release was redeployed successfully.
The health endpoint reported a healthy v2 service, and the
pricing endpoint returned all four expected v2 plans.
The rollback and recovery sequence was therefore demonstrated
in the staging environment.
\section{Evidence and Submission Controls}
The deployment evidence is maintained in the repository under:
\begin{verbatim}
pricing-service/chapter6-evidence/
\end{verbatim}
The evidence includes release image inspection, Ansible
execution and verification output, container security
configuration, idempotency verification, and staging
health and pricing responses.
Evidence should be retained alongside the source code so
that the deployment process can be reviewed and repeated.
Sensitive credentials and authentication material must
not be included in the submitted documentation.
digitalocean : ok=12 changed=1 unreachable=0 failed=0
=== STAGING HTTPS HEALTH ===
{"status":"healthy","version":"v2"}
=== STAGING HTTPS PRICING ===
{"plans":[{"name":"Starter","price":5},
{"name":"Basic","price":12},{"name":"Pro","price":30},
{"name":"Enterprise","price":60}],
"service":"Startup Pricing Service","version":"v2"}
=== PRODUCTION HTTPS HEALTH ===
{"status":"healthy","version":"v2"}
\end{lstlisting}
Public endpoints: \href{https://staging-pricing.nageshwaran.dev/health}{staging health}, \href{https://staging-pricing.nageshwaran.dev/pricing}{staging pricing}, \href{https://pricing.nageshwaran.dev/health}{production health}, and \href{https://pricing.nageshwaran.dev/pricing}{production pricing}.
\subsection*{Independent availability measurements}
Selected output from the saved staging downtime analysis:
\begin{lstlisting}
=== STAGING ===
Drill window samples: 111
Failed samples: 88
Sampled availability: 20.72 %
Failure timestamp span: 108.436741 seconds
First failure to recovery: 109.565538 seconds
=== PRODUCTION ===
Drill window samples: 111
Failed samples: 0
Sampled availability: 100.0 %
\end{lstlisting}
The observation window is the staging drill only; these are sampled estimates, not long-term SLO compliance or exact continuous downtime.
\subsection*{Synthetic-secret negative test}
Recorded result summary (not raw console output): Jenkins \href{https://ci.nageshwaran.dev/job/chapter6-synthetic-secret-test/3/}{synthetic-secret build 3} detected a generated test token (rule \texttt{github-pat}); Gitleaks returned 42, the delivery sentinel was skipped, and the build finished FAILURE. This separate test job does not demonstrate a full production-pipeline negative run. The test token is deliberately not reproduced. The archived console and reports remain in the local evidence directory, \nolinkurl{04-jenkins-ci/synthetic-secret-build-3/}. See also \href{https://ci.nageshwaran.dev/job/startup-product-chapter6-delivery/7/consoleText}{delivery build 7 console} and \href{https://ci.nageshwaran.dev/job/startup-product-chapter6-delivery/7/artifact/}{build 7 artifacts} for the passing scan and promotion evidence. Access to these links must be confirmed by the team.
\clearpage
\section{Additional visual execution evidence}
The following authentic screenshots supplement the saved log transcriptions. The availability screenshot documents the production rollback drill, not the staging drill. Staging downtime is supported by the saved analysis in Section 6.6. The synthetic-secret test was an isolated Jenkins job.
\clearpage
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.80\textheight,keepaspectratio]{img/chapter6-selected/staging-restoration.png}
\caption{Saved Ansible restoration output: Compose healthy, zero failed tasks, staging and production HTTPS healthy at 08:25:02 UTC.}
\end{figure}
\clearpage
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.80\textheight,keepaspectratio]{img/chapter6-selected/live-https.png}
\caption{Live HTTPS verification at 08:59:26 UTC on November 26, 2026: both environments returned healthy V2 and matching pricing plans.}
\end{figure}
\clearpage
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.80\textheight,keepaspectratio]{img/chapter6-selected/production-downtime.png}
\caption{Saved production rollback availability analysis: two observed interruption groups; sampled estimates rather than exact continuous downtime.}
\end{figure}
\clearpage
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.80\textheight,keepaspectratio]{img/chapter6-selected/synthetic-secret-start.png}
\caption{Jenkins synthetic-secret test build 3: recorded job execution and environment validation.}
\end{figure}
\clearpage
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.80\textheight,keepaspectratio]{img/chapter6-selected/synthetic-secret-blocked.png}
\caption{Jenkins synthetic-secret test build 3: delivery sentinel skipped, exit code 42, final result FAILURE.}
\end{figure}
\clearpage
\begin{figure}[H]\centering
\includegraphics[width=\linewidth,height=0.80\textheight,keepaspectratio]{img/chapter6-selected/synthetic-secret-report.png}
\caption{Redacted archived report for synthetic-secret build 3: one github-pat finding, exit code 42, delivery sentinel skipped. The generated token is omitted.}
\end{figure}