14 Commits

Author SHA1 Message Date
samahk13 24df5d9c5a Added hashes and run number
Scrap-Web/pipeline/head Build started...
Scrap-Web/pipeline/pr-main This commit looks good
2026-12-02 20:56:15 -05:00
samahk13 291c38bfd0 Pricing: clear message for non-numeric quantity (fixes #30); manual Chapter 12
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head This commit looks good
2026-12-02 20:41:39 -05:00
samahk13 3cc6f3b0d4 Adding a sentence in manual stating that manual build will be in Jenkins
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head Something is wrong with the build of this commit
2026-12-02 19:59:58 -05:00
samahk13 db8f5fe27b Manual: built and archived by Jenkins
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head Something is wrong with the build of this commit
2026-12-02 14:31:14 -05:00
samahk13 c9006bb314 Make it so image doesn't rebuild unless it's missing
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head Something is wrong with the build of this commit
2026-12-01 20:26:10 -05:00
samahk13 8e2fe554d3 Add sentence to manual about compiling by Jenkins on Droplet
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head Something is wrong with the build of this commit
2026-12-01 20:02:41 -05:00
samahk13 9fdfd00fa6 Patch libzstd1 (CVE-2026-124851) found by the image scan
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head Something is wrong with the build of this commit
2026-11-30 02:04:11 +00:00
samahk13 927df037b0 Add semantic versioning, LaTeX manual stage and versioned ZIP
Scrap-Web/pipeline/pr-main This commit looks good
Scrap-Web/pipeline/head There was a failure building this commit
2026-11-29 20:24:54 -05:00
samahk13 dae5b47373 Uploading final manual files for 11/13 submission
Scrap-Web/pipeline/head This commit looks good
Scrap-Web/pipeline/pr-main This commit looks good
2026-11-13 23:11:36 -05:00
samahk13 944ca0f203 Update jenkisn
Scrap-Web/pipeline/head This commit looks good
2026-11-13 23:06:26 -05:00
samahk13 1841a7d4ab Revert "Controlled failure: staging Gunicorn on 8001"
Scrap-Web/pipeline/head This commit looks good
This reverts commit 12226285c6.
2026-11-13 22:39:21 -05:00
samahk13 12226285c6 Controlled failure: staging Gunicorn on 8001
Scrap-Web/pipeline/head There was a failure building this commit
2026-11-13 22:33:04 -05:00
samahk13 7b73df19bd Added the v2 production and staging .yml files
Scrap-Web/pipeline/head Something is wrong with the build of this commit
2026-11-13 22:26:56 -05:00
samahk13 d6787727f8 Updating files
Scrap-Web/pipeline/head This commit looks good
2026-11-13 22:13:00 -05:00
48 changed files with 1075 additions and 73 deletions
Vendored
+55 -4
View File
@@ -8,6 +8,9 @@
// TODO before submission: remove the feature branch from TRUSTED_BRANCH so
// only reviewed code on main can deliver.
//
// Release version: major.minor.changelist = 1.0.<Jenkins build number>,
// shown as the build name and used for the image tag, ZIP, and manual PDF.
//
// Two kinds of run:
// * Normal run (DEPLOY_RECORD empty): test, scan, build once, publish, deploy
// staging, prove idempotence, human approval, promote the SAME digest.
@@ -19,6 +22,9 @@
def TRUSTED_BRANCH = 'main|feature/issue-24-delivery'
// Jenkins user IDs allowed to approve production. Anonymous users cannot.
def APPROVERS = 'samahk,kaylah7'
// Semantic version: bump MAJOR_MINOR by hand for a feature or breaking release;
// the changelist part is the Jenkins build number, so every build is unique.
def MAJOR_MINOR = '1.0'
def deployRecord(String record) {
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
@@ -81,8 +87,12 @@ pipeline {
script {
env.APP_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
env.IMAGE_TAG = "${env.IMAGE}:${env.APP_COMMIT}"
env.SEMVER = "${MAJOR_MINOR}.${env.BUILD_NUMBER}"
env.SEMVER_TAG = "${env.IMAGE}:${env.SEMVER}"
currentBuild.displayName = "#${env.BUILD_NUMBER} v${env.SEMVER}"
}
echo "Source commit: ${env.APP_COMMIT}"
echo "Release version: ${env.SEMVER}"
}
}
@@ -99,6 +109,26 @@ pipeline {
}
}
// LaTeX: compile the IT manual on the Droplet, in the same TeX Live
// image the Gitea Actions workflow uses (manual/ci/Dockerfile).
// The agent talks to the host's Docker daemon, so files are copied
// into and out of the container instead of bind-mounted.
stage('Compile manual (LaTeX)') {
steps {
sh '''
docker image inspect ssw590/manual-latex:1 >/dev/null 2>&1 || docker build -q -t ssw590/manual-latex:1 manual/ci
cid=$(docker create -w /work ssw590/manual-latex:1 latexmk devopsAssignment.tex)
docker cp manual/. "$cid":/work
if docker start -a "$cid"; then rc=0; else rc=$?; fi
docker cp "$cid":/work/devopsAssignment.pdf "manual-$SEMVER.pdf" || true
docker rm "$cid" > /dev/null
[ "$rc" -eq 0 ] && [ -s "manual-$SEMVER.pdf" ] || { echo "Manual build failed"; exit 1; }
echo "Manual compiled: manual-$SEMVER.pdf"
'''
archiveArtifacts artifacts: "manual-${env.SEMVER}.pdf", fingerprint: true
}
}
// 6.4.5: dependency and secret checks on the source. Fails closed:
// a missing script, a scanner error, or a finding stops the run.
stage('Security scan: source') {
@@ -109,7 +139,7 @@ pipeline {
stage('Build image') {
steps {
dir('pricing') {
sh 'docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE_TAG" .'
sh 'docker build --build-arg APP_COMMIT="$APP_COMMIT" -t "$IMAGE_TAG" -t "$SEMVER_TAG" .'
}
}
}
@@ -130,7 +160,8 @@ pipeline {
sh '''
printf '%s' "$REG_TOKEN" | docker login "$REGISTRY" -u "$REG_USER" --password-stdin
docker push "$IMAGE_TAG"
docker image rm "$IMAGE_TAG"
docker push "$SEMVER_TAG"
docker image rm "$IMAGE_TAG" "$SEMVER_TAG"
docker pull "$IMAGE_TAG"
docker logout "$REGISTRY"
docker image inspect "$IMAGE_TAG" --format '{{index .RepoDigests 0}}' > image-digest.txt
@@ -138,7 +169,9 @@ pipeline {
'''
}
script { env.IMAGE_DIGEST = readFile('image-digest.txt').trim() }
writeFile file: 'build-record.txt', text: """source_commit: ${env.APP_COMMIT}
writeFile file: 'build-record.txt', text: """version: ${env.SEMVER}
source_commit: ${env.APP_COMMIT}
version_tag: ${env.SEMVER_TAG}
image_tag: ${env.IMAGE_TAG}
image_digest: ${env.IMAGE_DIGEST}
jenkins_build: ${env.BUILD_URL}
@@ -147,6 +180,22 @@ jenkins_build: ${env.BUILD_URL}
}
}
// Deployment-ready ZIP named with the semantic version.
stage('Package') {
steps {
sh '''
rm -rf dist && mkdir -p "dist/pricing-$SEMVER"
cp pricing/app.py pricing/requirements.txt pricing/Dockerfile "dist/pricing-$SEMVER/"
cp -r ansible "dist/pricing-$SEMVER/ansible"
cp build-record.txt "dist/pricing-$SEMVER/"
printf '%s\n' "$SEMVER" > "dist/pricing-$SEMVER/VERSION"
cd dist && python3 -m zipfile -c "pricing-$SEMVER.zip" "pricing-$SEMVER"
python3 -m zipfile -l "pricing-$SEMVER.zip"
'''
archiveArtifacts artifacts: "dist/pricing-${env.SEMVER}.zip", fingerprint: true
}
}
// 6.4.6: deploy the digest just published to staging with Ansible,
// then rerun unchanged and require changed=0 (idempotence).
stage('Deploy staging') {
@@ -161,6 +210,7 @@ release_image: ${env.IMAGE_DIGEST}
expected_version: ${env.APP_VERSION}
expected_commit: ${env.APP_COMMIT}
expected_total: ${env.EXPECTED_TOTAL}
release_version: ${env.SEMVER}
public_url: https://staging.ssw590-08.me
proxy_network: gitea-net
"""
@@ -193,7 +243,7 @@ proxy_network: gitea-net
// Only APPROVERS can approve; Abort or the timeout stops the run.
timeout(time: 30, unit: 'MINUTES') {
env.APPROVER = input(
message: """Promote ${env.APP_VERSION} to production (https://app.ssw590-08.me)?
message: """Promote ${env.APP_VERSION} (release ${env.SEMVER}) to production (https://app.ssw590-08.me)?
Source commit: ${env.APP_COMMIT}
Image digest: ${env.IMAGE_DIGEST}
Security scans: source and image gates PASSED (fixable HIGH/CRITICAL block).
@@ -217,6 +267,7 @@ release_image: ${env.IMAGE_DIGEST}
expected_version: ${env.APP_VERSION}
expected_commit: ${env.APP_COMMIT}
expected_total: ${env.EXPECTED_TOTAL}
release_version: ${env.SEMVER}
public_url: https://app.ssw590-08.me
proxy_network: gitea-net
approved_by: ${env.APPROVER}
Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

+16
View File
@@ -114,4 +114,20 @@ confirmed, as the assistant did not create those two chapters.
Exporter to the public hostnames is inferred from the Compose networks, not
tested.
\item \textbf{Secure delivery and rollback.} Date: November 12--13, 2026.
Tool and model: Claude (configured model claude-opus-5-5). Task: split the
work; write the delivery agent Dockerfile and Compose file, the hash-locked
requirements, the Dockerfile changes, and the \texttt{Jenkinsfile} stages for
publishing, staging, idempotence, restricted approval, production promotion,
and record-based redeployment; guide the registry, deploy-account, Caddy,
rollback, failure, and monitoring steps; draft and edit Chapter 11 and the
deployment diagram. Inputs: manual Chapter 6 and its starter files; Jenkins
console output, screenshots, release records, commit hashes, and per-second
probe logs supplied by the students. Output used: the files above and
chapter text. Human review and corrections: the students ran every step on
the real services and supplied all evidence; a registry token pasted into
the chat was revoked and replaced; Jenkins times were found to be UTC and
converted to EST; the Prometheus edit was found not to be loaded and the
container was recreated. Unresolved assumptions: none.
\end{itemize}
+4 -3
View File
@@ -41,10 +41,10 @@
\newcommand{\CourseName}{DevOps}
\newcommand{\Instructor}{Samah Keshiro and Kayla Holmes}
\newcommand{\Organization}{Stevens Institute of Technology}
\newcommand{\DocumentDate}{November 13, 2026}
\newcommand{\DocumentDate}{November 29, 2026}
\newcommand{\DueDate}{[Due Date and Time]}
\newcommand{\VERSION}{Version 1.7 (draft)}
\newcommand{\AssignmentNumber}{7}
\newcommand{\VERSION}{Version 1.8 (draft)}
\newcommand{\AssignmentNumber}{8}
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
@@ -138,6 +138,7 @@
\include{devopsCI}
\include{devopsSRE}
\include{devopsSecureDelivery}
\include{devopsZammad}
\printglossaries
+1 -1
View File
@@ -10,7 +10,7 @@
\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule
\endhead
November 13, 2026 / 1.7 (draft) & SK, KH & In progress: Secure Delivery and Rollback assignment. Added the trusted Jenkins delivery agent, locked dependencies and pinned base image, the Gitea container registry, staging and production proxy routes, image build and publish by digest, and Ansible deployment to staging with an idempotence check. Security gates, approval and promotion, v2 and recovery, and monitoring sections still to be completed. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SecureDelivery}, \ChapterRef{PWDHST} \\
November 13, 2026 / 1.7 & SK, KH & Secure Delivery and Rollback assignment: trusted Jenkins delivery agent, locked dependencies and pinned base image, Gitea container registry, staging and production proxy routes, security gates with a blocked run, build once and publish by digest, Ansible deployment with an unchanged rerun, restricted approval and promotion of the same digest, v2 release, production rollback and staging failure recovery, production health probe, runbooks, and traceability. Updated the Hosts and Passwords tables, Glossary, Bibliography, and AI Prompt Log. & \ChapterRef{SecureDelivery}, \ChapterRef{PWDHST} \\
October 29, 2026 / 1.6 & SK, KH & Completed the Introduction to SRE assignment: deployed Prometheus, Grafana OSS, Node Exporter, and Blackbox Exporter as four pinned, persistent containers on the existing Droplet; published authenticated Grafana at \texttt{metrics.ssw590-08.me}; built a six-panel dashboard; defined an availability SLI and SLO; configured and tested Grafana-managed alerts with a Discord contact point; and ran a controlled Jenkins outage with a blameless review. Updated the Hosts and Passwords tables and the Glossary. & \ChapterRef{SRE}, \ChapterRef{PWDHST} \\
+4
View File
@@ -74,6 +74,10 @@ Gitea container registry
& Push: Jenkins credential \texttt{gitea-registry-push}; pull: root on the Droplet
& Package-write and package-read tokens; never stored in Git, logs, or screenshots\\
\hline
Production approvers (Jenkins)
& samahk, kaylah7
& Personal Jenkins logins; passwords not recorded here. Only these users can approve production or a production rollback\\
\hline
Jenkins delivery agent
& delivery-agent
& Agent secret in a file on the Droplet beside \texttt{agent/compose.yaml}; not in Git\\
+45
View File
@@ -158,3 +158,48 @@
url = {https://github.com/pypa/pip-audit},
note = {Accessed: Nov. 13, 2026}
}
@misc{JenkinsInput,
author = {{Jenkins Project}},
title = {{Pipeline: Input Step}},
howpublished = {Jenkins Pipeline Steps Reference},
year = {2026},
url = {https://www.jenkins.io/doc/pipeline/steps/pipeline-input-step/},
note = {Accessed: Nov. 13, 2026}
}
@misc{ZammadCompose,
author = {{Zammad GmbH}},
title = {{zammad-docker-compose: Zammad Docker Compose deployment}},
howpublished = {GitHub repository},
year = {2026},
url = {https://github.com/zammad/zammad-docker-compose},
note = {Accessed: Nov. 29, 2026}
}
@misc{ZammadDocker,
author = {{Zammad GmbH}},
title = {{Install with Docker Compose}},
howpublished = {Zammad System Documentation},
year = {2026},
url = {https://docs.zammad.org/en/latest/install/docker-compose.html},
note = {Accessed: Nov. 29, 2026}
}
@misc{ZammadHardware,
author = {{Zammad GmbH}},
title = {{Hardware Requirements}},
howpublished = {Zammad System Documentation},
year = {2026},
url = {https://docs.zammad.org/en/latest/prerequisites/hardware.html},
note = {Accessed: Nov. 29, 2026}
}
@misc{ZammadRoles,
author = {{Zammad GmbH}},
title = {{Roles}},
howpublished = {Zammad Admin Documentation},
year = {2026},
url = {https://admin-docs.zammad.org/en/latest/manage/roles/index.html},
note = {Accessed: Nov. 29, 2026}
}
+400 -56
View File
@@ -31,10 +31,21 @@ Droplet, so they share a failure domain and its CPU, memory, and disk: separate
Compose projects give configuration separation, not high availability.
\textbf{Division of work.} Sections~\ref{sec:del-baseline}--\ref{sec:del-build}
and Section~\ref{sec:del-ansible} were carried out by \texttt{samahk13}, who
holds the Gitea administrator, Jenkins, DNS, and Droplet SSH access.
Sections~\ref{sec:del-security} and~\ref{sec:del-promote}--\ref{sec:del-ops}
were carried out by \texttt{kholmes}.
and~\ref{sec:del-ansible}--\ref{sec:del-ops} were carried out by
\texttt{samahk13} (Jenkins user \texttt{samahk}), who holds the Gitea
administrator, Jenkins, DNS, and Droplet SSH access.
Section~\ref{sec:del-security} was carried out by \texttt{kholmes} (Jenkins user
\texttt{kaylah7}).
\textbf{Times and run numbers.} Jenkins displays times in UTC. This chapter gives
each time in Eastern Standard Time (EST, UTC$-$5) and, where it helps, the UTC
value shown in a screenshot. The Jenkins job for
\texttt{feature/issue-24-delivery} restarted its run numbers on November 13,
2026, so the November 12 runs in Sections~\ref{sec:del-baseline}
and~\ref{sec:del-ansible} (an earlier \#5--\#8) are recorded by their
screenshots and are no longer listed in Jenkins. Every run link in this chapter
points to the current numbering, \#1 onwards from November 13
(Figure~\ref{fig:del-run-history}).
\section{Deployment Architecture}
\label{sec:del-architecture}
@@ -62,9 +73,22 @@ were carried out by \texttt{kholmes}.
Section~\ref{sec:del-ops}.
\end{itemize}
\FillIn{team deployment diagram (HW8 images/delivery-architecture.png) showing
actual hosts, container boundaries, volumes and bind mounts, Ansible SSH, both
environments, proxy, and monitoring}
\delfig{delivery-architecture.png}{1.0}{Deployment architecture on the single
Droplet. Red arrows are the only connections that cross the host boundary or carry
deployment rights: public HTTPS to Caddy, and Ansible SSH from the trusted agent
to the \texttt{deploy} account.}{fig:del-architecture}
\textbf{Public versus private.} Only Caddy is reachable from the Internet
(HTTPS 443, plus 80 for redirects); SSH is restricted by the firewall. Gitea,
Jenkins, the agent, both pricing containers, and the monitoring stack listen only
on Docker networks, and no application port is published on the host. Prometheus
probes the public HTTPS names through Caddy, as a user would.
\textbf{Deployment rights.} Only the Jenkins delivery agent holds the registry
write token and the \texttt{deploy} SSH key, and it runs only for trusted branches.
Production changes additionally need a Jenkins approval from \texttt{samahk} or
\texttt{kaylah7}. Droplet administration (Caddy, DNS, monitoring) is limited to
\texttt{samahk13}.
\section{Prepare the Repository and Establish a Baseline}
\label{sec:del-baseline}
@@ -126,8 +150,8 @@ python3 -m venv .venv
\begin{itemize}
\item \textbf{Controlled failure:} Jenkins run
\texttt{feature/issue-24-delivery} \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/6/}{\#6}, started by a push at 11:19 PM EST on
November 12, 2026, ran on \texttt{delivery-agent}. The deliberately
\texttt{feature/issue-24-delivery} \#6 of the earlier numbering, started by a
push at 6:19 PM EST (23:19 UTC) on November 12, 2026, ran on \texttt{delivery-agent}. The deliberately
broken test \texttt{test\_price} failed, so the \emph{Unit tests} stage
failed after 6 seconds and every later delivery stage (security scans,
build, publish, deploy) was skipped
@@ -135,16 +159,14 @@ python3 -m venv .venv
delivery. The test's expected total was changed from 30 to 31, so it
failed with \texttt{AssertionError: 30 != 31} while the application itself
was unchanged.
\item \textbf{Passing baseline and restore:} run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/5/}{\#5} (11:13 PM EST), before the
\item \textbf{Passing baseline and restore:} run \#5 (6:13 PM EST), before the
controlled failure, passed all three tests. The test was then restored to
expect 30, and run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7} (11:20 PM EST) passed all three tests again. The same tests also
expect 30, and run \#7 (6:20 PM EST) passed all three tests again. The same tests also
pass locally in a fresh virtual environment (\texttt{Ran 3 tests in
0.085s, OK}).
\end{itemize}
All times in this chapter are Eastern Standard Time (EST), as displayed by Jenkins.
\delfig{build6-unit-test-fail.png}{1.0}{November 12, 2026, 11:19 PM EST ---
\delfig{build6-unit-test-fail.png}{1.0}{November 12, 2026, 6:19 PM EST (shown by Jenkins as 11:19 PM UTC) ---
Jenkins \texttt{feature/issue-24-delivery} run \#6 on \texttt{delivery-agent}:
\texttt{test\_price} fails, the Unit tests stage stops the run, and the build,
publish, and deploy stages are skipped.}{fig:del-test-fail}
@@ -247,7 +269,7 @@ Compose plugin ($\geq$ 2.18) & v5.5.1 (meets the minimum)\\
no credentials and no Docker socket. The \emph{Delivery} stages run only for
the trusted branch pattern \texttt{TRUSTED\_BRANCH}. In the repository, the pattern is currently
\texttt{main|feature/issue-24-delivery} (Figure~\ref{fig:del-commit-diff}),
so the delivery runs recorded in this chapter (builds \#4 to \#7) ran from the
so the delivery runs recorded in this chapter (\#4 to \#16) ran from the
feature branch. Until the pattern is changed back to \texttt{main}, code on
that branch can build, publish, and deploy without a merge review. The
Jenkinsfile carries a comment to remove the feature branch from the pattern
@@ -296,9 +318,11 @@ network per application would give stronger lateral isolation.
The \texttt{Jenkinsfile} keeps the Chapter~\ref{Chapter:ContinuousIntegration}
checks and adds a \emph{Delivery} block on the \texttt{delivery} agent with
these stages: Checkout, Unit tests, Security scan: source, Build image, Security
scan: image, Publish, Deploy staging, Staging idempotence, and Approve and deploy
production. The pipeline sets \texttt{disableConcurrentBuilds()}, so two runs
cannot change staging or production at the same time.
scan: image, Publish, Deploy staging, Staging idempotence, Approve production, and
Deploy production. A separate \emph{Redeploy release record} path, used for
rollback and recovery, is described in Section~\ref{sec:del-v2}. The pipeline sets \texttt{disableConcurrentBuilds()}, so two runs
cannot change staging or production at the same time. The IT manual is also compiled by this pipeline on the Droplet, in the \emph{Compile manual (LaTeX)} stage, and archived as a versioned PDF. The resulting PDF is archived as Jenkins build artifact named with the release version.
We've officially moved our manual build into Jenkins instead of Gitea Actions.
The image is built once per source commit, with the commit baked in at build
time. The \emph{Publish} stage pushes it, deletes the local copy, and pulls it
@@ -323,31 +347,31 @@ with a \texttt{tmpfs} for \texttt{/tmp}.
{\small
\begin{tabularx}{\linewidth}{L{1.9cm}YYY}
\toprule
\textbf{Release v1} & \textbf{First build (superseded)} & \textbf{Rebuild (superseded)} & \textbf{Run \#7 (latest)}\\ \midrule
Source commit & \texttt{\seqsplit{2a35f97071c95b23bccb8c973099f2991c998599}} & \texttt{\seqsplit{3fcd04010ad115df943d2d001dbc4a1523c2a6d1}} & \texttt{c46f127e8c}\\
Jenkins build & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8} & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/4/}{\#4} & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7}\\
Image digest & \texttt{\seqsplit{sha256:ce91d0552da2a4580557ec65aedec04b278fe918df1f02b23c971ca45cc3d97c}} & \texttt{\seqsplit{sha256:2688685992aa57bc94aaca36ea3cce22fd2cd9ba162ea2e09437531594e15bb7}} & \texttt{\seqsplit{sha256:5e7c72446cfc592fdbef07f085b8045bc366068a2aac039c027da7777a27ad59}}\\
Published & November 12, 2026, 11:51 PM EST & November 13, 2026, after the 7:48 PM EST image scan in the same build & November 13, 2026, \FillIn{time from the Publish stage}\\
Status & Failed the security policy: 7 fixable High findings (Section~\ref{sec:del-security}) & Passed the policy; replaced by run \#7 & Passed the policy (both scans ran before Publish and the run finished successfully); \FillIn{unfixed High count from the run's image-summary file}\\
\textbf{Release v1} & \textbf{First build (superseded)} & \textbf{Rebuild (superseded)} & \textbf{Released v1, run \#9}\\ \midrule
Source commit & \texttt{\seqsplit{2a35f97071c95b23bccb8c973099f2991c998599}} & \texttt{\seqsplit{3fcd04010ad115df943d2d001dbc4a1523c2a6d1}} & \texttt{\seqsplit{69f1fe05cf72848e250d71349a76ee1157d44df3}}\\
Jenkins build & \#8 (earlier numbering, Nov 12) & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/4/}{\#4} & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/9/}{\#9}\\
Image digest & \texttt{\seqsplit{sha256:ce91d0552da2a4580557ec65aedec04b278fe918df1f02b23c971ca45cc3d97c}} & \texttt{\seqsplit{sha256:2688685992aa57bc94aaca36ea3cce22fd2cd9ba162ea2e09437531594e15bb7}} & \texttt{\seqsplit{sha256:7689c624960c3d47cc7eb0bd456b4023923a55a64e6941f621c82315b374adf5}}\\
Published & November 12, 2026, 6:51 PM EST & November 13, 2026, after the 7:48 PM EST image scan in the same build & November 13, 2026, run started 10:00 PM EST\\
Status & Failed the security policy: 7 fixable High findings (Section~\ref{sec:del-security}) & Passed the policy; superseded & Passed both gates: 0 fixable, 47 unfixed High (accepted exception); approved and promoted to production\\
\bottomrule
\end{tabularx}}
\medskip
Run \#7 is the first run after the blocked-run test (Section~\ref{sec:del-security}).
Its commit \texttt{c46f127e8c} removes the fixture that commit \texttt{05d3c58c3a}
had added, and each of those two commits changed only that one file, so the
source files are the same as in the rebuild. The digest is different because the
commit is baked into each image at build time, so every commit produces a new
image. A later run, with a new commit, would again produce a new digest. The
release that is promoted to production is therefore the one built by the run that
passes the approval stage, and its digest is the one recorded for v1.
Every commit produces a new image, because the commit is baked into the image at
build time. Runs \#7 (commit \texttt{c46f127e8c}, digest
\texttt{sha256:5e7c7244\ldots}) and \#8 also built v1 images on the way to the
final pipeline. The v1 that was released is the one built by run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/9/}{\#9}, the
first run with the approval stage: its digest \texttt{sha256:7689c624\ldots} was
deployed to staging, approved, and promoted unchanged to production
(Section~\ref{sec:del-promote}). The v1 application files are the same in all of
these builds.
\medskip
All digests are in the registry repository \texttt{git.ssw590-08.me/ssw-590-08/pricing}.
Earlier builds are kept as a record. They were superseded by new builds, not
edited, so their images remain in the registry and their digests are unchanged.
\delfig{publish-digest.png}{1.0}{November 12, 2026, run \#8 --- Jenkins Publish
\delfig{publish-digest.png}{1.0}{November 12, 2026, 6:51 PM EST, run \#8 (earlier numbering) --- Jenkins Publish
stage: the v1 image is pushed, the local copy deleted and pulled back from the
registry, and its registry digest recorded. The registry token is masked and
never printed.}{fig:del-publish}
@@ -564,9 +588,10 @@ repository history. Run \#7, on the removal commit, finished with
\texttt{Finished: SUCCESS} (Figure~\ref{fig:del-run7-success}). In that run the
\emph{Approve and deploy production} stage was still a placeholder that printed
``Not implemented yet'', so no production step ran. Run \#7 also executed the
Publish and Deploy staging stages for commit \texttt{c46f127e8c}.
\FillIn{image digest published by run \#7, and whether it replaces build \#4 as
the v1 release}
Publish and Deploy staging stages for commit \texttt{c46f127e8c}, publishing
digest \texttt{sha256:5e7c7244\ldots}. Neither run \#4 nor run \#7 is the
released v1; that is run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/9/}{\#9} (Section~\ref{sec:del-promote}), whose
image scan again reported 0 fixable and 47 unfixed HIGH findings.
\delfig{del-fixture-added.png}{1.0}{November 13, 2026 --- Gitea commit page for
\texttt{05d3c58c3a}, ``testing build block'', which adds
@@ -658,7 +683,7 @@ Run \#7 & First & \texttt{ok=9 changed=2 unreachable=0 failed=0 skipped=0 rescue
\end{tabularx}
\medskip
\textbf{First build, run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8}} (November 12, 2026, 11:51 PM EST): the first
\textbf{First build, run \#8 of the earlier numbering} (November 12, 2026, 6:51 PM EST): the first
run created the environment and started the container (\texttt{changed=3}); the
identical second run changed nothing, and the stage's check matched the recap
line \texttt{startup : ok=9 changed=0 unreachable=0 failed=0}. In the second run
@@ -680,7 +705,7 @@ The identical second run changed nothing (\texttt{changed=0}), and the stage's
\texttt{rerun.log} matched (Figure~\ref{fig:del-recap7-second}), so the
\emph{Staging idempotence} stage passed.
\delfig{staging-idempotence.png}{1.0}{November 12, 2026, run \#8 --- Jenkins
\delfig{staging-idempotence.png}{1.0}{November 12, 2026, 6:51 PM EST, run \#8 (earlier numbering) --- Jenkins
Staging idempotence stage: the second, unchanged run passes every check and
reports \texttt{changed=0}.}{fig:del-idempotence}
@@ -714,38 +739,357 @@ a total of USD 30.}{fig:del-staging-rebuild}
\section{Approve and Promote the Same Image}
\label{sec:del-promote}
\FillIn{kholmes: restricted Jenkins input step with timeout, approver and
decision, v1-production record with the same digest, production smoke tests}
\subsection{Restricted Approval}
After \emph{Staging idempotence}, the pipeline stops at an \emph{Approve
production} stage that uses the Jenkins \texttt{input} step~\cite{JenkinsInput}:
\begin{minted}[breaklines,breakanywhere]{groovy}
def APPROVERS = 'samahk,kaylah7' // Jenkins user IDs; anonymous users cannot approve
timeout(time: 30, unit: 'MINUTES') {
env.APPROVER = input(
message: """Promote ${env.APP_VERSION} to production (https://app.ssw590-08.me)?
Source commit: ${env.APP_COMMIT}
Image digest: ${env.IMAGE_DIGEST}
Security scans: ... ${scan}
Staging: deployed, HTTPS health/version/commit/total ${env.EXPECTED_TOTAL} passed, rerun changed=0.""",
ok: 'Approve and deploy to production',
submitter: APPROVERS, submitterParameter: 'APPROVER')
}
\end{minted}
\begin{itemize}
\item \textbf{Restricted:} only the Jenkins users \texttt{samahk} and
\texttt{kaylah7} can approve. Anyone else, including an anonymous user, cannot.
\item \textbf{Informed:} the prompt shows the source commit, the image digest,
the scan result (the archived \texttt{image-summary.txt}), and the staging
result (Figure~\ref{fig:del-approve}).
\item \textbf{Recorded:} \texttt{submitterParameter} returns the actual
approver, who is printed in the log with the time and written into the
production release record (\texttt{approved\_by}, \texttt{approved\_at}).
\item \textbf{Stops safely:} \emph{Abort}, or no answer within 30 minutes, ends
the run before any production step. Runs
\href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/12/}{\#12}
and \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/14/}{\#14}
were aborted at this prompt, and \emph{Deploy production} did not run
(Figure~\ref{fig:del-aborted}).
\end{itemize}
\subsection{Promotion of v1}
Run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/9/}{\#9}
(push at 10:00 PM EST on November 13, 2026; source commit
\texttt{69f1fe05cf72848e250d71349a76ee1157d44df3}) passed every gate, deployed to
staging with an unchanged rerun, and stopped for approval. \texttt{samahk}
approved at 10:04:14 PM EST. The \emph{Deploy production} stage then wrote
\texttt{release-v1-production.yml} from the values already recorded in the run,
archived it before deploying, and ran the same playbook with it. Nothing was
rebuilt: production received the digest that staging had passed.
\begin{minted}[breaklines,breakanywhere]{yaml}
target_env: production
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:7689c624960c3d47cc7eb0bd456b4023923a55a64e6941f621c82315b374adf5
expected_version: v1
expected_commit: 69f1fe05cf72848e250d71349a76ee1157d44df3
expected_total: 30
public_url: https://app.ssw590-08.me
proxy_network: gitea-net
approved_by: samahk
approved_at: 2026-11-14T03:04:14+00:00
\end{minted}
The record is committed as \texttt{releases/v1-production.yml}, with
\texttt{releases/v1-staging.yml} beside it; it holds no credentials. The playbook's
production smoke tests passed, and \url{https://app.ssw590-08.me/} returned
\texttt{v1}, commit \texttt{69f1fe0}, and a total of USD~30
(Figure~\ref{fig:del-prod-v1}).
\delfig{approve-prompt-run9.png}{1.0}{November 13, 2026, about 10:03 PM EST, run
\#9 --- the restricted approval prompt for v1, showing the source commit, image
digest, scan summary (47 unfixed HIGH, 0 fixable), and staging
result.}{fig:del-approve}
\delfig{prod-v1-run9.png}{0.75}{November 13, 2026, after 10:04 PM EST ---
production, v1 from run \#9: \url{https://app.ssw590-08.me/} returns version
\texttt{v1} and commit \texttt{69f1fe0}, and \texttt{/price?quantity=3} returns
30.}{fig:del-prod-v1}
\delfig{approval-aborted-run14.png}{1.0}{November 13, 2026, 10:39 PM EST, run
\#14 --- the approval was aborted after 17 seconds; \emph{Deploy production} did
not run.}{fig:del-aborted}
\section{Release v2 and Exercise Two Recovery Cases}
\label{sec:del-v2}
\FillIn{kholmes: v2 release in both environments, healthy rollback of
production to v1, failed staging deployment (Gunicorn on 8001) and recovery,
timeline and measured interruption, state-compatibility discussion}
\subsection{Release v2}
The supplied v2 changes (\texttt{VERSION = "v2"}, \texttt{UNIT\_PRICE = 12}, and
the matching test expectations: total 36, version \texttt{v2}) were committed
together with the v1 release records as
\texttt{d6787727f8ebce3f8ac0f8f6d36ddef352ba63da}. Run
\href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/10/}{\#10}
(10:13 PM EST) passed tests and both security gates, published digest
\texttt{sha256:d7aa3cfc\ldots}, deployed it to staging with an unchanged rerun, and
was approved by \texttt{samahk} at 10:17:50 PM EST. Production then returned
\texttt{v2}, commit \texttt{d678772}, and a total of USD~36
(Figure~\ref{fig:del-prod-v2}). The v2 records were committed as
\texttt{releases/v2-staging.yml} and \texttt{releases/v2-production.yml} in
\texttt{7b73df1}; the v1 records were kept.
\delfig{prod-v2-run10.png}{0.75}{November 13, 2026, after 10:18 PM EST ---
production, v2 from run \#10: version \texttt{v2}, commit \texttt{d678772}, total
36.}{fig:del-prod-v2}
\subsection{Rollback and Recovery Mechanism}
Rollback reuses the release records. When the pipeline's \texttt{DEPLOY\_RECORD}
parameter names a committed record, the \emph{Delivery} block is skipped and a
\emph{Redeploy release record} path runs instead: it checks that the record
exists under \texttt{releases/}, prints it, asks for the same restricted approval
if the target is production, and runs the playbook with that record and the
Ansible files of the commit being built. Nothing is rebuilt, and the playbook's
health, version, commit, and price checks still decide success. The
configuration that is restored is therefore both the image digest in the record
and the template and playbook of the chosen commit.
\subsection{Case 1: Healthy Rollback of Production to v1}
Production was healthy on v2. Rolling back to v1 was a planned business
decision, made at 10:23 PM EST, so there was no failure to detect.
\begin{tabularx}{\linewidth}{L{3.2cm}Y}
\toprule
\textbf{Time (EST)} & \textbf{Event}\\ \midrule
10:23 PM & Decision; run \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/11/}{\#11} started with \texttt{DEPLOY\_RECORD=releases/v1-production.yml} at configuration commit \texttt{d678772}; approved by \texttt{samahk}\\
10:24:07 & First failed request: \texttt{https://app.ssw590-08.me/health} returned HTTP 502 while Compose recreated the container\\
10:24:09 & Last failed request (3 failures, 1-second polling)\\
10:24:10 & Service answering again; the playbook's checks then passed and the run finished successfully\\
\bottomrule
\end{tabularx}
\medskip
Production returned \texttt{v1}, commit \texttt{69f1fe0}, health OK, and a total
of 30 (Figure~\ref{fig:del-rollback}). The observed interruption was about 3
seconds, measured on the Droplet with a once-per-second \texttt{curl} loop:
\begin{minted}[breaklines,breakanywhere]{bash}
while true; do echo "$(date +%T) $(curl -s -o /dev/null -w '%{http_code}' https://app.ssw590-08.me/health)"; sleep 1; done | tee ~/rollback-probe.log
grep -v " 200$" ~/rollback-probe.log # 03:24:07, 03:24:08, 03:24:09 UTC: 502
\end{minted}
This is a recreate deployment, not a zero-downtime one: Caddy returns 502 while
the old container is stopped and the new one starts.
\delfig{prod-rollback-v1-run11.png}{0.75}{November 13, 2026, after 10:24 PM EST
--- production after the rollback in run \#11: version \texttt{v1}, commit
\texttt{69f1fe0}, total 30.}{fig:del-rollback}
\subsection{Case 2: Failed Deployment in Staging and Recovery}
\begin{enumerate}
\item \textbf{Fault, in a separate configuration commit.} Commit
\texttt{1222628} (``Controlled failure: staging Gunicorn on 8001'') added to
\texttt{ansible/templates/compose.yaml.j2}, for staging only:
\begin{minted}[breaklines,breakanywhere]{jinja}
{% if target_env == 'staging' %}
command: ["gunicorn", "--bind", "0.0.0.0:8001", "app:app"]
{% endif %}
\end{minted}
Gunicorn now listened on 8001 while the image health check still tested 8000.
Nothing else was changed: not the Docker daemon, Caddy, Gitea, or Jenkins.
\item \textbf{Failure.} Run
\href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/13/}{\#13}
(10:33 PM EST) passed tests, scans, and publish, but \emph{Deploy staging}
failed after 24 seconds: the container never became healthy, so the Compose
wait in the playbook failed. Every later stage, including approval and
production, was skipped (Figure~\ref{fig:del-failed}). Production stayed on v1.
\item \textbf{Restore the reviewed configuration.} \texttt{git revert} created
commit \texttt{1841a7d}, which restores the template of the reviewed
commits. Its automatic run
\href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/14/}{\#14}
deployed staging successfully and was aborted at the production approval
(Figure~\ref{fig:del-aborted}).
\item \textbf{Redeploy the reviewed release record.} Run
\href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/15/}{\#15}
(10:42 PM EST) redeployed \texttt{releases/v2-staging.yml} (digest
\texttt{sha256:d7aa3cfc\ldots}, commit \texttt{d678772}) with configuration
commit \texttt{1841a7d}. The playbook's HTTPS checks passed, and staging
returned \texttt{v2}, commit \texttt{d678772}, and a total of 36
(Figure~\ref{fig:del-restored}).
\end{enumerate}
\delfig{staging-failed-run13.png}{1.0}{November 13, 2026, 10:33 PM EST, run
\#13 --- the controlled failure: \emph{Deploy staging} fails (Compose wait,
unhealthy container), and staging idempotence, approval, and production are
skipped.}{fig:del-failed}
\delfig{staging-restored-v2-run15.png}{0.75}{November 13, 2026, after 10:42 PM
EST --- staging after recovery run \#15: version \texttt{v2}, commit
\texttt{d678772}, total 36.}{fig:del-restored}
\subsection{State Compatibility}
Both rollbacks were safe because the pricing service is stateless: it has no
database, no stored data, and no external side effects, so running the older
image is enough to restore the older behaviour. Image-only rollback would not be
safe in three common cases:
\begin{itemize}
\item \textbf{Database migration.} If v2 had dropped or renamed a column, v1
would fail against the migrated database, and rolling the schema back could
lose data written by v2.
\item \textbf{External payment.} Charges made at the v2 price of 12 are already
with the payment provider; redeploying v1 does not reverse them, and they
would need refunds or reconciliation.
\item \textbf{Incompatible stored state.} Sessions, queued jobs, or cached data
written in a v2-only format could be unreadable by v1.
\end{itemize}
A compatible approach is \textbf{expand and contract}: first release a schema
change that only adds (for example, a new nullable column) and works with both
versions; then deploy the code that uses it; and only after the new version is
proven, remove the old structure in a later release. During the expand phase,
either version can run against the same data, so rolling back the image stays
safe.
\section{Reuse Monitoring and Document Operations}
\label{sec:del-ops}
\FillIn{kholmes: production /health Blackbox probe and Grafana panel, release
and rollback timestamps correlated with monitoring, runbooks, approvers,
resource use, cleanup plan}
\subsection{Production Health Probe}
The production endpoint \texttt{https://app.ssw590-08.me/health} was added to the
Blackbox Exporter's \texttt{https} job in
\texttt{monitoring/prometheus/prometheus.yml}, beside the existing Gitea and
Jenkins probes; the host metrics are unchanged. The file is bind-mounted read-only
into the Prometheus container, so the container was recreated
(\texttt{docker compose up -d -{}-force-recreate prometheus}) to load it. The
probe has recorded since 10:50:30 PM EST on November 13, 2026. Its availability is
shown in Grafana with
\texttt{probe\_success\{instance="https://app.ssw590-08.me/health"\}}
(Figure~\ref{fig:del-grafana}). The probe only reports status; the version and
price checks stay in the pipeline, because a status probe cannot validate a price.
\subsection{Correlating a Release with Monitoring}
The probe was added after the rollback in run \#11, so that rollback has no
Prometheus data; its evidence is the per-second log above. To correlate a
deployment with monitoring, production was then rolled forward to v2 with run
\href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/16/}{\#16}
(\texttt{DEPLOY\_RECORD=releases/v2-production.yml}, approved):
\begin{tabularx}{\linewidth}{L{3.2cm}Y}
\toprule
\textbf{Time (EST)} & \textbf{Observation}\\ \midrule
10:50:30 PM & First \texttt{probe\_success} sample for production (value 1)\\
10:51 PM & Run \#16 started; approved by \texttt{samahk}\\
10:55:16--10:55:22 & HTTP 502 in the per-second log (6 failed requests, about 7 seconds)\\
10:55:35 & Playbook checks passed: ``Redeploy verified'' (Figure~\ref{fig:del-redeploy}); \texttt{changed=2}\\
10:50--10:58 PM & Grafana shows \texttt{probe\_success} = 1 at every sample (Figure~\ref{fig:del-grafana})\\
\bottomrule
\end{tabularx}
\medskip
\textbf{What was actually observed.} Prometheus probes every 30 seconds, and the
7-second interruption fell between two samples, so Grafana shows no dip and no
alert fired. The \texttt{ServiceUnavailable} rule also needs a failure lasting
1 minute before it fires (Chapter~\ref{Chapter:SRE}). Short recreate
interruptions are therefore measured by the pipeline's own checks and a
fine-grained probe, not by the 30-second monitoring stack.
\delfig{grafana-app-probe.png}{1.0}{November 13, 2026, 10:44--10:58 PM EST ---
Grafana Explore, \texttt{probe\_success} for \texttt{https://app.ssw590-08.me/health}:
data from 10:50:30 PM, value 1 throughout, including the roll-forward at
10:55 PM.}{fig:del-grafana}
\delfig{redeploy-verified-run16.png}{1.0}{November 13, 2026, run \#16 --- end of
the redeploy of \texttt{releases/v2-production.yml}: all playbook checks pass,
\texttt{changed=2}, and ``Redeploy verified'' at 03:55:35 UTC (10:55:35 PM
EST).}{fig:del-redeploy}
\delfig{jenkins-run-history.png}{0.6}{Run history of
\texttt{feature/issue-24-delivery} (times in UTC): \#9 v1 release, \#10 v2
release, \#11 rollback, \#12 and \#14 aborted at approval, \#13 controlled
failure, \#15 staging recovery, \#16 roll-forward.}{fig:del-run-history}
\subsection{Roles}
\begin{tabularx}{\linewidth}{L{3.4cm}Y}
\toprule
\textbf{Action} & \textbf{Who}\\ \midrule
Approve production & Jenkins users \texttt{samahk} and \texttt{kaylah7} only (input \texttt{submitter})\\
Deploy (staging, production) & Only the Jenkins delivery agent, for trusted branches, using \texttt{deploy-ssh}; production only after approval\\
Roll back or recover & Anyone who can start a Jenkins build sets \texttt{DEPLOY\_RECORD}; production still needs an approver\\
Droplet, Caddy, DNS, monitoring & \texttt{samahk13} (administrator SSH)\\
\bottomrule
\end{tabularx}
\subsection{Runbooks}
\textbf{Release.}
\begin{enumerate}
\item Commit the application change with its tests on a branch, review it, and merge.
\item Let the pipeline run: tests, both scans, build, publish, staging, rerun.
\item An approver checks the commit, digest, scan summary, and staging result in
the prompt, then approves or aborts.
\item After \emph{Deploy production} passes, download the two release records
from the run's artifacts and commit them under \texttt{releases/}.
\end{enumerate}
\textbf{Failed deployment.}
\begin{enumerate}
\item The run stops at the failing stage; production is untouched when staging
fails. Read the failing task in the console.
\item Revert the faulty commit (\texttt{git revert}) and push.
\item Run the pipeline with \texttt{DEPLOY\_RECORD} set to the last good record
for that environment, and confirm health, version, commit, and price.
\end{enumerate}
\textbf{Rollback.}
\begin{enumerate}
\item Decide which reviewed release to return to.
\item Start \emph{Build with Parameters} with
\texttt{DEPLOY\_RECORD=releases/<version>-production.yml}; an approver approves.
\item Confirm \texttt{/}, \texttt{/health}, and \texttt{/price?quantity=3}, and
note the start and end times. Expect a few seconds of HTTP 502.
\item Never use \texttt{docker compose down -v}, volume removal, or pruning, and
never roll back Gitea or Jenkins as part of an application rollback.
\end{enumerate}
\textbf{Cleanup (only after grading, when instructed).}
\begin{enumerate}
\item On the Droplet: \texttt{docker compose -p pricing-staging down} and
\texttt{docker compose -p pricing-production down} (without \texttt{-v}),
then remove \texttt{/opt/startup}.
\item Remove the \texttt{staging} and \texttt{app} blocks from the Caddyfile,
validate, and reload Caddy. Remove the production probe from
\texttt{prometheus.yml}.
\item Delete the \texttt{staging} and \texttt{app} DNS records.
\item Revoke the registry tokens and the \texttt{deploy-ssh} key, and delete the
\texttt{deploy} account. Keep Gitea, Jenkins, monitoring, earlier assignments,
and the evidence in this chapter.
\end{enumerate}
\subsection{Resource Use and the Single-Droplet Limitation}
\FillIn{resource use from docker stats, free -h and df -h /}
Every component (Gitea, Jenkins, the agent, both environments, Caddy, and
monitoring) shares one Droplet. One host failure stops source control, CI,
staging, production, and the monitoring that would report it, and builds compete
with production for CPU and memory. Staging and production are separated by
configuration only, not by hardware.
\section{Traceability}
\label{sec:del-trace}
\begin{tabularx}{\linewidth}{L{3.4cm}YY}
{\small
\begin{tabularx}{\linewidth}{L{2.4cm}YY}
\toprule
\textbf{Item} & \textbf{v1} & \textbf{v2}\\ \midrule
Source commit & \texttt{c46f127e8c} (run \#7; earlier: rebuild \texttt{3fcd0401}, first build \texttt{2a35f97}) & \FillIn{}\\
Configuration commit & \texttt{c46f127e8c} (same checkout as the source; Ansible files and release record come from the build's own repository checkout) & \FillIn{}\\
Image digest & \texttt{sha256:5e7c7244\ldots} (rebuild \texttt{sha256:26886859\ldots}; first build \texttt{sha256:ce91d055\ldots}) & \FillIn{}\\
Jenkins build & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/7/}{\#7} (staging; earlier \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/4/}{\#4} and \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/8/}{\#8}) & \FillIn{}\\
Scan result & Pass: both scan stages passed before Publish in run \#7 (rebuild \#4: 0 fixable High/Critical, 47 unfixed High accepted; first build failed: 7 fixable) & \FillIn{}\\
Staging result & Run \#7: rerun \texttt{changed=0}; \FillIn{health, v1, commit and total check for the run \#7 deployment} & \FillIn{}\\
Approver and time & \FillIn{} & \FillIn{}\\
Production result & \FillIn{} & \FillIn{}\\
Source commit & \texttt{\seqsplit{69f1fe05cf72848e250d71349a76ee1157d44df3}} & \texttt{\seqsplit{d6787727f8ebce3f8ac0f8f6d36ddef352ba63da}}\\
Configuration commit & \texttt{69f1fe0} (release); \texttt{d678772} (rollback, run \#11) & \texttt{d678772} (release); \texttt{1841a7d} (staging recovery \#15, production \#16)\\
Image digest & \texttt{\seqsplit{sha256:7689c624960c3d47cc7eb0bd456b4023923a55a64e6941f621c82315b374adf5}} & \texttt{\seqsplit{sha256:d7aa3cfce583a68e287dc34707f11c1d664161e65c74cd709df15330b2fd8f19}}\\
Jenkins build & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/9/}{\#9} (rollback \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/11/}{\#11}) & \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/10/}{\#10} (recovery \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/15/}{\#15}, roll-forward \href{https://ci.ssw590-08.me/job/Scrap-Web/job/feature\%252Fissue-24-delivery/16/}{\#16})\\
Scan result & Passed: 0 fixable, 47 unfixed HIGH (accepted) & Passed both gates\\
Staging result & Health, v1, commit, 30 passed; rerun \texttt{changed=0} & Health, v2, commit, 36 passed; rerun \texttt{changed=0}\\
Approver and time & \texttt{samahk}, Nov 13, 2026, 10:04:14 PM EST & \texttt{samahk}, Nov 13, 2026, 10:17:50 PM EST\\
Production result & v1, \texttt{69f1fe0}, 30 (Fig.~\ref{fig:del-prod-v1}); restored by rollback (Fig.~\ref{fig:del-rollback}) & v2, \texttt{d678772}, 36 (Fig.~\ref{fig:del-prod-v2}); restored by \#16\\
Release records & \texttt{releases/v1-staging.yml}, \texttt{releases/v1-production.yml} & \texttt{releases/v2-staging.yml}, \texttt{releases/v2-production.yml}\\
\bottomrule
\end{tabularx}
\end{tabularx}}
\medskip
Repository files: \texttt{pricing/} (application, tests, \texttt{requirements.in}
and the hash-locked \texttt{requirements.txt}, \texttt{Dockerfile}),
\texttt{Jenkinsfile}, \texttt{ansible/inventory.ini} (no secrets),
\texttt{ansible/deploy.yml}, \texttt{ansible/templates/compose.yaml.j2},
\texttt{releases/}, \texttt{security/}, and \texttt{agent/}, all on
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/feature/issue-24-delivery}{\texttt{feature/issue-24-delivery}}.
Graders can view them in Gitea and the runs in Jenkins with the course accounts
the team provided; no credentials are in this manual.
\fussy
+498
View File
@@ -0,0 +1,498 @@
\chapter{Support Ticket Management with Zammad}
\ChapterLabel{SupportDesk}
\index{Zammad}
\index{help desk}
\sloppy
% Red marker for values still to be filled in from the team's own outputs.
\providecommand{\FillIn}[1]{\textcolor{devopsRed}{\textbf{[TO FILL: #1]}}}
% Figure helper: shows a labelled box until the screenshot file exists.
\providecommand{\zfig}[4]{%
\begin{figure}[H]\centering
\IfFileExists{HW9 images/#1}{\includegraphics[width=#2\linewidth]{HW9 images/#1}}%
{\fbox{\parbox{0.8\linewidth}{\centering\vspace{1em}\textit{[Screenshot needed: HW9 images/#1]}\vspace{1em}}}}
\caption{#3}\label{#4}\end{figure}}
This chapter gives the startup's customers and operations team a shared place to
report problems, assign responsibility, and record the resolution. The official
Zammad Docker Compose stack~\cite{ZammadCompose,ZammadDocker} is deployed
unchanged as its own Compose project, three synthetic tickets are worked through
triage and resolution, one ticket is linked to an engineering issue in Gitea, and
the web service is stopped and restarted to show that tickets persist.
\textbf{Local deployment.} Zammad recommends at least two CPU cores and 6~GB of
RAM, plus 4~GB more when Elasticsearch runs on the same host~\cite{ZammadHardware}.
The team's Droplet was already short of memory after Chapter~\ref{Chapter:SecureDelivery}.
As the instructor permitted for this final assignment, Zammad was therefore deployed
with Docker on a team member's laptop instead of the Droplet. For a local
deployment the instructor waived integration with the Droplet's HTTPS proxy,
firewall, and monitoring, so Steps~5, 6, and~9 of the assignment are replaced by
the local checks in Sections~\ref{sec:z-exposure} and~\ref{sec:z-recovery}. A
video submitted in Canvas shows the running installation and every workflow,
because the TA cannot reach a local installation.
\textbf{Division of work.} \texttt{kholmes} deployed and operated Zammad on her
laptop (Sections~\ref{sec:z-baseline}--\ref{sec:z-workflow}
and~\ref{sec:z-recovery}) and recorded the video. \texttt{samahk13} created the
Gitea issue and its links (Section~\ref{sec:z-gitea}), rechecked the existing
services (Section~\ref{sec:z-retest}), and wrote this chapter.
\section{Deployment Architecture}
\label{sec:z-architecture}
\zfig{zammad-architecture.png}{0.95}{Local Zammad deployment. Blue boxes are
Zammad containers, gray boxes are named volumes. Only \texttt{zammad-nginx} is
published, and only on the laptop's loopback address; every other service is
reachable only on the Compose project's private network.}{fig:z-architecture}
\begin{itemize}
\item \textbf{Entry point:} \texttt{zammad-nginx} is published on
\texttt{127.0.0.1:8080}, so only a browser on the same laptop can reach it.
There is no TLS: traffic never leaves the machine, and the HTTPS proxy was
waived for local installs. Zammad is configured for plain HTTP
(\texttt{ZAMMAD\_HTTP\_TYPE=http}, \texttt{NGINX\_SERVER\_SCHEME=http}), which
must match the scheme the browser uses or login fails with a CSRF error.
\item \textbf{Private services:} PostgreSQL, Elasticsearch, Redis, Memcached,
the Rails server, WebSocket server, scheduler, and backup service are on the
project network only, with no published ports.
\item \textbf{Earlier services:} Gitea, Jenkins, Caddy, monitoring, and the
Chapter~\ref{Chapter:SecureDelivery} application stay on the Droplet,
unchanged. The only link is a manual one: a ticket holds a Gitea issue URL,
and the issue holds the ticket number.
\end{itemize}
\section{Capacity Baseline}
\label{sec:z-baseline}
Both team laptops have 8~GB of RAM. The Windows laptop had only about 0.9~GB
free with normal applications open, so the macOS laptop was used.
\begin{tabularx}{\linewidth}{L{4.2cm}Y}
\toprule
\textbf{Item} & \textbf{Value}\\ \midrule
Host & MacBook Pro, Apple silicon (\texttt{arm64}), 8 CPU cores\\
Memory & 8~GB total (\texttt{hw.memsize} 8{,}589{,}934{,}592 bytes); 49--50\% free before start-up\\
Docker Desktop memory limit & 5.78~GiB (the container limit shown by \texttt{docker stats})\\
Docker / Compose & Docker Desktop 4.91.0, Engine 29.8.0 (\texttt{linux/arm64}); Compose v5.5.1\\
Disk free & 24~GiB available on \texttt{/}\\
\bottomrule
\end{tabularx}
\zfig{baseline.png}{0.75}{Capacity baseline on the laptop before Zammad was
started. The only running container was the team's existing Gitea Actions LaTeX
runner (37~MiB).}{fig:z-baseline}
\section{Official Compose Stack}
\label{sec:z-deploy}
\subsection{Obtaining a Fixed Revision}
The official repository was cloned into its own directory and checked out
detached, so the exact revision is recorded~\cite{ZammadCompose}:
\begin{minted}[breaklines,breakanywhere]{bash}
mkdir -p ~/dos-support && cd ~/dos-support
git clone https://github.com/zammad/zammad-docker-compose.git
cd zammad-docker-compose
git switch --detach
git rev-parse HEAD
cp .env.dist .env && chmod 600 .env
\end{minted}
Recorded commit: \texttt{67141451b6239190f7a616231bff20b8b0ccbd8a}. The image versions are the ones fixed
by that commit and were not changed:
\begin{tabularx}{\linewidth}{L{4.4cm}Y}
\toprule
\textbf{Service} & \textbf{Image}\\ \midrule
Zammad (nginx, railsserver, websocket, scheduler, init, backup) & \texttt{ghcr.io/zammad/zammad:7.3.0-0011}\\
Elasticsearch & \texttt{elasticsearch:9.5.7}\\
PostgreSQL & \texttt{postgres:17.12-alpine}\\
Redis & \texttt{redis:8.12-alpine}\\
Memcached & \texttt{memcached:1.6.45-alpine}\\
\bottomrule
\end{tabularx}
\subsection{Configuration}
The real \texttt{.env} stays on the laptop with mode 600. A sanitized copy,
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/support/zammad.env.example}{\texttt{support/zammad.env.example}},
is kept in Gitea:
\begin{minted}[breaklines,breakanywhere]{bash}
COMPOSE_PROJECT_NAME=dos-support
COMPOSE_FILE=docker-compose.yml:scenarios/apply-resource-limits.yml
# Local only: loopback port, plain HTTP
NGINX_EXPOSE_PORT=127.0.0.1:8080
ZAMMAD_FQDN=localhost:8080
ZAMMAD_HTTP_TYPE=http
NGINX_SERVER_SCHEME=http
# Unique generated values (openssl rand -hex 24); never committed
POSTGRES_PASS=<generated>
ELASTICSEARCH_PASS=<generated>
# Low-memory settings for an 8 GB laptop
ELASTICSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
ZAMMAD_ELASTICSEARCH_RESOURCES_LIMITS_MEMORY=1G
ZAMMAD_RAILSSERVER_RESOURCES_LIMITS_MEMORY=1G
ZAMMAD_SCHEDULER_RESOURCES_LIMITS_MEMORY=1G
ZAMMAD_INIT_RESOURCES_LIMITS_MEMORY=1G
# First backup at start-up instead of only at 03:00; local time zone
BACKUP_ON_START=true
TZ=America/New_York
\end{minted}
\textbf{Deviations from the assignment's Droplet configuration.} The
external-network scenario is not loaded, because there is no proxy to join; the
host-proxy alternative's loopback port is used instead. The
\texttt{apply-resource-limits.yml} scenario and a 512~MB Elasticsearch heap are
loaded because the laptop has 8~GB in total. Both scenario files are part of the
official repository, and no image was built or replaced.
\subsection{Validation and Start-up}
Elasticsearch needs \texttt{vm.max\_map\_count=262144}~\cite{ZammadDocker}. On
macOS the setting belongs to Docker Desktop's Linux VM, not to macOS, so it was
applied there:
\begin{minted}[breaklines,breakanywhere]{bash}
docker run --rm --privileged alpine sysctl -w vm.max_map_count=262144
docker compose config --quiet
docker compose config --services
docker compose pull
docker compose up -d
docker compose ps -a
docker compose logs --tail=50 zammad-init zammad-railsserver zammad-nginx
\end{minted}
This setting lasts until Docker Desktop restarts and has to be applied again
after that.
\textbf{Start-up result.} The first start took about 15 minutes: the containers
were created 24 minutes before Figure~\ref{fig:z-ps} was taken and
\texttt{zammad-init} exited 9 minutes before it, with exit code 0. No container
restarted or was stopped for running out of memory, so no setting had to be
changed after the first start.
\zfig{compose-ps.png}{1.0}{\texttt{docker compose ps -a} in project
\texttt{dos-support}: every service up (PostgreSQL, Redis, Memcached, and the Rails
server healthy), \texttt{zammad-init} exited with code 0, and only nginx published,
on \texttt{127.0.0.1:8080}.}{fig:z-ps}
\zfig{docker-stats-after.png}{1.0}{\texttt{docker stats -{}-no-stream} after
start-up: memory used by each Zammad container against its limit.}{fig:z-stats}
\textbf{Before and after.} Before start-up, only the 37~MiB runner was running
and macOS reported 49--50\% of memory free. After start-up, the nine Zammad
containers used about 1.93~GiB together. Elasticsearch used 897~MiB, 88\% of its
1~GiB limit, and is the container closest to its cap; the Rails server (293~MiB)
and scheduler (333~MiB) stayed near a third of theirs. The 1~GiB caps were enough
for the stack to start and stay up.
\section{Network Exposure}
\label{sec:z-exposure}
Only \texttt{zammad-nginx} may be published, and only on loopback.
\begin{minted}[breaklines,breakanywhere]{bash}
docker compose ps --format "table {{.Service}}\t{{.Ports}}"
lsof -nP -iTCP -sTCP:LISTEN | grep -E ':(8080|5432|9200|6379|11211)'
\end{minted}
Only nginx has a host binding, \texttt{127.0.0.1:8080->8080/tcp}. PostgreSQL
(5432), Elasticsearch (9200, 9300), Redis (6379), and Memcached (11211) list their
ports as container ports only, and \texttt{lsof} finds a single listening socket
among the checked ports: \texttt{127.0.0.1:8080}, owned by Docker Desktop.
\zfig{exposure.png}{1.0}{Published ports: only \texttt{127.0.0.1:8080}; no
database, search, cache, or Redis port listens on the laptop.}{fig:z-exposure}
The control that enforces this is the Compose file itself: no internal service
declares a \texttt{ports} entry, and \texttt{NGINX\_EXPOSE\_PORT} binds nginx to
the loopback address. A loopback binding is not reachable from the local network
whatever the macOS firewall setting is. The Droplet's cloud firewall and Caddy
are not involved, and no rule was added to either.
\section{Support Workflow and TA Access}
\label{sec:z-workflow}
\subsection{Accounts and Roles}
Self-registration was turned off, and every account was created directly by the
administrator with an initial password set administratively, since no email
channel is configured~\cite{ZammadRoles}.
\begin{tabularx}{\linewidth}{L{3.2cm}L{2.4cm}Y}
\toprule
\textbf{Account} & \textbf{Role} & \textbf{Group access}\\ \midrule
Admin Admin & Admin & Startup Support, Users\\
Test Agent (student agent) & Agent & Startup Support\\
TA User & Agent (not Admin) & Startup Support\\
Customer User (synthetic) & Customer & none: own tickets only\\
Secondary Customer (synthetic) & Customer & none: own tickets only\\
\bottomrule
\end{tabularx}
\medskip
All names and email addresses are synthetic. No password appears in this manual
or in Gitea; the TA login is given in the Canvas submission.
\subsection{Example Tickets}
\begin{tabularx}{\linewidth}{L{1.3cm}L{3.0cm}L{1.2cm}L{1.5cm}L{2.4cm}Y}
\toprule
\textbf{Ticket} & \textbf{Title} & \textbf{State} & \textbf{Priority} & \textbf{Owner} & \textbf{Customer}\\ \midrule
\#63002 & OpenUnassigned & open & normal & none & Secondary Customer\\
\#63003 & OpenAssigned (investigating) & open & high & Test Agent & Secondary Customer\\
\#63005 & ResolvedTicket & closed & low & Admin Admin & Customer User\\
\#63004 & ClosedTicket & closed & normal & Admin Admin & Secondary Customer\\
\#63006 & TestingWorkflow (TA test) & closed & normal & TA User & Customer User\\
\bottomrule
\end{tabularx}
\zfig{tickets-overview.png}{1.0}{Ticket overview: the four example tickets and
the TA's test ticket \#63006, with their states, priorities, and
owners.}{fig:z-tickets}
\subsection{Internal Note, Customer Reply, and Visibility}
In ticket \#63002, the agent added an internal note (``This will be an internal
note, the customer cannot view'') and then a public reply through the web
interface. Logged in as Secondary Customer in a separate private window, the
customer saw the public reply but not the internal note, and the customer's
ticket list showed only that customer's own tickets, \#63002, \#63003, and
\#63004; \#63005 and \#63006 belong to Customer User and were not listed.
Self-registration is off (Figure~\ref{fig:z-selfreg}), so a customer account
exists only if the administrator creates it.
\zfig{self-registration.png}{1.0}{Demo video, 0:56 --- Security settings: new
user accounts (self-registration) set to \emph{no}.}{fig:z-selfreg}
\zfig{agent-view.png}{1.0}{Demo video, 2:32 --- agent view of ticket \#63002:
the internal note is marked internal, and a public reply is being
added.}{fig:z-agent-view}
\zfig{customer-tickets.png}{1.0}{Demo video, 2:45 --- Secondary Customer's
\emph{My Tickets}: only \#63002, \#63003, and \#63004.}{fig:z-customer-tickets}
\zfig{customer-view.png}{1.0}{Demo video, 4:48 --- ticket \#63002 in the
customer's session: the public reply is shown and the internal note is
not.}{fig:z-customer-view}
\subsection{TA Account Test}
In a separate private window, the TA account created test ticket \#63006
``TestingWorkflow'' for Customer User, replied to it (``This is my reply''), set
an owner, and closed it, all without administrator rights; the Admin settings
were not available to it.
\zfig{ta-test.png}{1.0}{Demo video, 3:48 --- TA session: replying to test
ticket \#63006 and choosing its owner; no Admin menu.}{fig:z-ta}
\subsection{TA Checklist}
\begin{enumerate}
\item \textbf{Evidence:} the video in the Canvas submission. The installation
is on a team laptop and is not reachable remotely.
\item \textbf{URL (local):} \texttt{http://localhost:8080}.
\item \textbf{Account:} TA User, role Agent, group Startup Support
with full access. The password is in the Canvas submission text, not here.
\item \textbf{Example tickets:} open \#63002, investigating \#63003, closed
\#63004 and \#63005; Gitea-linked ticket \#63003; TA test ticket \#63006.
\item \textbf{Test steps:} New Ticket $\rightarrow$ customer, group Startup
Support, title, text $\rightarrow$ Create; reply in the article box with
visibility Public $\rightarrow$ Update; set Owner $\rightarrow$ Update; set
State to closed $\rightarrow$ Update.
\end{enumerate}
\section{Link to Engineering in Gitea}
\label{sec:z-gitea}
Ticket\#63003 reports a problem that needs a software change, so it was linked
to Gitea issue
\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/30}{\#30}:
\begin{itemize}
\item \textbf{Report:} the synthetic customer Secondary Customer wrote on the
ticket: ``when I typed `abc' as the quantity, the page showed a confusing
technical error.'' \texttt{GET /price?quantity=abc} returns HTTP 400 with
Python's internal text \texttt{invalid literal for int() with base 10: 'abc'}.
\item \textbf{Issue \#30:} ``Ticket\#63003: Non-numeric quantity returns a
technical error message.'' Its description quotes the ticket. Acceptance
criterion: \texttt{GET /price?quantity=abc} returns HTTP 400 with the message
\texttt{quantity must be a whole number between 1 and 1000}, and a unit test
covers it.
\item \textbf{Ticket:} an internal note on Ticket\#63003 holds the clickable
issue URL, so agents can follow the engineering work.
\item \textbf{Fix:} in \texttt{pricing/app.py}, every rejected quantity now
returns one fixed message, \texttt{QUANTITY\_ERROR}, instead of
\texttt{str(error)}, so Python's internal text never reaches the customer.
A new unit test, \texttt{test\_non\_numeric\_quantity\_message}, requests
\texttt{/price?quantity=abc} and checks for HTTP 400 and the exact message;
the existing \texttt{test\_invalid\_quantity} still covers 0, $-1$, 1001,
\texttt{abc}, and 1.5.
\begin{minted}[breaklines]{python}
QUANTITY_ERROR = "quantity must be a whole number between 1 and 1000"
...
except ValueError:
return jsonify(error=QUANTITY_ERROR), 400
\end{minted}
\item \textbf{Release:} commit \texttt{291c38b} (``Pricing: clear message
for non-numeric quantity (fixes \#30)'') ran through Jenkins run
\FillIn{\#7 v1.0.7}: all four unit tests passed, the security gate passed,
and the release was approved and deployed.
\item \textbf{Verification and closure:} after the deploy,
\texttt{GET /price?quantity=abc} returned HTTP 400 with
\texttt{quantity must be a whole number between 1 and 1000}. Issue \#30 was
closed by the commit, and Ticket\#63003 got a public reply telling the
customer the fix was live and was then set to closed.
\end{itemize}
\zfig{ticket-issue-link.png}{1.0}{Ticket\#63003
with the customer's report and the internal note linking Gitea issue
\#30.}{fig:z-ticket-link}
\zfig{issue-ticket-link.png}{1.0}{December 2, 2026 --- Gitea issue \#30
referencing Ticket\#63003, with its acceptance criterion.}{fig:z-issue-link}
The link is manual, as the assignment requires. No webhook, API automation, or
alert-to-ticket integration was configured.
\section{Restart, Persistence, and Backup}
\label{sec:z-recovery}
\subsection{Controlled Web-Service Outage}
Ticket \#63002, with its internal note and public reply, was the reference
ticket. Because the Droplet's
Prometheus cannot reach a local installation, the destination was checked once
per second from the laptop instead of by the Blackbox probe:
\begin{minted}[breaklines,breakanywhere]{bash}
while true; do echo "$(date +%T) $(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/)"; sleep 1; done | tee ~/zammad-outage.log
docker compose stop zammad-nginx # announced test window
docker compose start zammad-nginx
docker compose ps -a
\end{minted}
\begin{tabularx}{\linewidth}{L{3.4cm}Y}
\toprule
\textbf{Time (min:s)} & \textbf{Observation}\\ \midrule
before \texttt{:21:35} & \texttt{docker compose stop zammad-nginx}; checks return 200 until then\\
\texttt{:21:35} & First failed request (curl status \texttt{000}, connection refused)\\
\texttt{:22:05} & Last failed request; \texttt{docker compose start zammad-nginx} run\\
\texttt{:22:06} & First successful request (HTTP 200) again\\
\bottomrule
\end{tabularx}
\medskip
The hour is cut off in the recording, so only minutes and seconds are shown.
There were 31 failed checks, an outage of about 31 seconds, and
\texttt{docker compose ps} showed every service healthy again, with nginx ``Up
less than a second'' (Figure~\ref{fig:z-restart}). After logging back in,
ticket \#63002 and its whole conversation were still there
(Figure~\ref{fig:z-customer-view}, taken after the restart). This is a web-service restart test, not a database
restore test: only nginx was stopped, and no volume was touched.
\zfig{restart.png}{1.0}{Demo video, 3:56 --- \texttt{docker compose stop} and
\texttt{start zammad-nginx}, then every service healthy.}{fig:z-restart}
\zfig{outage-log.png}{0.9}{Demo video, 4:26 --- per-second log: failed checks
(\texttt{000}) while nginx was stopped, then HTTP 200 again.}{fig:z-outage}
\subsection{Storage and Backup}
\begin{tabularx}{\linewidth}{L{6.0cm}Y}
\toprule
\textbf{Named volume (project \texttt{dos-support})} & \textbf{Contents}\\ \midrule
\texttt{dos-support\_postgresql-data} & Tickets, users, settings (database)\\
\texttt{dos-support\_elasticsearch-data} & Search index (can be rebuilt from the database)\\
\texttt{dos-support\_redis-data} & Sessions and job queue\\
\texttt{dos-support\_zammad-storage} & Attachments and application storage\\
\texttt{dos-support\_zammad-backup} & Backup archives written by \texttt{zammad-backup}\\
\bottomrule
\end{tabularx}
\medskip
Memcached is a disposable cache and has no volume. Volumes survive container
replacement, but they are on the same laptop, so they are not an off-machine
backup.
\begin{minted}[breaklines,breakanywhere]{bash}
docker volume ls | grep dos-support
docker compose logs --tail=20 zammad-backup
docker compose exec zammad-backup ls -lh /var/tmp/zammad
\end{minted}
All five named volumes exist, including \texttt{dos-support\_zammad-backup}
(Figure~\ref{fig:z-backup}). The \texttt{zammad-backup} service is running its
schedule: its log shows it waited for PostgreSQL and the init container, started
its backup loop, and is sleeping until the next scheduled run
(Figure~\ref{fig:z-backup-logs}). The backup directory was still empty
(\texttt{total 0}) when it was checked, because the first scheduled run had not
happened yet. So this lab shows that backups are configured and scheduled, not
that an archive has been written; the check is to run the \texttt{ls} command
again after the next scheduled time.
\zfig{backup.png}{1.0}{Demo video, 4:26 --- the five named volumes of project
\texttt{dos-support}.}{fig:z-backup}
\zfig{backup-logs.png}{1.0}{\texttt{zammad-backup} log (waiting, then sleeping
until the next run) and the still-empty backup directory.}{fig:z-backup-logs}
\textbf{Restore.} An operator would follow the backup and restore guide for the
same Zammad release~\cite{ZammadDocker}: stop the stack without removing volumes,
place the chosen backup in the \texttt{zammad-backup} volume as that guide
describes, start the stack so the backup is restored, and then check that a known
ticket and its attachments are present. No restore was performed in this lab.
\section{Earlier Services Retested}
\label{sec:z-retest}
The Droplet was not changed by this assignment. On November 29 and December 2, 2026, each
earlier service was checked again:
\begin{tabularx}{\linewidth}{L{4.0cm}Y}
\toprule
\textbf{Service} & \textbf{Result}\\ \midrule
Gitea (\url{https://git.ssw590-08.me}) & Dashboard loads; repository and recent activity shown (Figure~\ref{fig:z-gitea})\\
Jenkins (\url{https://ci.ssw590-08.me}) & \texttt{Scrap-Web} job listed; last success 14 seconds earlier, no failure; built-in node and delivery agent connected; Jenkins 2.580.1 (Figure~\ref{fig:z-jenkins})\\
Grafana (\url{https://metrics.ssw590-08.me}) & Reliability dashboard current on December 2 (last 6 hours): Gitea and Jenkins UP throughout, all six scrape targets UP including the production probe, CPU about 20\% apart from one build spike (Figure~\ref{fig:z-grafana})\\
Chapter~\ref{Chapter:SecureDelivery} application (\url{https://app.ssw590-08.me}) & Version \texttt{v2}, commit \texttt{d678772}; \texttt{/price?quantity=3} returns 36 (Figure~\ref{fig:z-app})\\
\bottomrule
\end{tabularx}
\zfig{recheck-gitea.png}{0.85}{November 29, 2026 --- Gitea dashboard.}{fig:z-gitea}
\zfig{recheck-jenkins.png}{0.85}{November 29, 2026 --- Jenkins: \texttt{Scrap-Web} last success, no failure.}{fig:z-jenkins}
\zfig{recheck-grafana-dashboard.png}{0.85}{December 2, 2026, 10:30 AM--4:30 PM
EST --- Grafana reliability dashboard: host panels, HTTPS probe durations, Gitea
and Jenkins UP, and every scrape target UP.}{fig:z-grafana}
\zfig{recheck-app.png}{0.85}{November 29, 2026 --- production pricing application:
v2 and a total of 36.}{fig:z-app}
\section{Operations Runbook}
\label{sec:z-runbook}
All commands run from \texttt{\textasciitilde/dos-support/zammad-docker-compose},
so the same \texttt{.env} and scenario files are loaded.
\begin{enumerate}
\item \textbf{Start:} open Docker Desktop; run
\texttt{docker run -{}-rm -{}-privileged alpine sysctl -w vm.max\_map\_count=262144};
then \texttt{docker compose up -d}; wait until \texttt{docker compose ps -a}
shows all services healthy and \texttt{zammad-init} exited with code 0.
\item \textbf{Check:} open \texttt{http://localhost:8080} and log in as an agent.
\item \textbf{Restart the web service:} \texttt{docker compose restart
zammad-nginx}.
\item \textbf{Investigate:} \texttt{docker compose logs -{}-tail=50
zammad-railsserver zammad-nginx}; \texttt{docker stats -{}-no-stream} for
memory pressure.
\item \textbf{Stop without losing data:} \texttt{docker compose stop}
(or \texttt{docker compose down} without \texttt{-v}).
\item \textbf{Never} run \texttt{docker compose down -v} or remove the
\texttt{dos-support\_*} volumes.
\item \textbf{After grading:} disable the TA account in Admin $\rightarrow$
Users, then stop the stack. The laptop has no recurring cost.
\end{enumerate}
\section{Limitations}
\label{sec:z-limits}
\begin{itemize}
\item Zammad runs on a laptop, not the Droplet: there is no public hostname,
TLS certificate, Caddy route, cloud-firewall check, or Prometheus/Grafana
panel for it. These were waived for local installs; no Droplet test is
claimed.
\item The laptop has 8~GB of RAM, below Zammad's recommendation, so the stack
runs with official memory-limit settings and a 512~MB Elasticsearch heap.
It is suitable for this lab, not for production load.
\item The service is only available while the laptop and Docker Desktop are
running, and the backups are on the same laptop.
\item No email channel is configured, so passwords were set administratively
and notifications are not sent.
\end{itemize}
\fussy
+1
View File
@@ -23,6 +23,7 @@ scrape_configs:
- targets:
- https://git.ssw590-08.me/user/login
- https://ci.ssw590-08.me/login
- https://app.ssw590-08.me/health
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
+1 -1
View File
@@ -6,7 +6,7 @@ WORKDIR /app
COPY requirements.txt .
# Exact, hash-checked dependency versions (direct + transitive) from requirements.txt
RUN pip install --no-cache-dir --require-hashes -r requirements.txt
RUN apt-get update && apt-get install -y --only-upgrade zlib1g && rm -rf /var/lib/apt/lists/* \
RUN apt-get update && apt-get install -y --only-upgrade zlib1g libzstd1 && rm -rf /var/lib/apt/lists/* \
&& pip uninstall -y pip setuptools
COPY app.py .
USER 10001:10001
+8 -5
View File
@@ -2,14 +2,17 @@ import os
from flask import Flask, jsonify, request
app = Flask(__name__)
VERSION = "v1"
UNIT_PRICE = 10
VERSION = "v2"
UNIT_PRICE = 12
COMMIT = os.environ.get("APP_COMMIT", "development")
QUANTITY_ERROR = "quantity must be a whole number between 1 and 1000"
def total_price(quantity):
if quantity < 1 or quantity > 1000:
raise ValueError("quantity must be between 1 and 1000")
raise ValueError(QUANTITY_ERROR)
return UNIT_PRICE * quantity
@@ -28,6 +31,6 @@ def price():
try:
quantity = int(request.args.get("quantity", "1"))
total = total_price(quantity)
except ValueError as error:
return jsonify(error=str(error)), 400
except ValueError:
return jsonify(error=QUANTITY_ERROR), 400
return jsonify(quantity=quantity, total=total, currency="USD")
+10 -3
View File
@@ -7,17 +7,24 @@ class PricingTests(unittest.TestCase):
self.client = app.test_client()
def test_price(self):
self.assertEqual(total_price(3), 30)
self.assertEqual(total_price(3), 36)
response = self.client.get("/price?quantity=3")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json["total"], 30)
self.assertEqual(response.json["total"], 36)
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_non_numeric_quantity_message(self):
# Ticket#63003 / issue #30: no Python internals in the error
response = self.client.get("/price?quantity=abc")
self.assertEqual(response.status_code, 400)
self.assertEqual(response.json["error"],
"quantity must be a whole number between 1 and 1000")
def test_release_identity(self):
self.assertEqual(self.client.get("/").json["version"], "v1")
self.assertEqual(self.client.get("/").json["version"], "v2")
self.assertEqual(self.client.get("/health").json["status"], "ok")
+9
View File
@@ -0,0 +1,9 @@
target_env: production
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:7689c624960c3d47cc7eb0bd456b4023923a55a64e6941f621c82315b374adf5
expected_version: v1
expected_commit: 69f1fe05cf72848e250d71349a76ee1157d44df3
expected_total: 30
public_url: https://app.ssw590-08.me
proxy_network: gitea-net
approved_by: samahk
approved_at: 2026-11-14T03:04:14+00:00
+7
View File
@@ -0,0 +1,7 @@
target_env: staging
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:7689c624960c3d47cc7eb0bd456b4023923a55a64e6941f621c82315b374adf5
expected_version: v1
expected_commit: 69f1fe05cf72848e250d71349a76ee1157d44df3
expected_total: 30
public_url: https://staging.ssw590-08.me
proxy_network: gitea-net
+9
View File
@@ -0,0 +1,9 @@
target_env: production
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:d7aa3cfce583a68e287dc34707f11c1d664161e65c74cd709df15330b2fd8f19
expected_version: v2
expected_commit: d6787727f8ebce3f8ac0f8f6d36ddef352ba63da
expected_total: 36
public_url: https://app.ssw590-08.me
proxy_network: gitea-net
approved_by: samahk
approved_at: 2026-11-14T03:17:50+00:00
+7
View File
@@ -0,0 +1,7 @@
target_env: staging
release_image: git.ssw590-08.me/ssw-590-08/pricing@sha256:d7aa3cfce583a68e287dc34707f11c1d664161e65c74cd709df15330b2fd8f19
expected_version: v2
expected_commit: d6787727f8ebce3f8ac0f8f6d36ddef352ba63da
expected_total: 36
public_url: https://staging.ssw590-08.me
proxy_network: gitea-net