diff --git a/manual/HW5 images/actions.png b/manual/HW5 images/actions.png new file mode 100644 index 0000000..a81b710 Binary files /dev/null and b/manual/HW5 images/actions.png differ diff --git a/manual/HW5 images/adminpage.png b/manual/HW5 images/adminpage.png new file mode 100644 index 0000000..6630017 Binary files /dev/null and b/manual/HW5 images/adminpage.png differ diff --git a/manual/HW5 images/buildhistory.png b/manual/HW5 images/buildhistory.png new file mode 100644 index 0000000..eea8fb5 Binary files /dev/null and b/manual/HW5 images/buildhistory.png differ diff --git a/manual/HW5 images/errormessage.png b/manual/HW5 images/errormessage.png new file mode 100644 index 0000000..7b57a51 Binary files /dev/null and b/manual/HW5 images/errormessage.png differ diff --git a/manual/HW5 images/gitea-buildhash.png b/manual/HW5 images/gitea-buildhash.png new file mode 100644 index 0000000..0a19a2e Binary files /dev/null and b/manual/HW5 images/gitea-buildhash.png differ diff --git a/manual/HW5 images/gitea-running-artifact.png b/manual/HW5 images/gitea-running-artifact.png new file mode 100644 index 0000000..159c0f6 Binary files /dev/null and b/manual/HW5 images/gitea-running-artifact.png differ diff --git a/manual/HW5 images/ownerpage.png b/manual/HW5 images/ownerpage.png new file mode 100644 index 0000000..82b639c Binary files /dev/null and b/manual/HW5 images/ownerpage.png differ diff --git a/manual/HW5 images/pdf-buildhas.png b/manual/HW5 images/pdf-buildhas.png new file mode 100644 index 0000000..3eec124 Binary files /dev/null and b/manual/HW5 images/pdf-buildhas.png differ diff --git a/manual/HW5 images/pdfidentifiers.png b/manual/HW5 images/pdfidentifiers.png new file mode 100644 index 0000000..343e8d2 Binary files /dev/null and b/manual/HW5 images/pdfidentifiers.png differ diff --git a/manual/HW5 images/run-build-log.png b/manual/HW5 images/run-build-log.png new file mode 100644 index 0000000..ee05274 Binary files /dev/null and b/manual/HW5 images/run-build-log.png differ diff --git a/manual/HW5 images/runner-verification.png b/manual/HW5 images/runner-verification.png new file mode 100644 index 0000000..ad4e16b Binary files /dev/null and b/manual/HW5 images/runner-verification.png differ diff --git a/manual/HW5 images/tokenlocations.png b/manual/HW5 images/tokenlocations.png new file mode 100644 index 0000000..c68186c Binary files /dev/null and b/manual/HW5 images/tokenlocations.png differ diff --git a/manual/HW5 images/twosuccessruns.png b/manual/HW5 images/twosuccessruns.png new file mode 100644 index 0000000..d1407e6 Binary files /dev/null and b/manual/HW5 images/twosuccessruns.png differ diff --git a/manual/HW6 images/branch.png b/manual/HW6 images/branch.png new file mode 100644 index 0000000..4887264 Binary files /dev/null and b/manual/HW6 images/branch.png differ diff --git a/manual/HW6 images/credentials.png b/manual/HW6 images/credentials.png new file mode 100644 index 0000000..791f1be Binary files /dev/null and b/manual/HW6 images/credentials.png differ diff --git a/manual/HW6 images/droplet-resize.png b/manual/HW6 images/droplet-resize.png new file mode 100644 index 0000000..ee0bf3c Binary files /dev/null and b/manual/HW6 images/droplet-resize.png differ diff --git a/manual/HW6 images/fail.png b/manual/HW6 images/fail.png new file mode 100644 index 0000000..0e3520b Binary files /dev/null and b/manual/HW6 images/fail.png differ diff --git a/manual/HW6 images/jenkins-job-list.png b/manual/HW6 images/jenkins-job-list.png new file mode 100644 index 0000000..91c822b Binary files /dev/null and b/manual/HW6 images/jenkins-job-list.png differ diff --git a/manual/HW6 images/jenkins-site.png b/manual/HW6 images/jenkins-site.png new file mode 100644 index 0000000..355b0b9 Binary files /dev/null and b/manual/HW6 images/jenkins-site.png differ diff --git a/manual/HW6 images/merged.png b/manual/HW6 images/merged.png new file mode 100644 index 0000000..fbf148b Binary files /dev/null and b/manual/HW6 images/merged.png differ diff --git a/manual/HW6 images/pass.png b/manual/HW6 images/pass.png new file mode 100644 index 0000000..a93b88d Binary files /dev/null and b/manual/HW6 images/pass.png differ diff --git a/manual/HW6 images/persisting-jenkins.png b/manual/HW6 images/persisting-jenkins.png new file mode 100644 index 0000000..e6305e9 Binary files /dev/null and b/manual/HW6 images/persisting-jenkins.png differ diff --git a/manual/HW6 images/runs.png b/manual/HW6 images/runs.png new file mode 100644 index 0000000..0b85c20 Binary files /dev/null and b/manual/HW6 images/runs.png differ diff --git a/manual/HW6 images/webhook-delivery.png b/manual/HW6 images/webhook-delivery.png new file mode 100644 index 0000000..35848b8 Binary files /dev/null and b/manual/HW6 images/webhook-delivery.png differ diff --git a/manual/HW6 images/webhook-list.png b/manual/HW6 images/webhook-list.png new file mode 100644 index 0000000..20e8b34 Binary files /dev/null and b/manual/HW6 images/webhook-list.png differ diff --git a/manual/HW7 images/contact-point-test.png b/manual/HW7 images/contact-point-test.png new file mode 100644 index 0000000..ee15bfa Binary files /dev/null and b/manual/HW7 images/contact-point-test.png differ diff --git a/manual/HW7 images/contact-points.png b/manual/HW7 images/contact-points.png new file mode 100644 index 0000000..abca294 Binary files /dev/null and b/manual/HW7 images/contact-points.png differ diff --git a/manual/HW7 images/dashboard-build7.png b/manual/HW7 images/dashboard-build7.png new file mode 100644 index 0000000..0027c0e Binary files /dev/null and b/manual/HW7 images/dashboard-build7.png differ diff --git a/manual/HW7 images/dashboard-full.png b/manual/HW7 images/dashboard-full.png new file mode 100644 index 0000000..17a6ef7 Binary files /dev/null and b/manual/HW7 images/dashboard-full.png differ diff --git a/manual/HW7 images/disk-usage-panel.png b/manual/HW7 images/disk-usage-panel.png new file mode 100644 index 0000000..451a725 Binary files /dev/null and b/manual/HW7 images/disk-usage-panel.png differ diff --git a/manual/HW7 images/exposure-after.png b/manual/HW7 images/exposure-after.png new file mode 100644 index 0000000..b5b0501 Binary files /dev/null and b/manual/HW7 images/exposure-after.png differ diff --git a/manual/HW7 images/exposure-before.png b/manual/HW7 images/exposure-before.png new file mode 100644 index 0000000..a547add Binary files /dev/null and b/manual/HW7 images/exposure-before.png differ diff --git a/manual/HW7 images/exposure-recheck.png b/manual/HW7 images/exposure-recheck.png new file mode 100644 index 0000000..d38349a Binary files /dev/null and b/manual/HW7 images/exposure-recheck.png differ diff --git a/manual/HW7 images/hostdisklow-eval.png b/manual/HW7 images/hostdisklow-eval.png new file mode 100644 index 0000000..29e2abc Binary files /dev/null and b/manual/HW7 images/hostdisklow-eval.png differ diff --git a/manual/HW7 images/hostdisklow-firing.png b/manual/HW7 images/hostdisklow-firing.png new file mode 100644 index 0000000..f21139c Binary files /dev/null and b/manual/HW7 images/hostdisklow-firing.png differ diff --git a/manual/HW7 images/hostdisklow-history-repeat.png b/manual/HW7 images/hostdisklow-history-repeat.png new file mode 100644 index 0000000..0e71806 Binary files /dev/null and b/manual/HW7 images/hostdisklow-history-repeat.png differ diff --git a/manual/HW7 images/hostdisklow-history.png b/manual/HW7 images/hostdisklow-history.png new file mode 100644 index 0000000..fd119d4 Binary files /dev/null and b/manual/HW7 images/hostdisklow-history.png differ diff --git a/manual/HW7 images/hostdisklow-normal.png b/manual/HW7 images/hostdisklow-normal.png new file mode 100644 index 0000000..f298343 Binary files /dev/null and b/manual/HW7 images/hostdisklow-normal.png differ diff --git a/manual/HW7 images/hostdisklow-resolved.png b/manual/HW7 images/hostdisklow-resolved.png new file mode 100644 index 0000000..0b5706f Binary files /dev/null and b/manual/HW7 images/hostdisklow-resolved.png differ diff --git a/manual/HW7 images/hostdisklow-rule.png b/manual/HW7 images/hostdisklow-rule.png new file mode 100644 index 0000000..61b658f Binary files /dev/null and b/manual/HW7 images/hostdisklow-rule.png differ diff --git a/manual/HW7 images/hostdisklow-settings.png b/manual/HW7 images/hostdisklow-settings.png new file mode 100644 index 0000000..9cd57ab Binary files /dev/null and b/manual/HW7 images/hostdisklow-settings.png differ diff --git a/manual/HW7 images/hostdisklow-threshold-85.png b/manual/HW7 images/hostdisklow-threshold-85.png new file mode 100644 index 0000000..87703c4 Binary files /dev/null and b/manual/HW7 images/hostdisklow-threshold-85.png differ diff --git a/manual/HW7 images/incident-discord.png b/manual/HW7 images/incident-discord.png new file mode 100644 index 0000000..caea9bf Binary files /dev/null and b/manual/HW7 images/incident-discord.png differ diff --git a/manual/HW7 images/incident-probes.png b/manual/HW7 images/incident-probes.png new file mode 100644 index 0000000..14486a7 Binary files /dev/null and b/manual/HW7 images/incident-probes.png differ diff --git a/manual/HW7 images/incident-state-history.png b/manual/HW7 images/incident-state-history.png new file mode 100644 index 0000000..b133471 Binary files /dev/null and b/manual/HW7 images/incident-state-history.png differ diff --git a/manual/HW7 images/manual-build-recovery.png b/manual/HW7 images/manual-build-recovery.png new file mode 100644 index 0000000..158e02b Binary files /dev/null and b/manual/HW7 images/manual-build-recovery.png differ diff --git a/manual/HW7 images/rule-instances.png b/manual/HW7 images/rule-instances.png new file mode 100644 index 0000000..70b23ab Binary files /dev/null and b/manual/HW7 images/rule-instances.png differ diff --git a/manual/HW7 images/rule-misconfigured.png b/manual/HW7 images/rule-misconfigured.png new file mode 100644 index 0000000..2d72e22 Binary files /dev/null and b/manual/HW7 images/rule-misconfigured.png differ diff --git a/manual/HW7 images/rule-query.png b/manual/HW7 images/rule-query.png new file mode 100644 index 0000000..27dce56 Binary files /dev/null and b/manual/HW7 images/rule-query.png differ diff --git a/manual/HW7 images/sli-short-window.png b/manual/HW7 images/sli-short-window.png new file mode 100644 index 0000000..b1233d8 Binary files /dev/null and b/manual/HW7 images/sli-short-window.png differ diff --git a/manual/HW7 images/sre-targets-up.png b/manual/HW7 images/sre-targets-up.png new file mode 100644 index 0000000..84eb483 Binary files /dev/null and b/manual/HW7 images/sre-targets-up.png differ diff --git a/manual/devopsAIAgentGuide.tex b/manual/devopsAIAgentGuide.tex index 14b78b1..608fffe 100644 --- a/manual/devopsAIAgentGuide.tex +++ b/manual/devopsAIAgentGuide.tex @@ -1,4 +1,3 @@ -% This file acts as the entry point for AI \chapter{AI Agent Usage Guide} \ChapterLabel{AIAgentGuide} \index{AI agent} diff --git a/manual/devopsAIPromptLog.tex b/manual/devopsAIPromptLog.tex index 9174571..8b61eca 100644 --- a/manual/devopsAIPromptLog.tex +++ b/manual/devopsAIPromptLog.tex @@ -60,4 +60,58 @@ directly. Unresolved assumptions: chapter labels for the Digital Ocean Docker Deployment and class-based JavaScript refactor chapters not confirmed, as the assistant did not create those two chapters. + \item \textbf{Automated manual build.} Date: October 8--9, 2026. Tool and + model: Claude, model claude-opus-5-5. Task: plan the team work split, create + the reproducible build configuration (\texttt{.latexmkrc}), the Gitea + Actions workflow, the job-image Dockerfile, and draft the Automated Manual + Build chapter. Inputs: assignment instructions; the manual's LaTeX source. + Output used: build configuration, workflow, Dockerfile, chapter text for + sections 1, 3 and 5. Human review and corrections: the build command and + workflow shell steps were tested by compiling the manual in the assistant's + sandbox; the student moved the manual from issue~5 to a dedicated issue~8 + branch. Unresolved assumptions: runner label \texttt{latex} and the TL2025 + job image are pending the runner registration. + + + \item \textbf{Continuous integration with Jenkins.} Date: October 18--24, + 2026. Tool and model: Claude, model claude-opus-5-5. Task: split the work, + guide the Gitea integration account, branch protection and pull-request + demonstration, write the pricing tests and \texttt{Jenkinsfile}, and draft + and edit the Continuous Integration chapter. Inputs: assignment + instructions; sanitized screenshots, console logs, and commit IDs. Output + used: \texttt{Jenkinsfile}, tests, chapter text, and edits merging both + partners' sections. Human review and corrections: the students ran every + step on the real services and supplied the evidence; the assistant's claims + were checked against the screenshots (for example, the token scopes). + Unresolved assumptions: none. + + \item \textbf{SRE monitoring and reliability.} Date: October 25--29, 2026. + Tool and model: Claude, model claude-opus-5-5. Task: split the work, choose + pinned releases, write the monitoring Compose, Prometheus, Blackbox, Grafana + provisioning and dashboard files and the runbook, guide the alert set-up + and incident exercise, and draft sections of the SRE chapter. Inputs: + assignment instructions; baseline and \texttt{docker stats} output; + Prometheus API query output; Grafana and Discord screenshots. Output used: + configuration files, dashboard JSON, runbook, and chapter text. Human review + and corrections: the student deployed and ran everything on the Droplet; + the SMTP failure led to the Discord route; an incorrect alert condition and + summary found during testing were corrected; all timestamps come from the + recorded logs and screenshots. Unresolved assumptions: none. + + \item \textbf{SRE chapter completion.} Date: October 30, 2026. Tool and + model: Claude (configured model claude-sonnet-5-5). Task: complete the + \texttt{HostDiskLow} alert subsection and its repeat test; merge the two + exported alert rules into one file; draft the capacity and retention + rationale, the deployment diagram, the SLI, SLO, and SLA definitions and + worked example, the metric inventory, and the access-control text; add the + Hosts and Passwords rows. Inputs: manual Chapter 5; the existing chapter + text and Compose file; Grafana, Discord, and terminal screenshots; the + exported alert-rule YAML. Output used: chapter text, a Graphviz diagram, and + \texttt{alert-rules.yaml}. Human review and corrections: the students ran + every test and supplied all evidence; a Grafana address in an early export + command was wrong and returned an empty file, which was caught from the + output and corrected. Unresolved assumptions: the probe route from Blackbox + Exporter to the public hostnames is inferred from the Compose networks, not + tested. + \end{itemize} \ No newline at end of file diff --git a/manual/devopsAssignment.tex b/manual/devopsAssignment.tex index d16ef27..8e3abc6 100644 --- a/manual/devopsAssignment.tex +++ b/manual/devopsAssignment.tex @@ -9,6 +9,7 @@ \usepackage{fancyhdr} \usepackage{amsmath,amssymb} \usepackage{array} +\usepackage{seqsplit} \usepackage{booktabs} \usepackage{longtable} \usepackage{tabularx} @@ -40,10 +41,10 @@ \newcommand{\CourseName}{DevOps} \newcommand{\Instructor}{Samah Keshiro and Kayla Holmes} \newcommand{\Organization}{Stevens Institute of Technology} -\newcommand{\DocumentDate}{10/10/26} +\newcommand{\DocumentDate}{October 29, 2026} \newcommand{\DueDate}{[Due Date and Time]} -\newcommand{\VERSION}{Version 1.5} -\newcommand{\AssignmentNumber}{5} +\newcommand{\VERSION}{Version 1.6} +\newcommand{\AssignmentNumber}{6} \newcolumntype{Y}{>{\raggedright\arraybackslash}X} \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} @@ -135,7 +136,9 @@ \include{devopsPasswordsAndHosts} \include{devopsAutomatedManualBuild} \include{devopsCI} -\include +\include{devopsSRE} + +\printglossaries \bibliographystyle{IEEEtran} \bibliography{devopsReferences} @@ -143,4 +146,6 @@ \appendix \include{devopsAIPromptLog} +\printindex + \end{document} \ No newline at end of file diff --git a/manual/devopsAutomatedManualBuild.tex b/manual/devopsAutomatedManualBuild.tex index 9435e14..c6bcd18 100644 --- a/manual/devopsAutomatedManualBuild.tex +++ b/manual/devopsAutomatedManualBuild.tex @@ -22,8 +22,7 @@ \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/.gitea/workflows/manual.yml} \item[Tracking issue:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/8} - \item[Pull request:] \textit{[link to the merged pull request from - \texttt{issue-8} into \texttt{main}]} + \item[Pull request:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/9} \end{description} The manual is stored in the \texttt{manual/} folder of the team's existing @@ -48,8 +47,12 @@ not rebuild the manual. Merging a pull request into \texttt{main} counts as such a push. The workflow can also be started by hand from the Actions tab (\texttt{workflow\_dispatch}). -\textit{[Figure: Actions tab showing a run triggered by the merge commit into -\texttt{main}, dated.]} +\begin{figure} + \centering + \includegraphics[width=1\linewidth]{HW5 images/actions.png} + \caption{10/09/26 Screenshot of Actions tab} + \label{fig:actions} +\end{figure} \textbf{Git remote and network path:} team members push over HTTPS. The remote is configured as: @@ -84,12 +87,47 @@ same HTTPS URL. Because all traffic is initiated by the runner, no submission or management port has to be opened for it. \section{Runner Setup} -\textit{[To be completed with the runner registration (Part 2): version, -location, scope, label \texttt{latex}, execution mode, capacity, network path, -and a screenshot of the runner online with a job assigned.]} + +Gitea Actions was enabled for the Scrap-Web repository to support automated builds of the DevOps IT manual. A Gitea Actions runner was registered to execute workflow jobs. The runner was configured with the label \texttt{latex}, allowing the workflow to select the appropriate execution environment through the \texttt{runs-on: latex} setting in \texttt{.gitea/workflows/manual.yml}. The runner uses \texttt{act\_runner} and executes the build job in a Docker container based on the custom image \texttt{latex-job:local}. This image provides the TeX Live environment and the additional tools required to compile the LaTeX document, including \texttt{latexmk}, \texttt{latexminted}, and Pygments. \subsection{Runner Details} The runner configuration is summarized below. \begin{itemize} \item \textbf{Location:} The runner was hosted on a local macOS computer using Docker Desktop, separate from the DigitalOcean Droplet hosting Gitea. \item \textbf{Version:} Gitea Actions runner \texttt{act\_runner} version 0.6.1. \item \textbf{Execution mode:} Docker-based job execution using the custom image \texttt{latex-job:local}. Each job runs in a temporary container. \item \textbf{Capacity:} One concurrent job, configured with \texttt{capacity: 1} in the runner configuration. \item \textbf{Registration scope:} The runner was registered for the repository's Actions workflow. The registration scope was configured through the Gitea repository's runner settings. \end{itemize} + +\subsection{Connectivity and Security} The runner connects to the Gitea instance at \texttt{https://git.ssw590-08.me}. The runner container uses the configured Gitea instance URL and Docker socket to retrieve workflow jobs and launch their job containers. Docker-based execution isolates the build environment from the Gitea application container. The Docker daemon socket is mounted inside the runner container so that it can create job containers; therefore, access to the socket is restricted to the trusted runner environment. No separate runner-management or Docker daemon port was intentionally exposed to the public internet. The runner communicates with Gitea over HTTPS, while the job environment must have network access to the resources required for the build. + +\subsection{Resource Considerations} The DigitalOcean Droplet hosting Gitea had approximately 458 MiB of total memory, with approximately 114 MiB available during the earlier resource check. Because this was limited memory, the LaTeX runner was placed on the local macOS computer rather than adding another resource-intensive service to the Droplet. This arrangement reduces the additional memory and disk load on the Gitea server while allowing the runner to use the custom Docker image required for the manual build. + +\subsection{Network Path and Runner Verification} + +The Gitea Actions runner operates on the local macOS computer +using Docker Desktop. It connects to the Gitea instance at +\texttt{https://git.ssw590-08.me} over HTTPS. The runner retrieves +workflow jobs from Gitea and launches the assigned job in a +Docker container using the custom image +\texttt{latex-job:local}. + +The workflow targets the runner through the label +\texttt{latex}, configured with \texttt{runs-on: latex}. +The runner has a capacity of one concurrent job, allowing +one workflow job to execute at a time. + +The runner uses the Docker socket to create job containers. +The Docker daemon is not intentionally exposed through a +public network port. Because access to the Docker socket +provides substantial control over the Docker host, access is +restricted to the trusted runner environment. + +Figure~\ref{fig:runner-job-assigned} provides evidence of the +runner's status and its assignment to a workflow job. + +\begin{figure}[htbp] + \centering + \includegraphics[width=\linewidth] + {HW5 images/runner-verification.png} + \caption{Gitea Actions runner online with a workflow job assigned.} + \label{fig:runner-job-assigned} +\end{figure} + \section{Reproducible Compilation} - + \begin{description} \item[Main file:] \texttt{manual/devopsAssignment.tex} \item[Build command:] \texttt{latexmk devopsAssignment.tex}, run in the @@ -98,9 +136,9 @@ and a screenshot of the runner online with a job assigned.]} \item[Expected PDF path:] \texttt{manual/devopsAssignment.pdf} \item[Job image definition:] \texttt{manual/ci/Dockerfile} \item[Base image:] \texttt{texlive/texlive:TL2025-historic} - \item[Resolved image ID/digest:] \textit{[from the runner host]} + \item[Resolved image ID/digest:] \textit{b5c35d6bdbb9} \end{description} - + \textbf{Where TeX runs:} the compiler is not installed in the Gitea container. The workflow targets the runner label \texttt{latex} (\texttt{runs-on: latex}), which maps to a job image built from @@ -112,7 +150,7 @@ the image's own Debian package repositories, which the checkout and upload actions require; no external script is downloaded and executed. The base image uses a fixed TeX Live release tag rather than \texttt{latest}, so every build uses the same toolchain. - + \textbf{Build command and dependencies:} all compiler options are stored in \texttt{manual/.latexmkrc}, so the same command works on a laptop and in the workflow: @@ -126,11 +164,12 @@ sub run_makeglossaries { return system("makeglossaries \"$_[0]\""); } \texttt{latexmk} runs \texttt{pdflatex} as many times as needed and calls \texttt{bibtex}, \texttt{makeindex}, and \texttt{makeglossaries} when their inputs change. \texttt{-shell-escape} is required by \texttt{minted}. - -\textbf{Workflow:} the complete workflow file is shown below. + +\textbf{Workflow:} the complete workflow file, +\texttt{.gitea/workflows/manual.yml}, is shown below. \begin{minted}[breaklines]{yaml} name: Build IT manual - + on: push: branches: [main] @@ -138,7 +177,7 @@ on: - 'manual/**' - '.gitea/workflows/manual.yml' workflow_dispatch: - + jobs: build-manual: runs-on: latex @@ -148,7 +187,31 @@ jobs: steps: - name: Check out the triggering commit uses: actions/checkout@v4 - + + - name: Generate build metadata + working-directory: manual + env: + GIT_COMMIT: ${{ github.sha }} + BUILD_NUMBER: ${{ github.run_number }} + run: | + MANUAL_VERSION="v1.4" + SHORT_SHA="${GIT_COMMIT:0:7}" + BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}" + + cat > build-metadata.tex <> build-metadata.tex <<'EOF' + \noindent\textbf{Manual version:} \ManualVersion\\ + \textbf{Build identifier:} \BuildIdentifier\\ + \textbf{Commit hash:} \BuildCommit\\ + \textbf{Gitea Actions run:} \BuildRunNumber + EOF + - name: Record build identity and toolchain run: | SHORT_SHA="${GITHUB_SHA::7}" @@ -158,11 +221,11 @@ jobs: pdflatex --version | head -n 1 latexmk -v | head -n 2 | tail -n 1 python3 -c "import pygments; print('Pygments', pygments.__version__)" - + - name: Compile the manual working-directory: manual run: latexmk devopsAssignment.tex - + - name: Verify the PDF exists working-directory: manual run: | @@ -171,16 +234,16 @@ jobs: exit 1 fi ls -l devopsAssignment.pdf - + - name: Upload the PDF as an artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: it-manual-build-${{ github.run_number }}-${{ env.SHORT_SHA }} path: manual/devopsAssignment.pdf if-no-files-found: error retention-days: 30 \end{minted} - + \textbf{Failure detection:} the build fails in three independent ways. \begin{enumerate} \item A LaTeX error stops \texttt{pdflatex} immediately @@ -193,22 +256,154 @@ jobs: silently upload nothing. \end{enumerate} A failed step stops the job, so no artifact is produced from a broken build. - + \textbf{Checkout and upload without a shared filesystem:} the job container shares no files with Gitea. The \texttt{actions/checkout} step clones the exact triggering commit from Gitea over HTTPS, the compile happens inside the temporary job container, and \texttt{actions/upload-artifact} sends the PDF back to Gitea over HTTPS, where it is attached to the matching run. The container is discarded when the job ends. - -\textit{[Link to a successful run log, and a dated screenshot of the -compile and verify steps passing.]} - + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/run-build-log.png} + \caption{Successful build log} + \label{fig:run-log} +\end{figure} + \section{PDF Version Traceability} -\textit{[To be completed (Part 4): human-maintained version, generated build -identifier such as \texttt{v1.4+build.N.abcdef0}, visible commit hash and run -number in the PDF, matching Gitea run, and how the metadata is injected -without committing back to the branch.]} + +Every PDF produced by the workflow carries two kinds of version information: +a \emph{human-maintained} manual version, which the team changes deliberately +when the manual's content is revised, and a \emph{generated} build +identifier, which the workflow creates automatically for every run. The +build identifier appends the run number and the triggering commit to the +manual version: +\begin{center} +\texttt{+build..} +\end{center} + +\subsection{Build Identifier for Run \#10} + +The table below traces one build from its source commit to the finished PDF. + +\begin{tabularx}{\linewidth}{L{3.4cm}L{4.4cm}Y} +\toprule +\textbf{Field} & \textbf{Where it comes from} & \textbf{Value for run \#10}\\ \midrule +Manual version & \texttt{MANUAL\_VERSION} in the \emph{Generate build metadata} step of \texttt{manual.yml}, edited by the team & \texttt{v1.4}\\ +Workflow run number & \texttt{GITHUB\_RUN\_NUMBER}, set by Gitea Actions & \texttt{10}\\ +Source commit & \texttt{GITHUB\_SHA}, the triggering commit, shortened to 7 characters & \texttt{67e9e17}\\ +Build identifier & Combined by the workflow & \texttt{v1.4+build.10.67e9e17}\\ +Gitea run & Actions tab & \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions/runs/10}\\ +Artifact & Uploaded by the same run & \texttt{it-manual-build-10-67e9e17}\\ \bottomrule +\end{tabularx} + +The same three values appear in three places: the run's log +(Figure~\ref{fig:gitea-buildhash}), the artifact name, and the generated +PDF itself (Figure~\ref{fig:pdf-buildhash}). In the PDF, the build +identifier, full commit hash, and run number are printed on +\textit{[the title page / in the page footer: state where]}. Because the +commit hash in the PDF matches the commit listed on run \#10, a reader +holding only the PDF can find the exact source revision that produced it. + +\subsection{How the Metadata Is Injected} + +The human-maintained version is set once, in the \emph{Generate build +metadata} step of the workflow, and is kept equal to \texttt{\string\VERSION} +on the title page. The team changes it only when the manual's content is +revised, together with a new Document History entry. The run number and +commit hash are never typed by hand: Gitea Actions supplies them to every +job as \texttt{github.run\_number} and \texttt{github.sha}. + +Before compiling, the workflow combines these values and writes a small +LaTeX file, \texttt{manual/build-metadata.tex}, inside the job container. +The file defines four macros and a short block that prints them: +\begin{minted}[breaklines]{yaml} +- name: Generate build metadata + working-directory: manual + env: + GIT_COMMIT: ${{ github.sha }} + BUILD_NUMBER: ${{ github.run_number }} + run: | + MANUAL_VERSION="v1.4" + SHORT_SHA="${GIT_COMMIT:0:7}" + BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}" + + cat > build-metadata.tex <> build-metadata.tex <<'EOF' + \noindent\textbf{Manual version:} \ManualVersion\\ + \textbf{Build identifier:} \BuildIdentifier\\ + \textbf{Commit hash:} \BuildCommit\\ + \textbf{Gitea Actions run:} \BuildRunNumber + EOF +\end{minted} +For run \#10 the generated file therefore defined +\texttt{\string\BuildIdentifier} as \texttt{v1.4+build.10.67e9e17}. The manual +reads the file during compilation: +\begin{minted}[breaklines]{latex} +run: | + MANUAL_VERSION="v1.4" + SHORT_SHA="${GIT_COMMIT:0:7}" + BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}" + + cat > build-metadata.tex <> build-metadata.tex <<'EOF' + \noindent\textbf{Manual version:} \ManualVersion\\ + \textbf{Build identifier:} \BuildIdentifier\\ + \textbf{Commit hash:} \BuildCommit\\ + \textbf{Gitea Actions run:} \BuildRunNumber + EOF +\end{minted} +The first \texttt{cat} uses an unquoted heredoc so that the shell +substitutes the version, run number and commit into the macro definitions; +the second uses a quoted heredoc (\texttt{<<'EOF'}) so that the LaTeX +commands are written literally. + +\subsection{No Commit or Push Loop} + +The metadata file exists only inside the temporary job container, and +\texttt{build-metadata.tex} is listed in \texttt{manual/.gitignore} so that a +local test build cannot commit it by accident. The workflow contains no \texttt{git commit} or \texttt{git push} step, so the +generated version is never written back to \texttt{main}; the container and +the file are discarded when the job ends. This matters because the workflow +is triggered by pushes to \texttt{main}: a workflow that committed its own +version file would trigger itself again on every build. The human-maintained +version and the Document History table therefore stay entirely under the +team's control, and change only when a team member edits them. + +\subsection{Re-runs} + +Re-running a workflow in Gitea keeps the same run number and checks out the +same commit, so a re-run produces a PDF with the same build identifier. +Because the source is identical, the team treats such a re-run as the same +build, and the run-attempt number is not included in the identifier. + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/gitea-buildhash.png} + \caption{Gitea build report} + \label{fig:gitea-buildhash} +\end{figure} + + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/pdf-buildhas.png} + \caption{PDF compiled build report} + \label{fig:pdf-buildhash} +\end{figure} \section{Downloadable Artifact} @@ -218,10 +413,8 @@ without committing back to the branch.]} commit hash; for example, \texttt{it-manual-build-12-a1b2c3d} \item[Contents:] \texttt{devopsAssignment.pdf} \item[Retention:] 30 days, set in the workflow - (\texttt{retention-days: 30}). \textit{[Confirm the server's maximum - artifact retention; Gitea applies the lower of the two.]} - \item[Example artifact link:] \textit{[link to the artifact on a successful - run]} + (\texttt{retention-days: 30}). + \item[Example artifact link:] \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/actions/runs/10/artifacts/it-manual-build-10-67e9e17} \end{description} Because the run number and commit hash are part of the artifact name, each @@ -242,20 +435,83 @@ Artifacts expire after the retention period and are not a backup. The permanent record is the LaTeX source in Git, from which any version of the manual can be rebuilt. -\textit{[Figure: run page with the artifact listed, and the downloaded PDF -open, dated.]} +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/gitea-running-artifact.png} + \caption{Run page with the artifact listed, and the downloaded PDF open, dated} + \label{fig:fig:gitea-artifact-running} +\end{figure} \section{Change, Failure, and Repair Evidence} -\textit{[To be completed together (Part 6): two successive commits with -their runs and PDF identifiers, one deliberate LaTeX error with its failed -run, and the repaired passing run.]} + +To verify the automated manual-build pipeline, two successive changes were committed to the main branch of the Scrap-Web repository. Each commit triggered a separate Gitea Actions run. Both builds completed successfully, and the generated PDF artifacts were checked to confirm that their build identifiers corresponded to the appropriate commits and run numbers. + +A deliberate LaTeX error was then introduced into the manual source. The workflow detected the compilation error and terminated with a failed status because the build uses the -halt-on-error option. The failed run and its error log were recorded as evidence that the pipeline prevents an invalid manual from being treated as a successful build. + +The invalid command was subsequently removed in a repair commit. A new Actions run compiled the corrected source successfully and produced a new PDF artifact. The repaired artifact's commit hash and run number were compared with the corresponding Gitea Actions run to verify that the output was generated from the repaired revision. + +The generated metadata was produced during the workflow rather than committed back to the source branch. This kept the build identifier associated with the specific build while preserving the distinction between source commits and generated artifacts. + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/run-build-log.png} + \caption{Run log showing 2 successive builds, followed by an error, and another successful build} + \label{fig:buildlogs} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/errormessage.png} + \caption{Failed build error message} + \label{fig:error-message} +\end{figure} \section{Runner and Secret Boundary} -\textit{[To be completed (Part 7): workflow edit rights, where the runner -registration token is stored (without its value), runner isolation, and -Docker socket risk.]} +\subsection{Workflow edit permissions} The automated build workflow is stored in .gitea/workflows/manual.yml. Users who can modify the workflow may change the commands executed by the runner. Repository write permissions and any branch-protection rules were reviewed to identify who can modify the workflow and its associated source files. The repository's actual permissions and branch-protection configuration are recorded in the accompanying evidence. + +\subsection{Runner registration credentials} The Gitea Actions runner is hosted on the local macOS development machine. Its configuration is stored in ~/gitea-runner/runner-data/config.yaml, and its local runner credentials are stored in the runner-data directory, including the .runner file when present. These files are not included in the report or committed to the repository because they may contain sensitive authentication information. The registration token is used to register the runner; it is distinct from the credentials subsequently stored by the registered runner. + +\subsection{Runner isolation} The runner uses the latex label, which matches the workflow's runs-on: latex setting. The runner executes the manual-build job in a Docker container based on the custom latex-job:local image. Its configured capacity is one job at a time. Hosting the runner on the development machine rather than the DigitalOcean Gitea server avoids placing the additional build workload on the server's limited memory and disk resources. Containerization provides isolation for the build environment, but it is not treated as a complete security boundary. + +\subsection{Docker socket risk} The runner container has access to the Docker Desktop socket so that it can create job containers. Access to this socket is security-sensitive because it may allow control over Docker resources and potentially affect the host system. The socket is mounted locally for runner operation rather than deliberately exposed as a public network endpoint. The runner is therefore restricted to trusted coursework workflows, and its credentials and configuration files are kept out of source control. + +Evidence includes the repository permission settings, runner configuration with secrets omitted, and the runner's Docker configuration. No authentication tokens or credential values are reproduced in this report. + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/adminpage.png} + \caption{Listed repo admins} + \label{fig:admin-perms} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/ownerpage.png} + \caption{Listed repo owners} + \label{fig:owner-perms} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/tokenlocations.png} + \caption{Verification of token existence} + \label{fig:tokenlocations} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/twosuccessruns.png} + \caption{Two Successive Runs} + \label{fig:successfulruns} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=1\linewidth]{HW5 images/pdfidentifiers.png} + \caption{Associated PDF identifiers} + \label{fig:pdfidentify} +\end{figure} \section{Manual Quality and Controls} -\textit{[To be completed (Part 8): version and history update, whether the -Hosts and Passwords tables changed, and a short failed-build troubleshooting -procedure.]} +\subsection{Common Troubleshooting Methods} +Throughout this exercise, there came many times where the builds failed (around 8 times). The main method of troubleshooting involved checking version statuses, updating and restarting file instances, and parsing of error messages to pinpoint. diff --git a/manual/devopsCI.tex b/manual/devopsCI.tex index 3ac7ffc..41c70b8 100644 --- a/manual/devopsCI.tex +++ b/manual/devopsCI.tex @@ -9,8 +9,7 @@ Jenkins was deployed on the existing DigitalOcean Droplet used for the Gitea env Jenkins was deployed as a Docker Compose service rather than installed directly on the host operating system. This approach makes the service configuration reproducible and allows the container to be managed independently of the other services running on the Droplet. The Jenkins container is named \texttt{jenkins}. -The Docker Compose configuration defines the Jenkins image, container name, restart policy, Java memory settings, persistent storage, and shared Docker network. The configuration file is located at \texttt{/root/jenkins/docker-compose.yml} on the Droplet. The corresponding source-controlled configuration should be linked here for reproducibility. - +The Docker Compose configuration defines the Jenkins image, container name, restart policy, Java memory settings, persistent storage, and shared Docker network. The configuration file is located at \texttt{/root/jenkins/docker-compose.yml} on the Droplet. The relevant configuration is shown below. It contains no passwords, personal access tokens, or other authentication secrets. \begin{minted}[fontsize=\small,breaklines,linenos]{yaml} @@ -36,7 +35,7 @@ networks: name: gitea-net \end{minted} -\noindent\textbf{Configuration file:} \texttt{/root/jenkins/docker-compose.yml} on the Droplet. Add the URL to the source-controlled Compose file here: \url{[INSERT COMPOSE FILE LINK]}. +\noindent\textbf{Configuration file:} \texttt{/root/jenkins/docker-compose.yml} on the Droplet. The source-controlled copy is at \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/deployment/docker-compose.yml}. The container uses the external Docker network \texttt{gitea-net}, which allows Jenkins to communicate with the existing Gitea and Caddy services. Jenkins listens on container port 8080, but the Compose configuration does not publish port 8080 or the Jenkins agent port 50000 directly on the host. Browser access is provided through Caddy using the HTTPS address \url{https://ci.ssw590-08.me/}. @@ -53,6 +52,13 @@ The Jenkins container is configured with the following Java heap limits: After the Droplet upgrade, the reported host memory usage was approximately 503 MiB used out of 1.9 GiB, with approximately 931 MiB free and 1.4 GiB available. The reported disk usage was approximately 3.3 GB out of 48 GB, leaving approximately 45 GB available. These values describe the host at the time of measurement and may change as builds execute and logs accumulate. +\begin{figure}[H] + \centering + \includegraphics[width=0.8\linewidth]{HW6 images/droplet-resize.png} + \caption{DigitalOcean resize configuration for the Droplet \texttt{devops-gitea-server}: Basic plan, 1 vCPU, 2 GB RAM, 50 GB disk.} + \label{fig:ci-droplet-resize} +\end{figure} + Because the Droplet hosts several services on a relatively small resource allocation, memory and disk usage should be monitored during builds. The Java heap limit helps constrain Jenkins' Java memory allocation, but it does not represent a limit on the container's total memory usage. \subsection{Persistent Storage and Restart Policy} @@ -84,7 +90,14 @@ A container restart test was performed using the following command: docker restart jenkins \end{minted} -The command completed successfully. Following the restart, Jenkins was accessible through its HTTPS address, and the existing Jenkins configuration and job remained available. This demonstrated that Jenkins could restart without requiring the service to be reinstalled or configured from scratch. +The command completed successfully. Following the restart, Jenkins was accessible through its HTTPS address, and the existing Jenkins configuration and job remained available. This demonstrated that Jenkins could restart without requiring the service to be reinstalled or configured from scratch. Figure~\ref{fig:ci-restart} shows the running Jenkins, Caddy, and Gitea containers and the Jenkins log after the restart. + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{HW6 images/persisting-jenkins.png} + \caption{Container inspection and \texttt{docker restart jenkins}: the \texttt{unless-stopped} restart policy, the \texttt{jenkins\_home} volume mount, and the Jenkins log after restart (2026-10-22, 02:03 UTC) showing all jobs loaded and Jenkins fully up and running.} + \label{fig:ci-restart} +\end{figure} The test also supports the use of the named \texttt{jenkins\_home} volume for persistent Jenkins data. A container restart is not, however, a backup or disaster-recovery test. It does not demonstrate that data can be recovered after volume deletion, disk failure, Droplet loss, or corruption. Separate backups of the Jenkins home data and a documented restoration procedure are necessary to establish recoverability. @@ -101,7 +114,14 @@ Jenkins is accessible through the following HTTPS address: The hostname \texttt{ci.ssw590-08.me} resolves to the public IP address of the DigitalOcean Droplet hosting the DevOps services. Jenkins is not intended to be accessed through a publicly exposed container port. Instead, incoming browser requests reach the Caddy reverse proxy, which forwards requests to the Jenkins service over the shared Docker network. -The instructor-approved access path for this deployment is: \textbf{[INSERT THE ACCESS METHOD APPROVED BY THE INSTRUCTOR]}. Access was verified by opening the HTTPS login page in a browser on \textbf{[INSERT VERIFICATION DATE]}. +The instructor-approved access path for this deployment is \textbf{HTTPS}, through the Caddy reverse proxy. HTTPS access, including the Caddy-issued certificate, was verified on October 22, 2026 (Figure~\ref{fig:ci-site}). + +\begin{figure}[H] + \centering + \includegraphics[width=0.8\linewidth]{HW6 images/jenkins-site.png} + \caption{Jenkins 2.580.1 reached in a browser at \texttt{ci.ssw590-08.me} through Caddy.} + \label{fig:ci-site} +\end{figure} \subsection{DNS and TLS Certificate} @@ -122,12 +142,12 @@ The certificate details should be recorded from the certificate actually present \begin{itemize} \item \textbf{Hostname:} \texttt{ci.ssw590-08.me} -\item \textbf{Certificate issuer:} [INSERT VERIFIED CERTIFICATE ISSUER] -\item \textbf{Certificate expiration:} [INSERT VERIFIED EXPIRATION DATE] -\item \textbf{Certificate verification date:} [INSERT DATE] +\item \textbf{Certificate issuer:} Caddy (automatic certificate management) +\item \textbf{Certificate expiration:} January 20, 2027 +\item \textbf{Certificate verification date:} October 22, 2026 \end{itemize} -Caddy supports automatic HTTPS certificate provisioning and renewal. The deployment uses Caddy for TLS termination, with its configuration and persistent data stored separately from the Jenkins container. The certificate issuer, expiration date, and renewal status should be verified from the active certificate and Caddy logs before this section is finalized. +Caddy supports automatic HTTPS certificate provisioning and renewal. The deployment uses Caddy for TLS termination, with its configuration and persistent data stored separately from the Jenkins container. \subsection{HTTP-to-HTTPS Redirect and Jenkins Proxy Configuration} @@ -154,14 +174,14 @@ This URL should also be configured in Jenkins under \textit{Manage Jenkins} $\ri Jenkins requires authentication to access its administrative interface and configure continuous integration jobs. Access to Jenkins administration and configuration should be restricted to authorized project members. -The Gitea integration uses a dedicated \texttt{jenkins} account and a Gitea Personal Access Token stored in Jenkins credentials. The account has the repository permissions needed for Jenkins to interact with \texttt{SSW-590-08/Scrap-Web}. During integration troubleshooting, repository webhook management initially failed with HTTP 403 responses. The account's repository permissions were subsequently adjusted, and the Jenkins webhook was created successfully in Gitea. +The Gitea integration uses a dedicated \texttt{jenkins-ci} account and a Gitea Personal Access Token stored in Jenkins credentials. The account has the repository permissions needed for Jenkins to interact with \texttt{SSW-590-08/Scrap-Web}. During integration troubleshooting, repository webhook management initially failed with HTTP 403 responses. The account's repository permissions were subsequently adjusted, and the Jenkins webhook was created successfully in Gitea. -The following account and role information should be completed based on the actual Jenkins security configuration: +The Jenkins accounts and roles are: \begin{itemize} -\item \textbf{Jenkins administrators:} [INSERT AUTHORIZED ADMINISTRATOR ACCOUNTS OR ROLES] -\item \textbf{Jenkins users:} [INSERT AUTHORIZED USER ACCOUNTS OR ROLES] -\item \textbf{Gitea integration identity:} \texttt{jenkins} +\item \textbf{Jenkins administrators:} \texttt{samahk} and \texttt{kaylah7} +\item \textbf{Jenkins users:} \texttt{samahk} and \texttt{kaylah7} +\item \textbf{Gitea integration identity:} \texttt{jenkins-ci} \item \textbf{Credential storage:} Jenkins Credentials \end{itemize} @@ -184,7 +204,7 @@ Direct public access to Jenkins on TCP 8080 is not required. The Jenkins contain The host's UFW firewall was reported as inactive during deployment verification. Consequently, the DigitalOcean Cloud Firewall and Docker's network and port configuration are important parts of the external access restrictions. -The actual Cloud Firewall rules should be captured in a dated screenshot and compared with the rules listed above. Unneeded inbound rules, including direct public access to TCP 3000 and TCP 5432, should be removed if they are not required by another service. +Any inbound rule that is not required, such as direct public access to TCP 3000 or TCP 5432, should be removed from the Cloud Firewall. \subsection{Docker Port Mappings} @@ -206,7 +226,7 @@ This arrangement avoids exposing Jenkins' application port directly to the publi \subsection{External Connectivity Tests} -External tests were performed from a machine outside the Droplet to verify that selected ports were reachable or blocked from the public network. The test results must be recorded with their execution date and the source machine's network context. +Connectivity tests were run twice: first from a shell on the Droplet, and later from a machine outside it, to check which ports are reachable or blocked from the public network. The date and source of each run are recorded below. The following command tests the public IPv4 address for TCP connectivity: @@ -222,49 +242,41 @@ The expected results are: \item \textbf{TCP 8080:} The connection should fail because Jenkins' internal web port is not published on the host and is not intended to be publicly accessible. \end{itemize} -Previous external tests of TCP ports 3000, 5432, 8080, and 50000 returned connection failures. These observations support the conclusion that those ports were not reachable from the test machine at that time. A separate dated test of TCP 443 and TCP 8080 should be included as direct evidence for this section. - -The test record should include: +Previous external tests of TCP ports 3000, 5432, 8080, and 50000 returned connection failures. \begin{itemize} -\item \textbf{Test date and time:} [INSERT DATE, TIME, AND TIME ZONE] -\item \textbf{Test source:} [INSERT EXTERNAL MACHINE OR NETWORK] +\item \textbf{Test date and time:} October 24, 2026, 4:25 AM EDT +\item \textbf{Test source:} Shell on the Droplet itself (\texttt{root@devops-gitea-server}), connecting to its own public IPv4 address \item \textbf{Droplet IPv4 address:} \texttt{147.182.179.191} -\item \textbf{TCP 443 result:} [INSERT OBSERVED RESULT] -\item \textbf{TCP 8080 result:} [INSERT OBSERVED RESULT] +\item \textbf{TCP 443 result:} Succeeded (\texttt{nc} reported the connection to port 443 succeeded) +\item \textbf{TCP 8080 result:} Failed with ``Connection refused,'' so nothing is listening on host port 8080 \end{itemize} -A failed connection alone does not establish which control blocked it. The firewall configuration and Docker port inspection provide complementary evidence for the intended exposure restrictions. +Because the test ran on the Droplet itself, it shows that Caddy answers on TCP 443 and that nothing listens on host port 8080; it does not exercise the cloud firewall. A failed connection alone does not establish which control blocked it. The firewall configuration and Docker port inspection provide complementary evidence for the intended exposure restrictions. + +\textbf{Test from outside the Droplet (October 30, 2026).} The same two commands were run from a team member's MacBook on a network outside the Droplet, at 2026-10-31T01:58:14Z (9:58~PM EDT). TCP 443 succeeded. \textbf{TCP 8080 also succeeded}, which differs from the expected result. + +The result was investigated rather than accepted. At 2026-10-31T02:14:23Z (10:14~PM EDT) a follow-up from the same machine gave: +\begin{itemize} +\item TCP 8081 and 8888, ports with no service, \textbf{timed out}, so the outside network does not accept every port. +\item \texttt{curl -v http://147.182.179.191:8080} connected, sent \texttt{GET /}, and after 5 seconds closed the connection with \textbf{0 bytes received}. Jenkins would have answered with HTTP headers, so Jenkins did not serve this connection. +\end{itemize} +On the Droplet, \texttt{ss -tlnp} showed no process listening on ports 8080 or 50000, and \texttt{iptables -t nat -S DOCKER} showed no forwarding rule for them. \texttt{docker ps} showed the Jenkins container with the unpublished ports \texttt{8080/tcp, 50000/tcp}; the only host-published ports were Caddy's 80 and 443 and Gitea's SSH on 222. + +\textbf{Conclusion.} Jenkins' web port is not published and no Jenkins content was reachable on port 8080. The TCP handshake that succeeded on 8080 alone was not explained: its source was not identified, and the test was not repeated from a second outside network. This report does not claim that port 8080 is closed to the Internet, only that nothing on the Droplet listens on it and no HTTP response was received. A repeat from a second network, and a cloud-firewall rule that admits only the ports in use, would settle it. + \section{Gitea Trigger and Traceability} \label{sec:ci-trigger} \subsection{Deployment and Network Paths} -Figure~\ref{fig:ci-deployment} adapts the reference deployment to the team's -actual setup. Gitea and Jenkins run as containers on the same DigitalOcean -Droplet behind the Caddy TLS proxy. Two paths are separate: -\begin{itemize} - \item \textbf{Browser path:} a team member's browser reaches - \url{https://ci.ssw590-08.me} on port 443 through the Cloud Firewall and - Caddy, which forwards to Jenkins on the private Docker network. Jenkins' - own port 8080 is not published (Section~\ref{sec:ci-https}). - \item \textbf{Integration path:} Jenkins initiates every connection to - Gitea. It calls the Gitea API at \url{https://git.ssw590-08.me} to - discover branches and pull requests, clones the pull request's head - commit, and posts the commit status back. Gitea never needs to reach - Jenkins for builds to run, because the job polls for changes - (Section~\ref{sec:ci-trigger-config}). -\end{itemize} - -\begin{figure}[H] - \centering - % Uncomment once the diagram image is uploaded: - % \includegraphics[width=\linewidth]{HW6 images/ci-deployment.png} - \fbox{\parbox[c][3cm][c]{0.9\linewidth}{\centering\textit{[Diagram to be added]}}} - \caption{Adapted UML deployment diagram of the Gitea and Jenkins CI paths} - \label{fig:ci-deployment} -\end{figure} +The continuous integration workflow connects the Gitea repository +\texttt{SSW-590-08/Scrap-Web} to Jenkins. The repository is hosted at +\url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web}, and Jenkins is +accessible through \url{https://ci.ssw590-08.me/}. Jenkins uses the +Gitea integration to discover repository changes and report build +statuses associated with commits and pull requests. \subsection{Repository and Integration Identity} @@ -312,6 +324,65 @@ this integration and limited to what Jenkins needs: \label{fig:ci-token} \end{figure} +\subsection{Webhook Configuration and Delivery} + +The Jenkins Gitea integration is configured to communicate with the +Gitea server at \url{https://git.ssw590-08.me/}. The Gitea webhook +connects repository events to the Jenkins service. Jenkins is +reachable externally through Caddy over HTTPS, while the Jenkins +container itself is attached to the shared Docker network +\texttt{gitea-net}. The Caddy reverse proxy forwards requests for +\url{https://ci.ssw590-08.me/} to the Jenkins service on port 8080 +inside the Docker network. + +The webhook was created in Gitea (\emph{Scrap-Web $\rightarrow$ Settings +$\rightarrow$ Webhooks}) and points at the endpoint exposed by the Jenkins +Gitea plugin. Its details, as shown in +Figures~\ref{fig:ci-webhook-list} and~\ref{fig:ci-webhook-delivery}, are: + +\begin{description} + \item[Name:] \texttt{Jenkins Webhook} + \item[Target URL:] \url{https://ci.ssw590-08.me/gitea-webhook/post}, reached + over HTTPS through Caddy + \item[Status:] Listed with a green (healthy) indicator in the repository's + webhook list + \item[Verification:] A \emph{Test Push Event} was sent from Gitea on + October 23, 2026. \emph{Recent Deliveries} lists delivery + \texttt{6b542d91-02b7-45be-a6c2-ba9989df7f4f} with a green check mark, + meaning Gitea delivered the event to the Jenkins endpoint successfully. + \item[Trigger events and secret:] Push and pull-request events from the + repository. No webhook secret is set; a secret would let Jenkins verify + that a delivery really came from Gitea, and adding one is a recommended + hardening step (Section~\ref{sec:ci-credentials}). +\end{description} + +Figure~\ref{fig:ci-job-list} shows the Jenkins job list shortly after the +test delivery: the \texttt{Scrap-Web} Multibranch Pipeline reports a last +success 25 seconds earlier and no failures. The Multibranch Pipeline also +scans the repository every minute as a fallback (Section~\ref{sec:ci-trigger-config}), so a missed webhook delivery +delays a build rather than losing it. + +\begin{figure}[H] + \centering + \includegraphics[width=0.9\linewidth]{HW6 images/webhook-list.png} + \caption[10/23/26 --- Gitea webhook \texttt{Jenkins Webhook} for Scrap-Web]{\textit{10/23/26} --- Gitea webhook \texttt{Jenkins Webhook} for Scrap-Web, targeting \url{https://ci.ssw590-08.me/gitea-webhook/post}.} + \label{fig:ci-webhook-list} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=0.9\linewidth]{HW6 images/webhook-delivery.png} + \caption{\textit{10/23/26} --- Gitea \emph{Recent Deliveries} for the Jenkins webhook, showing a successful \emph{Test Push Event} delivery.} + \label{fig:ci-webhook-delivery} +\end{figure} + +\begin{figure}[H] + \centering + \includegraphics[width=0.9\linewidth]{HW6 images/jenkins-job-list.png} + \caption{\textit{10/23/26} --- Jenkins job list showing the \texttt{Scrap-Web} Multibranch Pipeline, last success 25 seconds earlier, captured shortly after the test delivery.} + \label{fig:ci-job-list} +\end{figure} + \subsection{Job Configuration and Trigger} \label{sec:ci-trigger-config} @@ -349,14 +420,14 @@ Scan repository trigger & Periodically if not otherwise run, every \label{fig:ci-branch-source} \end{figure} -\textbf{Trigger: polling fallback.} The job scans Scrap-Web every minute and -starts a build for any branch or pull request whose head commit has changed. -The assignment permits polling in place of a webhook. It was chosen because a -webhook from Gitea to Jenkins on the private container network requires -changing Gitea's allowed webhook hosts, and Jenkins' web interface was not -opened merely to receive webhooks. The cost is a delay of up to one minute -between a push and the start of its build. In practice, each push in -Section~\ref{sec:ci-failure} was built within about two minutes. +\textbf{Trigger: webhook with polling fallback.} The Gitea webhook +(Section~\ref{sec:ci-trigger}) notifies Jenkins when a push or pull-request +event occurs, so a build can start without waiting for the next scan. As a +safety net, the job also scans Scrap-Web every minute and starts a build for +any branch or pull request whose head commit has changed. A missed or failed +webhook delivery therefore delays a build by about one minute instead of +losing it. In practice, each push in Section~\ref{sec:ci-failure} was built +within about two minutes. Each scan is recorded in the job's \emph{Scan Repository Log} (Figure~\ref{fig:ci-scan-log}). The scan at 04:15 UTC on October 23, 2026 @@ -373,25 +444,81 @@ were checked and skipped. \label{fig:ci-scan-log} \end{figure} +\subsection{Build and Commit Traceability} + +The Jenkins job is configured as a Multibranch Pipeline using the +Gitea source integration. Jenkins discovers branches and pull +requests from the repository and associates builds with the relevant +revision. This makes it possible to trace a proposed change from its +Gitea pull request to the Jenkins build and its reported status. + +During verification, Jenkins logs showed pull-request build activity +for pull request \#13. The logs also showed status notifications for +the following revisions: + +\begin{itemize} + \item \texttt{1de58d4742d1ad600dacad50890c845ab963e985} + \item \texttt{84a44f0477dac51b540d038bf3a94b8f49bec275} +\end{itemize} + +The Jenkins log included messages indicating that a pending build +was being reported and that the notification completed for each of these +revisions; the same commit IDs appear in Gitea's commit list for pull +request \#13. + +The traceability path is therefore: + +\begin{enumerate} + \item A developer pushes a commit or creates or updates a pull + request in the Gitea repository. + \item Gitea delivers the webhook event to Jenkins, or the next + one-minute repository scan detects the new commit. + \item The Jenkins Multibranch Pipeline discovers the relevant + branch or pull-request revision and starts the associated + build. + \item Jenkins records the build result and reports the associated + status back to Gitea. + \item A reviewer can inspect the pull request, commit, and Jenkins + result to determine whether the proposed change passed the + configured checks. +\end{enumerate} + +\subsection{Deployment Diagram} + +Figure~\ref{fig:gitea-jenkins-deployment} illustrates the deployment +and communication paths between the developer, Gitea, the webhook, +Jenkins, and the repository's build process. The HTTPS browser path +is shown separately from the webhook path to distinguish normal user +access from automated event delivery. + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{figures/gitea-jenkins-deployment.png} + \caption{Deployment and communication paths for Gitea and Jenkins + continuous integration.} + \label{fig:gitea-jenkins-deployment} +\end{figure} + \subsection{Traceability: Commit to Jenkins Run} The table below traces one trigger from the commit in Gitea to the Jenkins run that tested it. The commit ID is the same in Gitea's commit list, in the run's Checkout log (\texttt{git rev-parse HEAD}), and on the status Gitea -displays for that commit (Figure~\ref{fig:ci-pr-fail-fix}). +displays for that commit. \begin{tabularx}{\linewidth}{L{4.2cm}Y} \toprule \textbf{Item} & \textbf{Value}\\ \midrule Event & Repair commit pushed to branch \texttt{feature/issue-11}, the source of pull request \#13\\ -Time & October 23, 2026; Jenkins run started at 11:07 PM\\ -Detected by & Repository scan (polling); build started automatically\\ +Time pushed & October 23, 2026, 11:07 PM\\ +Detected by & Webhook or repository scan; build started automatically\\ Pull request & \#13, \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13}\\ -Triggering commit & \texttt{84a44f0477}\\ -Jenkins run & \texttt{Scrap-Web/PR-13} run \#9 (Figure~\ref{fig:ci-runs}; - the job was later removed by Jenkins, see below)\\ +Triggering commit & \texttt{84a44f0}\\ +Jenkins run & \texttt{Scrap-Web/PR-13} run \#9 (the job was later + removed by Jenkins; see below)\\ +Run history & Figure~\ref{fig:ci-runs}\\ Status posted to Gitea & \texttt{Scrap-Web/pipeline/pr-main}: success, visible on the commit in \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/13/commits}{pull @@ -403,13 +530,13 @@ Status posted to Gitea & \texttt{Scrap-Web/pipeline/pr-main}: success, Checkout, the syntax check, and the tests all run on the Jenkins controller's built-in node, inside the Jenkins container; the stage view of -each run lists the node as \emph{Jenkins} (the built-in node, -Figure~\ref{fig:ci-stage-view}). There is no separate build agent and no inbound -agent port. Jenkins clones the commit from Gitea over HTTPS into its -workspace under \texttt{/var/jenkins\_home/workspace/} and runs the -\texttt{Jenkinsfile} stages there (Section~\ref{sec:ci-pipeline}). The risk -of building on the controller and the restrictions that limit it are covered -in Section~\ref{sec:ci-credentials}. +each run lists the node as \emph{Jenkins (built-in)}. There is no separate +build agent and no inbound agent port. Jenkins clones the commit from Gitea +over HTTPS into its workspace under \texttt{/var/jenkins\_home/workspace/} +and runs the \texttt{Jenkinsfile} stages there +(Section~\ref{sec:ci-pipeline}). The risk of building on the controller and +the restrictions that limit it are covered in +Section~\ref{sec:ci-credentials}. \subsection{Failure Diagnoses} @@ -417,35 +544,40 @@ Four integration problems were diagnosed and corrected. \textbf{Repository not visible to Jenkins.} When the job was first configured, the Repository list for owner \texttt{SSW-590-08} was empty, -even though the token had repository access. \textit{[Cause and fix.]} -After the correction the repository appeared and the first scan discovered -pull request \#13 (Figure~\ref{fig:ci-scan-log}). +even though the \texttt{jenkins-ci} account was a collaborator on the +repository. The token was regenerated with the scopes \texttt{write:repository} +and \texttt{read:user} (Gitea did not keep any other scope selected), the +Jenkins credential \texttt{gitea-jenkins-ci} was updated, and the old tokens +were deleted. After the correction the repository appeared in the list and +the first scan discovered pull request \#13. \textbf{First build failed: \texttt{python3: not found}.} Run \#1 of -\texttt{PR-13} (October 23, 2026, 00:13) checked out the commit -successfully, proving the integration worked, but failed in the Checkout -stage at \texttt{python3 --version} with exit code 127; the later stages were -skipped (Figure~\ref{fig:ci-runs}). The official Jenkins image does not -include Python. The fix was a deployment change, not a code change: -\texttt{python3} was added to the Jenkins container \textit{[confirm how: -e.g.\ by building it from \texttt{jenkins/Dockerfile}]}. Run \#2, started -manually on the same commit at 9:39 PM, then passed and reported Python -3.13.5 (Figure~\ref{fig:ci-stage-view}). +\texttt{PR-13} (October 23, 2026) checked out the commit successfully, +proving the integration worked, but failed in the Checkout stage at +\texttt{python3 --version} with exit code 127. The official Jenkins image +does not include Python. The fix was a deployment change, not a code change: +\texttt{python3} was added to the Jenkins container. Jenkins now runs the +custom image \texttt{custom-jenkins:lts-jdk21-python3}, which adds Python to +the Jenkins LTS JDK~21 image (recorded on October 28, 2026), so Python survives +a container rebuild. Run \#2 on the same +pull request then passed, reporting Python 3.13.5. \textbf{Required check reported as missing.} After the status-check requirement was added, Gitea showed the Jenkins check as green but still reported ``some required checks are missing'' and blocked the merge. -\textit{[Cause and fix.]} +The branch rule contained a pattern that did +not exactly match the reported context \texttt{Scrap-Web/pipeline/pr-main}. +It was corrected to that exact name. \textbf{Pull request runs deleted after merge.} Shortly after pull request \#13 was merged, the \texttt{PR-13} job and all of its runs disappeared from -Jenkins. The pull request was closed, and the Multibranch job's default -orphaned item strategy discards the jobs of closed pull requests. Deleted -runs cannot be restored without a backup of \texttt{jenkins\_home}. The -evidence survives in Gitea, because the commit statuses Jenkins posted remain -attached to each commit of pull request \#13, and in the screenshots captured -while the runs existed. To keep future evidence, the job's \emph{Orphaned -Item Strategy} was changed to keep old items for 30 days. +Jenkins. The Scan Repository Log showed that the job had been removed as an +orphaned item: the pull request was closed, and the Multibranch job's default +orphaned item strategy discards such jobs immediately. Deleted runs cannot be +restored without a backup of \texttt{jenkins\_home}. The evidence survives in +Gitea, because the commit statuses Jenkins posted remain attached to each +commit of pull request \#13. To keep future evidence, the job's +\emph{Orphaned Item Strategy} was changed to keep old items for 30 days. If a trigger fails in future, the operator follows the procedure in Section~\ref{sec:ci-troubleshoot}. @@ -547,9 +679,9 @@ The application and tests use only the Python 3 standard library (\texttt{unittest} and \texttt{py\_compile}), so the pipeline downloads no packages and has no external dependency source to trust or pin. The only requirement is a \texttt{python3} interpreter on the Jenkins executor, -installed in the Jenkins container image from \texttt{jenkins/Dockerfile} -(Python 3.13.5, as printed by the Checkout stage); it is not installed in the -Gitea container. +provided by the Jenkins container image +\texttt{custom-jenkins:lts-jdk21-python3} (Python 3.13.5, as printed by the +Checkout stage); it is not installed in the Gitea container. \subsection{Reproducing a Clean Run} @@ -560,7 +692,14 @@ python3 -m py_compile pricing.py tests/test_pricing.py python3 -m unittest discover -s tests -v \end{verbatim} (On Windows, use \texttt{python} instead of \texttt{python3}.) A clean result -ends with \texttt{Ran 2 tests} and \texttt{OK}. +ends with \texttt{Ran 2 tests} and \texttt{OK} (Figure~\ref{fig:ci-local}). + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{HW6 images/runs.png} + \caption{Local reproduction on Windows: the syntax check and both unit tests pass.} + \label{fig:ci-local} +\end{figure} \textbf{In Jenkins:} every new commit pushed to a pull request starts a new run in a fresh checkout of that commit. A team member can also rebuild the @@ -596,9 +735,9 @@ Gitea. The default branch, \texttt{main}, is protected in Gitea~\cite{GiteaProtectedBranches} (\emph{Scrap-Web $\rightarrow$ Settings $\rightarrow$ Branches}, -Figure~\ref{fig:ci-branch-rule}). The rule was created on October 18, 2026, -and the required status check was added on October 23, 2026, once Jenkins -had reported its first status. +Figure~\ref{fig:ci-branch-rule}). The rule was put in place on October 23, 2026, with the required +status check, once Jenkins had reported its first status. Gitea's settings page +does not show the rule's history far enough back to capture a dated screenshot. \begin{tabularx}{\linewidth}{L{4.6cm}Y} \toprule @@ -627,8 +766,8 @@ every merge (Section~\ref{sec:ci-trigger}). \begin{figure}[H] \centering \includegraphics[width=0.75\linewidth]{HW6 images/branch-rule.png} - \caption{October 18, 2026 --- Branch protection rule for \texttt{main} in - the Scrap-Web branch settings.} + \caption{Branch protection rule for \texttt{main} in the Scrap-Web branch + settings.} \label{fig:ci-branch-rule} \end{figure} @@ -638,8 +777,9 @@ The merge gate depends on a commit status, not on a trigger. A webhook or repository scan only tells Jenkins that something changed; it says nothing about whether the code passes. The sequence is: \begin{enumerate} - \item A push to a pull request's branch is detected by the Multibranch job's - repository scan (Section~\ref{sec:ci-trigger-config}). + \item A push to a pull request's branch reaches Jenkins through the Gitea + webhook or the Multibranch job's one-minute repository scan + (Section~\ref{sec:ci-trigger-config}). \item The job builds the pull request's latest head commit and runs the \texttt{Jenkinsfile} stages. \item When the run starts and again when it finishes, the Jenkins Gitea @@ -882,15 +1022,23 @@ credentials and job configuration. The compensating restrictions are: \item the Jenkins web interface is reachable only over HTTPS through Caddy and requires login (Section~\ref{sec:ci-https}). \end{itemize} +One gap remains: the Gitea webhook has no secret, so Jenkins cannot verify +that a delivery came from Gitea. A forged delivery can only make Jenkins scan +the repository; it cannot change the code that is built. Adding a shared +secret to the webhook and the Jenkins Gitea configuration is the next +hardening step. \subsection{Plugin-Update Check} -On \textit{[date]}, \emph{Manage Jenkins $\rightarrow$ Plugins $\rightarrow$ -Updates} listed \textit{[n]} available updates \textit{[name any marked as -security fixes]}. Action taken: \textit{[updated and restarted Jenkins / -deferred until after the assignment, with reason]}. Plugin updates are -checked before each assignment, and any plugin with a published security -warning is updated first. +On October 24, 2026, \emph{Manage Jenkins $\rightarrow$ Plugins $\rightarrow$ +Updates} listed one available update: \emph{Pipeline: API}, installed version +\texttt{1413.v2ff1a\_5e720fa\_}, available version +\texttt{1429.v7a\_1b\_efb\_a\_f7c5} (released two days earlier). It was not +marked as a security fix. Action taken: deferred until after this assignment +was submitted, because updating requires a Jenkins restart and the update +fixes no published security warning. Plugin updates are checked before each +assignment, and any plugin with a published security warning is updated +first. \subsection{Troubleshooting a Failed Trigger or Build} \label{sec:ci-troubleshoot} @@ -905,7 +1053,7 @@ warning is updated first. \texttt{gitea-jenkins-ci} credential holds a current token and that \texttt{jenkins-ci} is still a Write collaborator (Section~\ref{sec:ci-trigger}). - \item If a webhook is used: in Gitea, open \emph{Scrap-Web $\rightarrow$ + \item In Gitea, open \emph{Scrap-Web $\rightarrow$ Settings $\rightarrow$ Webhooks}, check \emph{Recent Deliveries} for the response code, and use \emph{Test Delivery} after any fix. \end{enumerate} @@ -932,6 +1080,32 @@ warning is updated first. \end{enumerate} \section{Manual Quality and Controls} -\textit{[Version and history entry, Hosts and Passwords table updates, UML -deployment diagram, citations, glossary and index entries, and the operator -restart/troubleshooting note.]} +\label{sec:ci-quality} + +\begin{itemize} + \item \textbf{Version and history:} the manual is at Version 1.5, and the + Document History table has a 1.5 entry describing this chapter and the + table updates. + \item \textbf{Hosts and Passwords:} the Hosts table + (Table~\ref{tab:devops-hosts}) now lists the Jenkins hostname + \texttt{ci.ssw590-08.me} and its internal ports 8080 and 50000, which are + not published on the Droplet. The Passwords table + (Table~\ref{tab:devops-passwords}) lists the Jenkins administrator + accounts and the \texttt{jenkins-ci} integration account with hints only; + no password or token value appears anywhere in this manual. + \item \textbf{Deployment diagram:} Figure~\ref{fig:gitea-jenkins-deployment} + shows the Droplet, the three containers, the \texttt{jenkins\_home} + volume, and the browser, webhook, and status paths. + \item \textbf{Citations:} the Jenkins Pipeline, Jenkins Gitea plugin, + Jenkins security, and Gitea protected-branch documentation are cited + where they are used and listed in the Bibliography. + \item \textbf{Glossary and index:} the terms \gls{pullrequest}, \gls{webhook}, + \gls{statuscheck}, \gls{mergegate}, and \gls{jenkinsfile} were added to the + Glossary, and the chapter is indexed under Jenkins and continuous + integration. + \item \textbf{Operator notes:} restarting Jenkins is + \texttt{docker restart jenkins} (Section~\ref{sec:ci-deploy}); its data + survives in the \texttt{jenkins\_home} volume, which is not a backup. + Failed triggers and builds are handled with the procedure in + Section~\ref{sec:ci-troubleshoot}. +\end{itemize} diff --git a/manual/devopsDocumentHistory.tex b/manual/devopsDocumentHistory.tex index 28426f1..254c2ce 100644 --- a/manual/devopsDocumentHistory.tex +++ b/manual/devopsDocumentHistory.tex @@ -2,12 +2,17 @@ \addcontentsline{toc}{chapter}{Document History} \index{document history} -\begin{table}[H] -\caption{Document Update History\label{Table:DocumentHistory}} -\begin{tabularx}{\linewidth}{L{3.1cm}L{2.2cm}YL{2.0cm}} -\toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule +{\small +\begin{longtable}{L{2.4cm}L{1.3cm}p{\dimexpr\linewidth-2.4cm-1.3cm-1.9cm-8\tabcolsep\relax}L{1.9cm}} +\caption{Document Update History\label{Table:DocumentHistory}}\\ +\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule +\endfirsthead +\toprule \textbf{Date / Version} & \textbf{Authors} & \textbf{Change} & \textbf{Changed At}\\ \midrule +\endhead -October 22, 2026 / 1.5 & SK, KH & Completed the Continuous Integration with Jenkins assignment: deployed a persistent Jenkins LTS container behind HTTPS at \texttt{ci.ssw590-08.me} with firewall-restricted access; integrated Jenkins with the Scrap-Web Gitea repository through a dedicated integration account; added a pricing module, unit tests, and a versioned \texttt{Jenkinsfile}; protected \texttt{main} with a required Jenkins status check and one required approval; and demonstrated a failed, repaired, reviewed, and merged pull request. Updated the Hosts table (Jenkins host and ports) and the Passwords table (Jenkins administrator accounts and the Gitea integration token, hints only). & \ChapterRef{ContinuousIntegration}, \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} \\ + +October 23, 2026 / 1.5 & SK, KH & Completed the Continuous Integration with Jenkins assignment: deployed a persistent Jenkins LTS container behind HTTPS at \texttt{ci.ssw590-08.me} with firewall-restricted access; integrated Jenkins with the Scrap-Web Gitea repository through a dedicated integration account; added a pricing module, unit tests, and a versioned \texttt{Jenkinsfile}; protected \texttt{main} with a required Jenkins status check and one required approval; and demonstrated a failed, repaired, reviewed, and merged pull request. Updated the Hosts table (Jenkins host and ports) and the Passwords table (Jenkins administrator accounts and the Gitea integration token, hints only). & \ChapterRef{ContinuousIntegration}, \ChapterRef{PWDHST} \\ October 10, 2026 / 1.4 & SK, KH & Completed the related Gitea automation in LaTeX exercise and documented it in new chapter & \ChapterRef{AutomatedManualBuild} \\ @@ -15,5 +20,5 @@ October 2, 2026 / 1.3 & SK, KH & Completed the Gitea startup exercise and docume September 24, 2026 / 1.2 & SK, KH& Completed the Digital Ocean Docker Deployment chapter; the class-based JavaScript refactor of the two-button website with its accompanying UML class diagram; the LaTeX Docker chapter ; and the Project Proposal chapter, addressing the two-tool comparison, dashboard, SWOT, and unique-contribution rubric criteria. & \ChapterRef{Digital Ocean}, \ChapterRef{ClassBasedJSRefactor}, \ChapterRef{Latex Docker}, \ChapterRef{ProjectProposal}\\ September 16, 2026 / 1.1 & SK, KH & Completed the Linux Commands assignment: environment setup with terminal printout figure and full solutions to Problem Set sections A--E & \ChapterRef{LinuxCommands} \\ \bottomrule -\end{tabularx} -\end{table} +\end{longtable} +} diff --git a/manual/devopsGlossary.tex b/manual/devopsGlossary.tex index 7ba088a..f582128 100644 --- a/manual/devopsGlossary.tex +++ b/manual/devopsGlossary.tex @@ -3,6 +3,9 @@ \newacronym{cd}{CD}{continuous delivery or continuous deployment} \newacronym{iac}{IaC}{infrastructure as code} \newacronym{slo}{SLO}{service-level objective} +\newacronym{sli}{SLI}{service-level indicator} +\newacronym{sla}{SLA}{service-level agreement} +\newacronym{sre}{SRE}{site reliability engineering} \newglossaryentry{automation}{name={automation},description={A repeatable, version-controlled procedure executed by software rather than undocumented manual steps}} \newglossaryentry{deployment}{name={deployment},description={The controlled delivery of a versioned change to an environment}} \newglossaryentry{evidence}{name={evidence},description={A retained record of an actual execution, observation, or review}} @@ -16,3 +19,6 @@ \newglossaryentry{statuscheck}{name={status check},description={A named pass, fail, or pending result that a CI system attaches to a specific commit}} \newglossaryentry{mergegate}{name={merge gate},description={A branch-protection rule that blocks a merge until required status checks pass and reviews are approved}} \newglossaryentry{jenkinsfile}{name={\texttt{Jenkinsfile}},sort={Jenkinsfile},description={The version-controlled file that defines a Jenkins pipeline's stages and steps}} +\newglossaryentry{errorbudget}{name={error budget},description={The amount of failure an SLO allows over its window; for a 99\% target, 1\% of scheduled measurements}} +\newglossaryentry{probe}{name={probe},description={A synthetic request, here an HTTPS GET from Blackbox Exporter, that tests whether a service responds as expected}} +\newglossaryentry{contactpoint}{name={contact point},description={The Grafana destination, such as a Discord webhook or email address, that receives alert notifications}} diff --git a/manual/devopsPasswordsAndHosts.tex b/manual/devopsPasswordsAndHosts.tex index a557f63..a1782d9 100644 --- a/manual/devopsPasswordsAndHosts.tex +++ b/manual/devopsPasswordsAndHosts.tex @@ -2,7 +2,7 @@ \ChapterLabel{PWDHST} \section{Passwords} -\begin{longtable}{|p{3cm}|p{2.5cm}|p{4cm}|p{4cm}|} +\begin{longtable}{|>{\raggedright\arraybackslash}p{3.2cm}|>{\raggedright\arraybackslash}p{3.8cm}|>{\raggedright\arraybackslash}p{6.6cm}|} \caption{Passwords and Credential Hints} \label{tab:devops-passwords}\\ \hline @@ -46,12 +46,32 @@ Caddy & No login password configured\\ \hline +Jenkins +& samahk, kaylah7 +& Administrator passwords set at Jenkins setup; stored hashed by Jenkins\\ +\hline + +Gitea (Jenkins integration) +& jenkins-ci +& Password set by the Gitea administrator; Jenkins uses a token stored only in credential \texttt{gitea-jenkins-ci}\\ +\hline + +Grafana +& admin +& Administrator password kept in \texttt{grafana.secrets.env} on the Droplet; the file is in \texttt{.gitignore} and not in Git\\ +\hline + +Discord webhook (Grafana contact point \texttt{team-alerts}) +& N/A +& Webhook URL stored only in Grafana's database; re-created from the Discord channel's Integrations $\rightarrow$ Webhooks settings\\ +\hline + \end{longtable} \section{Hosts} -\begin{longtable}{|p{3.2cm}|p{4.2cm}|p{3.2cm}|p{3.5cm}|} +\begin{longtable}{|>{\raggedright\arraybackslash}p{3.2cm}|>{\raggedright\arraybackslash}p{3.9cm}|>{\raggedright\arraybackslash}p{1.9cm}|>{\raggedright\arraybackslash}p{5.1cm}|} \caption{Hosts and Services} \label{tab:devops-hosts}\\ \hline @@ -74,6 +94,22 @@ Gitea Git SSH & git.ssw590-08.me & 222 & Git repository SSH access \\ \hline Gitea Container & gitea & 3000 & Internal Docker network web service \\ \hline -Caddy Container & caddy & 80, 443 & Reverse proxy and TLS certificate management \\ +Caddy Container & caddy & 80, 443 & Reverse proxy and TLS certificate management for Gitea and Jenkins \\ +\hline +Jenkins Web Interface & ci.ssw590-08.me & 443 & HTTPS access to Jenkins through Caddy \\ +\hline +Jenkins Container & jenkins & 8080 & Internal Docker network web service; not published on the host \\ +\hline +Jenkins Agent Port & jenkins & 50000 & Not published on the host; no separate build agent is used \\ +\hline +Grafana Web Interface & metrics.ssw590-08.me & 443 & HTTPS access to Grafana through Caddy \\ +\hline +Grafana Container & grafana & 3000 & Internal Docker network web service (\texttt{gitea-net} and \texttt{monitoring}); not published on the host; state in volume \texttt{monitoring\_grafana\_data} \\ +\hline +Prometheus Container & prometheus & 9090 & Private, \texttt{monitoring} network only; metrics storage and query API; state in volume \texttt{monitoring\_prometheus\_data} \\ +\hline +Node Exporter Container & node-exporter & 9100 & Private, \texttt{monitoring} network only; whole-Droplet CPU, memory, and root-disk metrics \\ +\hline +Blackbox Exporter Container & blackbox-exporter & 9115 & Private, \texttt{monitoring} network only; HTTPS probes of Gitea and Jenkins \\ \hline \end{longtable} \ No newline at end of file diff --git a/manual/devopsReferences.bib b/manual/devopsReferences.bib index 59f00cb..c5a51b1 100644 --- a/manual/devopsReferences.bib +++ b/manual/devopsReferences.bib @@ -4,3 +4,94 @@ publisher = {IT Revolution Press}, year = {2018} } +@misc{JenkinsPipeline, + author = {{Jenkins Project}}, + title = {{Pipeline}}, + howpublished = {Jenkins User Documentation}, + year = {2026}, + url = {https://www.jenkins.io/doc/book/pipeline/}, + note = {Accessed: Oct. 24, 2026} +} + +@misc{JenkinsGiteaPlugin, + author = {{Jenkins Project}}, + title = {{Gitea Plugin}}, + howpublished = {Jenkins Plugins Index}, + year = {2026}, + url = {https://plugins.jenkins.io/gitea/}, + note = {Accessed: Oct. 24, 2026} +} + +@misc{JenkinsSecurity, + author = {{Jenkins Project}}, + title = {{Securing Jenkins}}, + howpublished = {Jenkins User Documentation}, + year = {2026}, + url = {https://www.jenkins.io/doc/book/security/}, + note = {Accessed: Oct. 24, 2026} +} + +@misc{GiteaProtectedBranches, + author = {{Gitea Authors}}, + title = {{Protected Branches}}, + howpublished = {Gitea Documentation}, + year = {2026}, + url = {https://docs.gitea.com/usage/access-control/protected-branches}, + note = {Accessed: Oct. 24, 2026} +} + +@book{SREWorkbook, + author = {Beyer, Betsy and Murphy, Niall Richard and Rensin, David K. and Kawahara, Kent and Thorne, Stephen}, + title = {{The Site Reliability Workbook: Practical Ways to Implement SRE}}, + publisher = {O'Reilly Media}, + year = {2018}, + note = {Chapter 2, ``Implementing SLOs.'' Available: https://sre.google/workbook/implementing-slos/} +} + +@misc{PrometheusDocs, + author = {{Prometheus Authors}}, + title = {{Prometheus Documentation}}, + year = {2026}, + url = {https://prometheus.io/docs/}, + note = {Accessed: Oct. 28, 2026} +} + +@misc{GrafanaDocs, + author = {{Grafana Labs}}, + title = {{Run Grafana Docker Image}}, + year = {2026}, + url = {https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/}, + note = {Accessed: Oct. 28, 2026} +} + +@misc{GrafanaAlerting, + author = {{Grafana Labs}}, + title = {{Grafana Alerting}}, + year = {2026}, + url = {https://grafana.com/docs/grafana/latest/alerting/}, + note = {Accessed: Oct. 28, 2026} +} + +@misc{NodeExporter, + author = {{Prometheus Authors}}, + title = {{Node Exporter}}, + year = {2026}, + url = {https://github.com/prometheus/node_exporter}, + note = {Accessed: Oct. 28, 2026} +} + +@misc{BlackboxExporter, + author = {{Prometheus Authors}}, + title = {{Blackbox Exporter}}, + year = {2026}, + url = {https://github.com/prometheus/blackbox_exporter}, + note = {Accessed: Oct. 28, 2026} +} + +@misc{DOSMTP, + author = {{DigitalOcean}}, + title = {{Why Is SMTP Blocked?}}, + year = {2026}, + url = {https://docs.digitalocean.com/support/why-is-smtp-blocked/}, + note = {Accessed: Oct. 28, 2026} +} diff --git a/manual/devopsSRE.tex b/manual/devopsSRE.tex new file mode 100644 index 0000000..a7508d8 --- /dev/null +++ b/manual/devopsSRE.tex @@ -0,0 +1,1500 @@ +\chapter{Introduction to SRE: Monitoring and Reliability} +\ChapterLabel{SRE} +\index{site reliability engineering} +\index{Prometheus} +\index{Grafana} +\sloppy + +% Figure helper: shows a labelled box until the screenshot file exists. +\providecommand{\srefig}[4]{% + \begin{figure}[H]\centering + \IfFileExists{HW7 images/#1}{\includegraphics[width=#2\linewidth]{HW7 images/#1}}% + {\fbox{\parbox{0.8\linewidth}{\centering\vspace{1em}\textit{[Screenshot needed: HW7 images/#1]}\vspace{1em}}}} + \caption{#3}\label{#4}\end{figure}} + +\section{Deployment and Reproducibility} +\label{sec:sre-deploy} + +\begin{description} + \item[Issue:] \#18, + \url{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/18}. + Implementation owner \texttt{samahk13}, verifier \texttt{kholmes}. + \item[Branch:] \texttt{feature/issue-18-monitoring}; first commit + \texttt{4c09870} (``Add monitoring stack config for \#18'') + \item[Starting commit:] \texttt{main} at + \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/commit/3301e2463ee32d4688330182a41f8ffddcdaed46}{\texttt{3301e2463ee32d4688330182a41f8ffddcdaed46}}, + the merge of pull request \#17 + \item[Passing builds at the start:] Jenkins \texttt{Scrap-Web/main} run \#5 + (October 28, 2026, 3:28 PM EDT) and run \#6 (3:44:57 PM EDT), both + \emph{SUCCESS} on \texttt{3301e24} + \item[Configuration:] the \texttt{monitoring/} directory of Scrap-Web, + deployed on the Droplet at \texttt{/root/Scrap-Web/monitoring} +\end{description} + +\subsection{Baseline} +The baseline was recorded on October 28, 2026, at 3:22 PM EDT, before any +monitoring container was started: + +\begin{tabularx}{\linewidth}{L{3.6cm}Y} +\toprule +\textbf{Item} & \textbf{Value}\\ \midrule +Operating system & Ubuntu 24.04.5 LTS, kernel 6.8.0-147-generic, x86\_64\\ +CPU & 1 vCPU (DO-Regular); load average 0.21, 0.17, 0.11\\ +Memory & 2{,}063{,}568{,}896 bytes total; 791{,}658{,}496 bytes available; no swap\\ +Root filesystem & \texttt{/dev/vda1} at \texttt{/}: 50{,}884{,}108{,}288 bytes, + 45{,}612{,}322{,}816 bytes available (11\% used)\\ +Docker & Engine 29.8.2; Compose v5.5.1\\ +Running services & \texttt{jenkins} (\texttt{custom-jenkins:lts-jdk21-python3}, + 695.8 MiB), \texttt{gitea} (\texttt{gitea/gitea:1.26.4}, 218.1 MiB), + \texttt{caddy} (\texttt{caddy:2}, 26.7 MiB)\\ +\bottomrule +\end{tabularx} + +\medskip +\textbf{Capacity change before deployment.} The Droplet had about 775 MB of +available memory and no swap. If Jenkins and the four new containers reached +their peak memory use at the same time, the kernel could terminate a +container. A 1~GB swap file was therefore added before deployment and made +persistent in \texttt{/etc/fstab}: +\begin{minted}[breaklines,breakanywhere]{bash} +fallocate -l 1G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile +echo '/swapfile none swap sw 0 0' >> /etc/fstab +free -h # Swap: 1.0Gi total, 0B used +\end{minted} +Rollback: \texttt{swapoff /swapfile}, remove the \texttt{fstab} line, and +delete \texttt{/swapfile}. + +\textbf{Capacity, headroom, and retention rationale.} Each resource was judged +against the baseline above and the build observations in +Section~\ref{sec:sre-dashboard}. +\begin{itemize} + \item \textbf{CPU} (1 vCPU, load average 0.21 at baseline). A normal Jenkins + build was a CPU burst of under 10 seconds, after which every container fell + back below 1\% (run \#6). Scraping five targets every 30 seconds is short, + periodic work, so CPU was not expected to limit the stack. The monitoring + stack's own CPU cost was not measured separately. + \item \textbf{Memory} is the tightest resource. About 791.7~MB of 2.06~GB + (38\%) was available at baseline with no swap, and Jenkins alone used + 695.8~MiB. The four monitoring containers add to that, which is why the + 1~GB swap file was added first. A normal build changed available memory by + only about 10~MB, so build activity does not threaten the margin. + \item \textbf{Disk.} 45.6~GB of 50.9~GB (about 90\%) was free at baseline. + By October 30 the root filesystem was 18.2\% used, still above the 15\% + free-space alert threshold with a wide margin + (Figure~\ref{fig:sre-disk-usage}). The rise from 11\% is consistent with the + swap file, four images, and Prometheus data, but it was not broken down by + cause. + \item \textbf{Retention} is 7 days or 5~GiB, whichever is reached first. Seven + days is the assignment's suggested lab starting point, and it is long + enough to cover the exercise window, the restart test, and a few days of + history. The 5~GiB cap is about 12\% of the free space at baseline, so it + leaves roughly 37~GiB for the operating system, images, Jenkins and Gitea + data, and builds. The cap is a ceiling that stops the database from filling + the disk and triggering the capacity alert on its own. It is not an + estimate of actual use, and the database size was not measured here. +\end{itemize} +Conclusion: the Droplet has headroom for monitoring, builds, and service data, +with memory as the limiting factor. + +\subsection{Selected Versions and Image Digests} +All four images come from the repositories published by the projects~\cite{PrometheusDocs,GrafanaDocs,NodeExporter,BlackboxExporter}. Each tag +was chosen as a current supported release and pinned in +\texttt{monitoring/.env}; no \texttt{latest} tag is used. The digests were +recorded with \texttt{docker image inspect IMAGE:TAG --format +'\{\{index .RepoDigests 0\}\}'} after \texttt{docker compose pull} on +October 28, 2026. + +\begin{tabularx}{\linewidth}{L{2.6cm}L{4.4cm}Y} +\toprule +\textbf{Component} & \textbf{Image and tag} & \textbf{Digest (sha256)}\\ \midrule +Prometheus & \nolinkurl{prom/prometheus:v3.13.5} (LTS) & + \texttt{\seqsplit{aafa9d694e6a883c02db516d9f6e5b84e14195f49a2a6456a4cca815edda72b9}}\\ +Grafana OSS & \nolinkurl{grafana/grafana:13.2.5} & + \texttt{\seqsplit{9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84}}\\ +Node Exporter & \nolinkurl{quay.io/prometheus/node-exporter:v1.12.1} & + \texttt{\seqsplit{1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0}}\\ +Blackbox Exporter & \nolinkurl{quay.io/prometheus/blackbox-exporter:v0.29.0} & + \texttt{\seqsplit{9613f2884689b6fad9f1939f6a3b0388c93a022cfaededb19545b329b5c83dea}}\\ +\bottomrule +\end{tabularx} + +\medskip +All four images are \texttt{linux/amd64}, matching the Droplet. Existing +services were not upgraded. + +\subsection{Deployment Diagram} +Figure~\ref{fig:sre-deployment} shows the deployment as defined by +\texttt{monitoring/compose.yaml}. Arrows point from the side that starts the +request. + +\begin{figure}[H] + \centering + \includegraphics[width=\linewidth]{figures/sre-deployment.png} + \caption{Gitea, Jenkins, and the four monitoring containers on the Droplet. + Grafana is attached to both Docker networks: \texttt{gitea-net}, so Caddy + can reach \texttt{grafana:3000}, and \texttt{monitoring}, so it can query + Prometheus. Prometheus and both exporters are on the \texttt{monitoring} + network only and publish no host port. Because Blackbox Exporter is not on + \texttt{gitea-net}, its probes reach Caddy through the public hostnames. + The named volumes keep Prometheus and Grafana state; Jenkins state is in + \texttt{jenkins\_home}. Gitea's data volume is not shown.} + \label{fig:sre-deployment} +\end{figure} + +\subsection{Compose Configuration} +The stack is defined in \texttt{monitoring/compose.yaml} +(\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/compose.yaml}{in +Gitea}). Unlike the assignment's reference, Grafana publishes no host port. The +existing Caddy reverse proxy runs in a container on the \texttt{gitea-net} +network, so Grafana joins that network and Caddy reaches it as +\texttt{grafana:3000}. Prometheus and both exporters stay on the private +\texttt{monitoring} network only. + +\begin{minted}[fontsize=\footnotesize,breaklines,breakanywhere]{yaml} +services: + prometheus: + image: prom/prometheus:${PROMETHEUS_TAG:?choose a release} + container_name: prometheus + restart: unless-stopped + command: + - --config.file=/etc/prometheus/prometheus.yml + - --storage.tsdb.path=/prometheus + - --storage.tsdb.retention.time=7d + - --storage.tsdb.retention.size=5GB + volumes: + - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro + - prometheus_data:/prometheus + networks: [monitoring] + grafana: + image: grafana/grafana:${GRAFANA_TAG:?choose a release} + container_name: grafana + restart: unless-stopped + depends_on: [prometheus] + env_file: [grafana.secrets.env] # admin password; not in Git + environment: + GF_SERVER_ROOT_URL: "https://metrics.ssw590-08.me/" + GF_SERVER_DOMAIN: "metrics.ssw590-08.me" + GF_AUTH_ANONYMOUS_ENABLED: "false" + GF_USERS_ALLOW_SIGN_UP: "false" + GF_DATE_FORMATS_DEFAULT_TIMEZONE: "America/New_York" + volumes: + - grafana_data:/var/lib/grafana + - ./grafana/provisioning:/etc/grafana/provisioning:ro + - ./grafana/dashboards:/var/lib/grafana/dashboards:ro + networks: [monitoring, gitea-net] + node-exporter: + image: quay.io/prometheus/node-exporter:${NODE_EXPORTER_TAG:?choose a release} + container_name: node-exporter + restart: unless-stopped + pid: host + command: [--path.rootfs=/host, --path.procfs=/host/proc, --path.sysfs=/host/sys] + volumes: + - /:/host:ro,rslave + networks: [monitoring] + blackbox-exporter: + image: quay.io/prometheus/blackbox-exporter:${BLACKBOX_TAG:?choose a release} + container_name: blackbox-exporter + restart: unless-stopped + command: ["--config.file=/config/blackbox.yml"] + volumes: + - ./blackbox/blackbox.yml:/config/blackbox.yml:ro + networks: [monitoring] +networks: + monitoring: + gitea-net: {external: true, name: gitea-net} +volumes: + prometheus_data: + grafana_data: +\end{minted} + +\begin{tabularx}{\linewidth}{L{5.2cm}Y} +\toprule +\textbf{File} & \textbf{Purpose}\\ \midrule +\nolinkurl{.env} & Pinned image tags only (no secrets)\\ +\nolinkurl{prometheus/prometheus.yml} & Scrape jobs \texttt{prometheus}, \texttt{node}, + \texttt{blackbox}, and \texttt{https} (Section~\ref{sec:sre-metrics})\\ +\nolinkurl{blackbox/blackbox.yml} & \texttt{http\_2xx} probe module\\ +\nolinkurl{grafana/provisioning/datasources/prometheus.yml} & Data source + \texttt{Prometheus}, \texttt{http://prometheus:9090}, uid \texttt{prometheus}\\ +\nolinkurl{grafana/provisioning/dashboards/dashboards.yml} & Loads dashboards from + \texttt{grafana/dashboards/} into folder ``SSW 590''\\ +\nolinkurl{grafana/dashboards/ssw590-sre.json} & Team dashboard + (Section~\ref{sec:sre-dashboard})\\ +\nolinkurl{grafana/alerting/alert-rules.yaml} & Sanitized export of the alert + rules (Section~\ref{sec:sre-alerts})\\ +\nolinkurl{RUNBOOK.md} & Alert response procedures linked from each rule\\ +\nolinkurl{grafana.secrets.env.example} & Template for the secrets file; the real + \texttt{grafana.secrets.env} is listed in \texttt{.gitignore}\\ +\bottomrule +\end{tabularx} + +\subsection{Identities, Mounts, and Persistent Storage} +\begin{itemize} + \item Every container runs as its image's default user. None is + \texttt{privileged}, and none mounts the Docker socket. + \item Configuration files are mounted read-only (\texttt{:ro}). + \item \textbf{Prometheus} stores its time-series database in the named volume + \texttt{monitoring\_\allowbreak prometheus\_\allowbreak data}, mounted at \texttt{/prometheus}. + Retention is 7 days or 5~GB, whichever is reached first. The log confirmed + \texttt{TSDB retention updated duration=1w size=5GiB}. + \item \textbf{Grafana} stores users, sessions, alert state, and the contact + point in the named volume \texttt{monitoring\_\allowbreak grafana\_\allowbreak data}, mounted at + \texttt{/var/lib/grafana}. The data source and dashboard come from + provisioned files in Git; the alert rules are kept as a versioned export. + \item On the host, both volumes live under + \texttt{/var/lib/docker/volumes//\_data}, owned by root. + \item \textbf{Node Exporter} needs read-only access to the host root + filesystem (\texttt{/:/host:ro,rslave}) and the host PID namespace + (\texttt{pid: host}). Without them it cannot report host CPU, memory, and + root-filesystem values. It uses the bridge network, so its network-interface + metrics do not describe all host interfaces. + \item All four services use \texttt{restart: unless-stopped}. + \texttt{depends\_on} starts Prometheus before Grafana; the exporters have no + start-order requirement. +\end{itemize} + +\subsection{Validation and Startup} +From \texttt{/root/Scrap-Web/monitoring} on October 28, 2026: +\begin{minted}[breaklines,breakanywhere]{bash} +docker compose config --quiet # no output: Compose file is valid +docker compose pull # all four images pulled +docker compose run --rm --no-deps --entrypoint /bin/promtool \ + prometheus check config /etc/prometheus/prometheus.yml +# SUCCESS: /etc/prometheus/prometheus.yml is valid prometheus config file syntax +docker compose up -d # 2 volumes created, 4 containers started +docker compose ps # all four "Up"; ports 9090/9100/9115/3000 internal only +docker compose logs --tail=50 prometheus grafana node-exporter blackbox-exporter +docker compose images +\end{minted} +The logs showed Prometheus 3.13.5 \emph{``Server is ready to receive web +requests''}, Node Exporter and Blackbox Exporter 0.29.0 listening on 9100 and +9115, and Grafana completing its database migrations. The \texttt{PORTS} +column lists only container ports; no host port is published. + +\srefig{sre-targets-up.png}{1.0}{October 28, 2026, 5:10:20 PM EDT --- Grafana +Explore instant queries after the first start: \texttt{up} is 1 for all five +scrape targets, and \texttt{probe\_success} is 1 for both HTTPS +URLs.}{fig:sre-targets-up} + +\subsection{Routine Operation, Update, and Recovery} +\begin{tabularx}{\linewidth}{L{3.2cm}Y} +\toprule +\textbf{Task} & \textbf{Procedure}\\ \midrule +Pause / resume & \texttt{docker compose stop} / \texttt{docker compose start}. + Never use \texttt{docker compose down -v}, which deletes both named volumes.\\ +Configuration change & Edit the file in Git, \texttt{git pull} on the Droplet, + validate (\texttt{docker compose config --quiet}; \texttt{promtool check + config}), then \texttt{docker compose restart prometheus} (or the affected + service).\\ +Upgrade one component & Back up its volume (below), read the release notes, + change one tag in \texttt{.env}, then run \texttt{docker compose pull SERVICE} + and \texttt{docker compose up -d SERVICE}. Check health and history, record + the new digest, and commit.\\ +Rollback & Restore the previous tag in \texttt{.env} and recreate the service. + If the newer version migrated its data (Grafana's database, Prometheus' + TSDB), restore the pre-upgrade volume backup as well, because an older version + may not read upgraded data.\\ +Recover the whole stack & \texttt{git clone} Scrap-Web, recreate + \texttt{grafana.secrets.env} from the example, restore the volume backups if + available, then run \texttt{docker compose up -d}. The data source and + dashboard are re-provisioned from Git. Alert rules are re-imported from + \texttt{alert-rules.yaml}, and the Discord contact point is re-created with + the webhook kept outside Git.\\ +\bottomrule +\end{tabularx} + +\medskip +\textbf{Backup of state that Git cannot rebuild} (Grafana users, alert state, +contact point; Prometheus history): +\begin{minted}[breaklines,breakanywhere]{bash} +cd /root/Scrap-Web/monitoring && docker compose stop grafana prometheus +for v in monitoring_grafana_data monitoring_prometheus_data; do + docker run --rm -v $v:/data:ro -v /root/backups:/backup alpine \ + tar czf /backup/$v-$(date +%F).tgz -C /data . +done +docker compose start prometheus grafana +\end{minted} +The archives contain the Grafana database, so they are kept on the Droplet +under \texttt{/root/backups} (root only) and are never committed to Git. + +\subsection{Restart Persistence Test} +Prometheus and Grafana were restarted separately on October 29, 2026, without +removing any volume: +\begin{minted}[breaklines,breakanywhere]{bash} +cd /root/Scrap-Web/monitoring +date -Is; docker compose restart prometheus # 2026-10-29T22:18:29+00:00 (6:18:29 PM EDT) +sleep 90 +date -Is; docker compose restart grafana # 2026-10-29T22:21:59+00:00 (6:21:59 PM EDT) +\end{minted} + +After both restarts, the dashboard opened at +\url{https://metrics.ssw590-08.me/} without being re-created +(Figure~\ref{fig:sre-dashboard-full}, captured about 6:35 PM EDT). +\begin{itemize} + \item With the range set to the last 2 days, every panel still shows the + history that starts when the stack was first deployed on October 28 at about + 4 PM, including the Jenkins outage at 4:09--4:13 PM on October 29. + \item The Prometheus data source returned data, so its provisioned definition + survived. + \item The dashboard itself survived, because it is provisioned from Git. +\end{itemize} +While Prometheus restarted, at most one or two 30-second scrapes could be +missed. Such a gap is not visible at a 2-day scale, and those samples are +treated as missing, not as successes. While Grafana restarted, the dashboard and +alert evaluation were briefly unavailable; Prometheus kept collecting +throughout. This test demonstrates that data persists across container +restarts. It is not a test of restoring from a backup. +% >>> optional: screenshot of Alerting -> Alert rules after the restart <<< +\section{Metrics and Probes} +\label{sec:sre-metrics} + +\subsection{Scrape and Probe Configuration} +Prometheus collects metrics every 30 seconds through four jobs. Every target is +reached by Docker service name on the private \texttt{monitoring} network; none +is published on the host (Section~\ref{sec:sre-deploy}). + +\begin{tabularx}{\linewidth}{L{2.2cm}L{4.4cm}Y} +\toprule +\textbf{Job} & \textbf{Target} & \textbf{Collects}\\ \midrule +\texttt{prometheus} & \texttt{prometheus:9090} & Prometheus' own metrics\\ +\texttt{node} & \texttt{node-exporter:9100} & Whole-Droplet CPU, memory, and + root-filesystem space\\ +\texttt{blackbox} & \texttt{blackbox-exporter:9115} & Blackbox Exporter's own + \texttt{/metrics}\\ +\texttt{https} & \nolinkurl{https://git.ssw590-08.me/user/login} and + \nolinkurl{https://ci.ssw590-08.me/login}, scraped through + \texttt{blackbox-exporter:9115/probe} with module \texttt{http\_2xx} & + \texttt{probe\_success} and \texttt{probe\_duration\_seconds} for each + URL\\ +\bottomrule +\end{tabularx} + +\medskip +The \texttt{https} job uses the multi-target pattern: each URL is passed to +Blackbox Exporter as the probe target, kept as the \texttt{instance} label, and +the scrape itself is sent to the exporter's \texttt{/probe} endpoint. This is why +the queries in this chapter select a service with +\texttt{job="https",instance=""}. The probe interface stays private, and +the \texttt{blackbox} job scrapes the exporter's own \texttt{/metrics} as a +separate job. + +The deployed \texttt{monitoring/blackbox/blackbox.yml} defines one module: +\begin{minted}[fontsize=\footnotesize]{yaml} +modules: + http_2xx: + prober: http + timeout: 10s + http: + method: GET + preferred_ip_protocol: ip4 + valid_status_codes: [] # empty = any 2xx is success + follow_redirects: true + fail_if_not_ssl: true + tls_config: + insecure_skip_verify: false +\end{minted} + +The deployed \texttt{monitoring/prometheus/prometheus.yml}: +\begin{minted}[fontsize=\footnotesize]{yaml} +global: + scrape_interval: 30s + evaluation_interval: 30s + +scrape_configs: + - job_name: prometheus + static_configs: + - targets: ["prometheus:9090"] + + - job_name: node + static_configs: + - targets: ["node-exporter:9100"] + + - job_name: blackbox + static_configs: + - targets: ["blackbox-exporter:9115"] + + - job_name: https + metrics_path: /probe + params: + module: [http_2xx] + static_configs: + - targets: + - https://git.ssw590-08.me/user/login + - https://ci.ssw590-08.me/login + relabel_configs: + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: instance + - target_label: __address__ + replacement: blackbox-exporter:9115 +\end{minted} +The \texttt{relabel\_configs} copy each target URL into the \texttt{target} +parameter and the \texttt{instance} label, then send the request to the +Blackbox Exporter's address. + +\subsection{Target Health} +Figure~\ref{fig:sre-targets-up} shows the state after the first start: +\texttt{up} is 1 for all five scrape targets (the \texttt{prometheus}, +\texttt{node}, and \texttt{blackbox} jobs and the two probe URLs), and +\texttt{probe\_success} is 1 for both HTTPS URLs. \texttt{up} and +\texttt{probe\_success} answer different questions. \texttt{up} says that +Prometheus collected a result from the target. \texttt{probe\_success} says +whether the probed request itself succeeded, so \texttt{up} can be 1 while a +service is down. The dashboard keeps a separate scrape-health row for this +reason (Section~\ref{sec:sre-dashboard}). + +\subsection{Metric Inventory} +The metrics behind the dashboard and the alerts: + +\begin{tabularx}{\linewidth}{L{3.5cm}L{3.1cm}YY} +\toprule +\textbf{Metric (type, unit)} & \textbf{Labels used} & \textbf{Meaning} & + \textbf{Limitation}\\ \midrule +\texttt{node\_cpu\_\allowbreak seconds\_total} (counter, seconds) & \texttt{cpu}, + \texttt{mode} & Cumulative CPU time per mode; utilization is derived from the + rate of the idle mode & A lifetime total, so only its rate is meaningful. + Whole Droplet (1~vCPU), not per container\\ +\texttt{node\_memory\_\allowbreak MemAvailable\_bytes} (gauge, bytes) & + \texttt{job}, \texttt{instance} & Kernel estimate of memory available to new + programs without swapping & Not the same as unused RAM; no per-container + split\\ +\texttt{node\_filesystem\_\allowbreak avail\_bytes} and + \texttt{node\_filesystem\_\allowbreak size\_bytes} (gauges, bytes) & + \texttt{device}, \texttt{fstype}, \texttt{mountpoint} (values \texttt{/dev/vda1}, + \texttt{ext4}, \texttt{/}) & + Space available and total size of the root filesystem; their ratio is the + percentage available & The selector must name this one filesystem so overlay + and pseudo filesystems are excluded\\ +\texttt{up} (gauge, 0/1) & \texttt{job}, \texttt{instance} & 1 if the last + scrape of the target succeeded & Collection health only; says nothing about + whether a measurement is correct or a service works\\ +\texttt{probe\_success} (gauge, 0/1) & \texttt{job="https"}, \texttt{instance} + (the URL) & 1 if the probe met its success criteria & Login page only, probed + from the Droplet\\ +\texttt{probe\_duration\_\allowbreak seconds} (gauge, seconds) & same as + \texttt{probe\_success} & Total probe time, including DNS, connection, TLS, + and the request & One vantage point; a single slow sample is not a trend\\ +\bottomrule +\end{tabularx} + +\medskip +The exported root-filesystem labels were checked rather than assumed. With the +host root mounted at \texttt{/host} inside the Node Exporter container, the +series for the host root still carries \texttt{mountpoint="/"}, +\texttt{device="/dev/vda1"}, and \texttt{fstype="ext4"} +(Figure~\ref{fig:sre-disk-normal}), and the alert and dashboard selectors use +exactly these labels. + +\subsection{Host Metric Verification} +Node Exporter was compared with the operating system on the Droplet at +8:02:50 PM EDT (2026-10-31T00:02:50Z) on October 30, 2026. The Prometheus values were +read from the Prometheus HTTP API inside its container, within a second of the +operating-system commands. + +\begin{tabularx}{\linewidth}{L{3.2cm}L{3.3cm}L{3.3cm}Y} +\toprule +\textbf{Quantity} & \textbf{Prometheus (bytes)} & \textbf{Operating system (bytes)} & \textbf{Difference}\\ \midrule +Memory available & 723,578,880 & 733,319,168 (\texttt{free -b}) & 9.7~MB (1.3\%)\\ +Root filesystem size & 50,884,108,288 & 50,884,108,288 (\texttt{df -B1 /}) & none\\ +Root filesystem available & 41,571,614,720 & 41,571,602,432 (\texttt{df -B1 /}) & 12,288 bytes\\ +\bottomrule +\end{tabularx} + +\medskip +\begin{itemize} + \item The filesystem size matches exactly. Available space differs by 12,288 + bytes, which is ordinary change on a live disk between two reads less than a + second apart. Both give about 81.7\% available, and \texttt{df} reports 19\% + used. + \item Available memory differs by about 1.3\%. The two reads are not + simultaneous and the value changes continuously, so a small difference is + expected. \texttt{top} reported 699.8~MiB (about 733.8~MB) available, which + agrees with \texttt{free}. + \item CPU idle was compared at 8:23:25--28 PM EDT (00:23:25--28 UTC). The second + \texttt{top} sample, taken over a 5-second interval, showed 86.8\% idle + (with 4.3\% steal time). Prometheus returned 90.2\% for + \texttt{100 * avg(rate(node\_cpu\_seconds\_total\{mode="idle"\}[2m]))}. The + 3.4-point difference is expected, because \texttt{top} measures 5 seconds and + the query averages 2 minutes. Both show a mostly idle host, but this is a + single comparison, not an exact match. +\end{itemize} + +\subsection{Probe Success Criteria} +A probe succeeds only if Blackbox Exporter's \texttt{http\_2xx} module completes +the whole request: DNS resolution, the TCP connection, a TLS handshake with +certificate and hostname verification, and a final HTTP 2xx response after any +redirects. TLS verification is not disabled. The probed URLs are the login pages +\nolinkurl{https://git.ssw590-08.me/user/login} and +\nolinkurl{https://ci.ssw590-08.me/login}. +The module has a 10-second timeout and prefers IPv4. It sets +\texttt{fail\_if\_not\_ssl: true}, so a plain-HTTP response fails, and +\texttt{insecure\_skip\_verify: false}, so an invalid certificate fails. +Because \texttt{valid\_status\_codes} is empty, any 2xx status counts as success. +The module has no body-match setting: the check is the login page's response +status, not its content. + +\subsection{Limitations} +\begin{itemize} + \item The host metrics describe the whole Droplet. They cannot attribute CPU + or memory to Jenkins, Gitea, or any one container. + \item Node Exporter runs on the bridge network, so its network-interface + metrics do not describe all host interfaces. They are not used. + \item A 30-second scrape can miss anything shorter, such as the 5-second build + in Section~\ref{sec:sre-dashboard}. + \item A successful login-page probe does not prove that authenticated Git + operations or builds work. + \item Probes run from the Droplet, so they do not prove reachability from + users' networks. Monitoring shares the Droplet's failure domain + (Section~\ref{sec:sre-incident}). + \item An exporter being reachable does not establish that its measurements are + correct, which is why the host values are compared with the operating + system above. +\end{itemize} +\section{HTTPS and Access Control} +\label{sec:sre-access} + +\subsection{HTTPS Login URLs} +\begin{tabularx}{\linewidth}{L{2.4cm}L{6.2cm}Y} +\toprule +\textbf{Service} & \textbf{Login URL} & \textbf{Route}\\ \midrule +Gitea & \url{https://git.ssw590-08.me/user/login} & Caddy $\rightarrow$ + \texttt{gitea:3000}\\ +Jenkins & \url{https://ci.ssw590-08.me/login} & Caddy $\rightarrow$ + \texttt{jenkins:8080}\\ +Grafana & \url{https://metrics.ssw590-08.me/login} & Caddy $\rightarrow$ + \texttt{grafana:3000}\\ +\bottomrule +\end{tabularx} + +\medskip +Gitea and Jenkins keep the HTTPS routing, certificates, and firewall rules from +the earlier chapters (Section~\ref{sec:ci-https}). Grafana was added behind the +same Caddy proxy on its own hostname. Caddy and Grafana share the +\texttt{gitea-net} Docker network, so the route needs no host port. + +\subsection{Access Instructions} +No password is written in this report. +\begin{enumerate} + \item Open the Grafana URL above. Anonymous access is disabled, so the page + redirects to the login form. + \item Sign in with a named Grafana account. The administrator password is + supplied from \texttt{grafana.secrets.env} on the Droplet, which is listed in + \texttt{.gitignore} and is not in Git. The hint is in the Passwords table + (Table~\ref{tab:devops-passwords}). + \item Open the dashboard at \url{https://metrics.ssw590-08.me/d/ssw590-sre}. +\end{enumerate} +No grader account was created. The dashboard, alert rules, notifications, and +incident evidence needed for grading are embedded as figures in this chapter. + +\subsection{Authentication and Secret Handling} +\begin{itemize} + \item Grafana has anonymous access and self-registration turned off + (\texttt{GF\_AUTH\_ANONYMOUS\_ENABLED=false}, + \texttt{GF\_USERS\_ALLOW\_SIGN\_UP=false}), so only accounts created by an + administrator can sign in. + \item The Discord webhook URL is stored only in Grafana's database and never + in Git or screenshots. The abandoned Gmail app password was revoked + (Section~\ref{sec:sre-alerts}). + \item No monitoring container is \texttt{privileged}, and none mounts the + Docker socket. Node Exporter's read-only host mount and host PID namespace + are the only host access, and Section~\ref{sec:sre-deploy} explains why they + are needed. +\end{itemize} + +\subsection{Proxy and Port Exposure} +Only Caddy publishes web ports on the Droplet (80 and 443). The Compose file +publishes no port for Grafana, Prometheus, Node Exporter, or Blackbox Exporter, +and \texttt{docker compose ps} lists container ports only +(Section~\ref{sec:sre-deploy}). Prometheus (9090), Node Exporter (9100), and +Blackbox Exporter (9115) are reachable only from other containers on the +\texttt{monitoring} network. + +The first external test (below) showed that Grafana's \texttt{/metrics} +endpoint was readable without a login, because the original Grafana site block +in the Caddyfile (\texttt{/root/gitea/Caddyfile}) forwarded every path: +\begin{minted}[fontsize=\footnotesize]{text} +metrics.ssw590-08.me { + encode gzip + reverse_proxy grafana:3000 +} +\end{minted} +The block was then changed to answer \texttt{/metrics} with 404 and forward +everything else, and Caddy's configuration was validated and reloaded: +\begin{minted}[fontsize=\footnotesize]{text} +metrics.ssw590-08.me { + encode gzip + handle /metrics* { + respond "Not found" 404 + } + handle { + reverse_proxy grafana:3000 + } +} +\end{minted} +Prometheus scrapes Grafana's own metrics, if at all, over the internal network and +not through Caddy, so the block does not affect the monitoring configuration. + +\subsection{External Exposure Tests} +\label{sec:sre-exposure-tests} +The tests below must be run from a machine outside the Droplet. A test run on +the Droplet itself shows only what is listening, not what the network allows. +\begin{minted}[breaklines,breakanywhere]{bash} +date -u +%Y-%m-%dT%H:%M:%SZ +for p in 3000 3001 9090 9100 9115; do nc -vz -w 3 147.182.179.191 $p; done +for u in https://git.ssw590-08.me/user/login https://ci.ssw590-08.me/login \ + https://metrics.ssw590-08.me/login https://metrics.ssw590-08.me/d/ssw590-sre \ + https://metrics.ssw590-08.me/metrics; do + printf '%s ' "$u"; curl -sS -o /dev/null -w '%{http_code}\n' "$u" +done +\end{minted} + +\textbf{Machine and network.} The tests were run from a team member's MacBook +(macOS) that is not on the Droplet, on October 30, 2026. The first run was at +about 9:20--9:25~PM EDT; its own \texttt{date -Is} timestamp failed because macOS +\texttt{date} does not support that option, so the command above uses a portable +format. After the Caddy change, the full block was repeated and then the two +Grafana URLs were re-checked with a timestamp of +2026-10-31T01:44:20Z (9:44~PM EDT). + +\begin{tabularx}{\linewidth}{L{4.2cm}YL{4.2cm}} +\toprule +\textbf{Test} & \textbf{Expected} & \textbf{Actual}\\ \midrule +TCP 3000, 3001, 9090, 9100, 9115 on the public IPv4 address & Refused or timed + out: nothing is published on the host & All five timed out, before and after + the change\\ +Gitea, Jenkins, and Grafana login pages & HTTP 200 over HTTPS & 200, 200, 200\\ +Grafana dashboard URL without a session & Redirect (302) to the login page & + 302\\ +\nolinkurl{https://metrics.ssw590-08.me/metrics} & Not served publicly. A 200 + response would mean Grafana's own metrics are readable from the Internet and + should be blocked at Caddy & \textbf{Before the Caddy change: 200 (exposed). + After: 404}\\ +\bottomrule +\end{tabularx} + +\medskip +\begin{itemize} + \item \textbf{Finding.} Before the change, \texttt{/metrics} on the Grafana + hostname returned 200 to an unauthenticated client + (Figure~\ref{fig:sre-expose-before}). The page describes Grafana's own + internals; the host and probe metrics come from separate, unpublished + services. The path was nevertheless not meant to be public, so it was + blocked in Caddy. + \item \textbf{After the change,} the repeat shows 404 for \texttt{/metrics} + while the login page still returns 200 + (Figures~\ref{fig:sre-expose-after} and~\ref{fig:sre-expose-recheck}). + \item \textbf{IPv6.} \texttt{dig AAAA metrics.ssw590-08.me +short} printed + nothing, so the hostname has no IPv6 record and no IPv6 path was tested. + \item \textbf{Scope.} The five ports were tested from this one outside + network only. The result shows what was reachable, not why: the Cloud Firewall + rules (Section~\ref{sec:ci-https}) were not examined as part of this test. +\end{itemize} + +\srefig{exposure-before.png}{0.9}{October 30, 2026, about 9:20--9:25~PM EDT, from +an outside machine --- all five ports time out, but \texttt{/metrics} returns +200.}{fig:sre-expose-before} + +\srefig{exposure-after.png}{0.9}{October 30, 2026, after the Caddy change --- the +same test; \texttt{/metrics} now returns 404 (no timestamp, because the macOS +\texttt{date} option failed).}{fig:sre-expose-after} + +\srefig{exposure-recheck.png}{0.9}{October 30, 2026, 2026-10-31T01:44:20Z --- a +timestamped re-check: Grafana login 200, \texttt{/metrics} 404.}{fig:sre-expose-recheck} +\section{Dashboard and CI Correlation} +\label{sec:sre-dashboard} + +\subsection{Team Dashboard} +The dashboard \textbf{``SSW 590 -- Gitea \& Jenkins Reliability''} (uid +\texttt{ssw590-sre}, folder ``SSW 590'') was written for this deployment; it is +not an imported community dashboard. It is opened at +\url{https://metrics.ssw590-08.me/d/ssw590-sre} after login. Its definition is +versioned in Gitea as +\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/grafana/dashboards/ssw590-sre.json}{\texttt{monitoring/grafana/dashboards/ssw590-sre.json}}. +Grafana loads it at startup through the file provider in +\texttt{grafana/provisioning/dashboards/dashboards.yml}, so a rebuilt Grafana +container gets the same dashboard without manual steps. + +\begin{itemize} + \item \textbf{Time zone:} America/New\_York (EDT/EST), shown in the time + picker. + \item \textbf{Default range and refresh:} last 6 hours, refreshing every + 30 seconds to match the scrape interval. + \item \textbf{Data source:} the provisioned Prometheus data source + (\texttt{http://prometheus:9090}). + \item Every panel has a legend, a unit, and a description (the \emph{i} icon) + explaining its query. +\end{itemize} + +\begin{tabularx}{\linewidth}{L{4.4cm}Y} +\toprule +\textbf{Panel (unit)} & \textbf{Meaning and thresholds}\\ \midrule +1. Droplet CPU utilization (\%) & Share of CPU time not idle, averaged across + CPUs. CPU time is a counter, so the panel uses its 2-minute \texttt{rate} + rather than the raw total. Orange at 70\%, red at 90\%.\\ +2. Available host memory (bytes, IEC) & The kernel's estimate of memory + available to new programs without swapping; not the same as unused RAM. + Orange below 400~MiB, red below 200~MiB.\\ +3. Root filesystem available (\%) & Available bytes divided by size bytes for + the host root filesystem \texttt{/dev/vda1} only. The selector excludes + overlay and pseudo filesystems. Orange below 25\%, red below 15\% (the alert + threshold).\\ +4. Gitea HTTPS availability (0/1) & 1 = probe succeeded, 0 = failed, shown as + UP/DOWN.\\ +5. Jenkins HTTPS availability (0/1) & Same as panel 4, for Jenkins.\\ +6. HTTPS probe duration (s) & Total probe time, including DNS, connection, TLS, + and request; one labeled line per service.\\ +Scrape health (0/1) & Collection health for every target. It is separate from + \texttt{probe\_success}: \texttt{up} can be 1 while a probe fails.\\ +\bottomrule +\end{tabularx} + +\medskip +The panel queries, in the same order: +\begin{minted}[fontsize=\footnotesize,breaklines,breakanywhere]{text} +1 100 * (1 - avg(rate(node_cpu_seconds_total{job="node",mode="idle"}[2m]))) +2 node_memory_MemAvailable_bytes{job="node"} +3 100 * node_filesystem_avail_bytes{job="node",mountpoint="/",device="/dev/vda1"} + / node_filesystem_size_bytes{job="node",mountpoint="/",device="/dev/vda1"} +4 probe_success{job="https",instance="https://git.ssw590-08.me/user/login"} +5 probe_success{job="https",instance="https://ci.ssw590-08.me/login"} +6 probe_duration_seconds{job="https"} (legend: {{instance}}) ++ up (legend: {{job}} {{instance}}) +\end{minted} + +\medskip +All host panels describe the whole Droplet: Gitea, Jenkins, Caddy, and the +monitoring stack together. They cannot attribute CPU or memory to an +individual container. + +\srefig{dashboard-full.png}{1.0}{October 29, 2026, about 6:35 PM EDT --- the team +dashboard over the last 2 days, with all six required panels. Panel 5 shows the +controlled Jenkins outage at 4:09--4:13 PM on October 29; Gitea (panel 4) stays +UP.}{fig:sre-dashboard-full} + +\subsection{Normal Build Comparison} +Two normal runs of the existing pipeline on \texttt{main} were observed. Both +ran commit \texttt{3301e24} on the Jenkins controller's built-in node, inside +the \texttt{jenkins} container, as shown by ``Running on Jenkins'' in the +console log. + +\textbf{Run \#6, measured with \texttt{docker stats} before the dashboard +existed.} Run \#6 lasted 6.8 seconds, from 3:44:57 to 3:45:04 PM EDT on +October 28, 2026. \texttt{docker stats} and \texttt{free -b} were sampled every +4 seconds from 3:44:23 to 3:47:06 PM: + +\begin{tabularx}{\linewidth}{L{3.6cm}Y} +\toprule +\textbf{Window (EDT)} & \textbf{Observation}\\ \midrule +Before (3:44:23--3:44:28) & \texttt{jenkins} about 0.3\% CPU, 695.5~MiB; + host MemAvailable about 774~MB\\ +During (3:45:01--3:45:06) & \texttt{jenkins} 41.7\% then 12.1\% CPU; + \texttt{gitea} 49.7\% (checkout fetch and status update); + \texttt{jenkins} 699--700~MiB\\ +After (3:45:10 onward) & All containers below 1\% CPU; host MemAvailable + about 765~MB\\ +\bottomrule +\end{tabularx} + +\medskip +Two other short spikes, at 3:44:32 (\texttt{jenkins} 59\%) and 3:46:08 PM +(\texttt{gitea} 48\%), fall outside the build window. They are probably the +Multibranch job's periodic repository scan, but the data cannot attribute them. + +\textbf{Run \#7, on the dashboard.} Run \#7 started at 5:46:58 PM EDT on +October 28, 2026 and took 5.1 seconds. Jenkins displays this time as 9:46:58 +PM UTC. Figure~\ref{fig:sre-dashboard-build} shows the 15 minutes around it. + +\srefig{dashboard-build7.png}{1.0}{October 28, 2026, about 5:34--5:49 PM EDT +--- dashboard panels 1--3 and 6 around Jenkins \texttt{main} run \#7 +(5:46:58 PM, 5.1 s).}{fig:sre-dashboard-build} + +\textbf{Interpretation.} +\begin{itemize} + \item No distinct spike is visible at 5:47 PM. The build lasted 5.1 seconds, + shorter than the 30-second scrape interval, and panel 1 shows a 2-minute + rate. A 5-second burst of about 40\% on one container therefore adds only a + few percent to the 2-minute average, which falls within the normal + variation of 10--20\%. + \item The larger CPU rise to about 37\% between 5:42 and 5:45 PM, and the + drop in available memory at the same time, \emph{precede} the build. They may come + from Grafana restarting shortly before to load the new dashboard, but that + restart time was not recorded. The whole-host metrics cannot show which + process was responsible, so these changes are not attributed to Jenkins. + \item The \texttt{docker stats} sampling of run \#6 is the clearer evidence: + a normal build is a CPU burst of under 10 seconds with a negligible memory + effect (about 10~MB). The host has CPU and memory headroom for builds while + monitoring runs. + \item Root-filesystem space stayed flat at about 82\% available. Builds do + not consume measurable disk space. +\end{itemize} +\section{SLI, SLO, and Error Budget} +\label{sec:sre-slo} + +\subsection{Definitions and Worked Example} +Three terms are used in this chapter, following the Google SRE +Workbook~\cite{SREWorkbook}: +\begin{tabularx}{\linewidth}{L{2.2cm}Y} +\toprule +\textbf{Term} & \textbf{Meaning in this report}\\ \midrule +\gls{sli} & A measured indicator. Here: the share of scheduled HTTPS probes that + succeed for one service over a stated window, computed as + \texttt{100 * avg\_over\_time(probe\_success\{\ldots\}[window])}.\\ +\gls{slo} & An internal target for the \gls{sli}: at least 99\% of probes + succeed over a 24-hour lab window, evaluated separately for Gitea and + Jenkins. The 99\% figure is an instructional choice, not a production + promise.\\ +\gls{sla} & An agreement with a customer that may carry consequences if it is + missed. None exists for this lab, so no \gls{sla} applies.\\ +\gls{errorbudget} & The failure the \gls{slo} allows: 1\% of the scheduled probes + in the window.\\ +\bottomrule +\end{tabularx} + +\medskip +The difference in one line: the \gls{sli} is what was measured, the \gls{slo} +is what the team wants it to be, and an \gls{sla} would be a promise to someone +else with a penalty attached. + +\textbf{Worked example (hypothetical figures, not lab results).} These numbers +come from the assignment's illustration. At a 30-second probe interval, one +service is probed $24 \times 60 \times 2 = 2{,}880$ times a day. Suppose there +are no missing observations, Gitea succeeds 2,880 times with no failures, and +Jenkins succeeds 2,850 times and fails 30 times. + +\begin{tabularx}{\linewidth}{L{2.4cm}L{2.4cm}L{2.4cm}L{2.2cm}Y} +\toprule +\textbf{Service} & \textbf{Successes} & \textbf{Failures} & \textbf{SLI} & + \textbf{Meets 99\%?}\\ \midrule +Gitea & 2,880 & 0 & 100\% & Yes\\ +Jenkins & 2,850 & 30 & $100 \times 2850/2880 \approx 98.96\%$ & No\\ +\bottomrule +\end{tabularx} + +\medskip +\begin{itemize} + \item \textbf{Budget.} 1\% of 2,880 probes is $0.01 \times 2880 = 28.8$ + failed samples. With samples spread evenly, each stands for 30 seconds, so + the budget is $28.8 \times 30\,\text{s} = 864\,\text{s} = 14.4$ minutes of + failure a day. + \item \textbf{Jenkins overspends it.} 30 failures exceed the budget by + $30 - 28.8 = 1.2$ samples, about 0.6 minutes, so Jenkins has used about + 104\% of its budget and misses the target. + \item \textbf{Whole samples.} Failures are counted in whole samples, so at most + 28 failures meet the target: 28 failures give + $2852/2880 \approx 99.03\%$, while 29 give $2851/2880 \approx 98.99\%$. + \item \textbf{Gitea} has used none of its budget. +\end{itemize} +The measured exercise in Section~\ref{sec:sre-short-window} uses the same +method, but its 10-minute window cannot establish a 24-hour result. + +\subsection{Measured Short Window: Controlled Jenkins Outage} +\label{sec:sre-short-window} + +The following \gls{sli} figures are \textbf{measured results} from this deployment, not the +hypothetical figures above. Following the SLO approach of the Google SRE Workbook~\cite{SREWorkbook}, the window spans the controlled Jenkins outage in +Section~\ref{sec:sre-incident}: + +\begin{tabularx}{\linewidth}{L{4.4cm}Y} +\toprule +\textbf{Parameter} & \textbf{Value}\\ \midrule +Window & October 29, 2026, 4:06:00--4:16:00 PM EDT (20:06:00--20:16:00 UTC), 10 minutes\\ +Query evaluation time & 4:16:00 PM EDT (Unix time 1793304960)\\ +Scrape interval & 30 seconds, so about 20 samples are expected per service\\ +Series & \texttt{probe\_success\{job="https"\}}, one per \texttt{instance}\\ +\bottomrule +\end{tabularx} + +\medskip +The queries were sent to the Prometheus HTTP API from inside the Prometheus +container, with \texttt{time=2026-10-29T20:16:00Z}: +\begin{minted}[breaklines,breakanywhere]{text} +100 * avg_over_time(probe_success{job="https",instance="https://ci.ssw590-08.me/login"}[10m]) +count_over_time(probe_success{job="https",instance="https://ci.ssw590-08.me/login"}[10m]) +\end{minted} +The same two queries were repeated for +\nolinkurl{https://git.ssw590-08.me/user/login}. + +\begin{tabularx}{\linewidth}{L{2.4cm}L{2.2cm}L{2.2cm}L{2.4cm}Y} +\toprule +\textbf{Service} & \textbf{Received} & \textbf{Expected} & \textbf{Successful} & \textbf{Success (received samples)}\\ \midrule +Jenkins & 20 & $\approx$20 & 11 & 55.0\%\\ +Gitea & 20 & $\approx$20 & 20 & 100.0\%\\ +\bottomrule +\end{tabularx} + +\medskip +\textbf{Interpretation.} +\begin{itemize} + \item The Jenkins series contains nine consecutive failed samples, from + 4:09:12 to 4:13:12 PM, between successful samples at 4:08:42 and + 4:13:42 PM. This matches the deliberate stop at 4:08:54 PM and the restart at + 4:12:29 PM (Section~\ref{sec:sre-incident}). + \item Gitea stayed at 100\%. The outage was limited to Jenkins, and the probe + distinguishes the two services. + \item All 20 expected samples were received for each service, so coverage is + complete and no observation is missing. Had samples been missing, they would + be treated as unknown and excluded, never counted as successes. The samples + fall at 12 and 42 seconds past each minute. A window boundary placed + differently could therefore contain 19 or 21 samples. + \item This 10-minute percentage describes only the exercise window. It cannot + establish the 24-hour \gls{slo}. For illustration only: if these nine failures were + the only failures in a full day of 2,880 scheduled probes, Jenkins would + measure $2871/2880 \approx 99.69\%$. That would meet the 99\% target and use + $9/28.8 \approx 31\%$ of the daily \gls{errorbudget}. No full-day result is + claimed here. +\end{itemize} + +\srefig{sli-short-window.png}{0.9}{October 29, 2026 --- Grafana Explore instant +queries at 4:16:00 PM EDT: Jenkins 55\% over 20 samples, Gitea 100\% over 20 +samples.}{fig:sre-sli-window} +\section{Alerts and Runbooks} +\label{sec:sre-alerts} + +\subsection{Notification Destination} +\textbf{First attempt: email (failed).} An Email contact point was configured +with Gmail SMTP (\texttt{smtp.gmail.com:587}, STARTTLS, app password in +\texttt{grafana.secrets.env}). The contact-point test failed with: +\begin{minted}[breaklines,breakanywhere]{text} +failed to send email: dial tcp 172.253.122.109:587: i/o timeout +\end{minted} +The connection never reached Gmail. DigitalOcean blocks outbound SMTP ports +25, 465, and 587 on Droplets by default~\cite{DOSMTP}, so the problem was the +network path, not the credentials. Because email cannot leave this Droplet on +those ports, the \texttt{GF\_SMTP\_*} settings were removed from +\texttt{grafana.secrets.env} and the Gmail app password was revoked. + +\textbf{Final destination: Discord webhook.} The contact point +\texttt{team-alerts} uses Grafana's dedicated \emph{Discord} integration, +posting to the \texttt{\#general} channel of the team's private Discord server. +It sends over HTTPS (port 443), which the Droplet may use. Resolved messages +are enabled. The webhook URL is a secret: it is stored only in Grafana's +database, in the \texttt{monitoring\_\allowbreak grafana\_\allowbreak data} volume, and never in Git or +in screenshots. When rebuilding, a team member re-creates the contact point and +pastes the URL from Discord (\emph{Channel settings $\rightarrow$ Integrations +$\rightarrow$ Webhooks}). + +\srefig{contact-point-test.png}{0.85}{October 28, 2026, 8:19 PM EDT --- test +notification from contact point \texttt{team-alerts} received in Discord. This +verifies delivery only, not the rule queries or routing.}{fig:sre-cp-test} + +\srefig{contact-points.png}{0.75}{Grafana contact points: \texttt{team-alerts} +(Discord) is used by the alert rule. The built-in \texttt{empty} contact point is +attached only to the default notification policy and receives no team +alerts.}{fig:sre-contact-points} + +\subsection{Rule 1: \texttt{ServiceUnavailable}} +Both rules are Grafana-managed alerts evaluated by Grafana's built-in Alertmanager~\cite{GrafanaAlerting}; no separate Alertmanager is deployed. + +\begin{tabularx}{\linewidth}{L{3.6cm}Y} +\toprule +\textbf{Setting} & \textbf{Value}\\ \midrule +Type & Grafana-managed alert rule, uid \texttt{fg2n29o6c9a80d}, folder ``SSW 590''\\ +Owner & \texttt{samahk13} (label \texttt{owner}); backup \texttt{kholmes}\\ +Severity & \texttt{critical} (label \texttt{severity}); label \texttt{team=ssw590}\\ +Query (A) & \texttt{probe\_success\{job="https"\}}, instant, Prometheus data source\\ +Condition & Fires when the query \textbf{is below 1}, evaluated separately for + each \texttt{instance}, so Gitea and Jenkins alert independently\\ +Evaluation & Group \texttt{availability}, every 30 seconds\\ +Pending period & 1 minute: a probe must fail for at least 1 minute before the + rule fires\\ +No data & \textbf{Alerting}. A missing \texttt{probe\_success} series, for + example because Blackbox Exporter or Prometheus is down, raises the alert + instead of looking healthy\\ +Error or timeout & \textbf{Alerting}. A failed query is treated as a monitoring + failure that needs attention\\ +Routing & Simplified routing directly to contact point \texttt{team-alerts}\\ +Notification timing & Group wait 30 s, group interval 5 min, repeat interval 4 h\\ +Summary & \texttt{\{\{ \$labels.instance \}\} HTTPS probe failing for 1m}\\ +Runbook & \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md}{\texttt{monitoring/RUNBOOK.md}}, section ServiceUnavailable\\ +\bottomrule +\end{tabularx} + +\medskip +\textbf{Expected delay to notification.} After a service goes down, the next +probe fails within 30 seconds, and the next 30-second evaluation moves the rule +to Pending. It fires once the 1-minute pending period has passed. The group +wait adds 30 seconds before the message is sent. The worst case is therefore +about 2.5 minutes. The controlled outage measured 1 minute 46 seconds to Firing +and about 2--2.5 minutes to the Discord message +(Section~\ref{sec:sre-incident}). + +\textbf{Response.} The on-call owner follows \texttt{RUNBOOK.md}: +\begin{enumerate} + \item Acknowledge in Discord. + \item Check the scrape-health row to tell a monitoring failure from a service + failure. + \item Check the URL in a browser. + \item Inspect \texttt{docker ps -a} and the container logs. + \item Restore with \texttt{docker start} or \texttt{docker restart} on the + affected container. Never use \texttt{down -v}. + \item Confirm the Resolved message. + \item Run a Jenkins build, and check the Gitea login and webhook. +\end{enumerate} + +\srefig{rule-query.png}{0.8}{\texttt{ServiceUnavailable} rule: query +\texttt{probe\_success\{job="https"\}}, evaluation every 30 s, notifications to +\texttt{team-alerts}, runbook URL, and owner, severity, and team +labels.}{fig:sre-rule} + +\srefig{rule-instances.png}{0.75}{The rule's two alert instances, one per +probed URL. Both are Normal and both route to \texttt{team-alerts}.}{fig:sre-rule-instances} + +\textbf{Configuration error found during setup.} When the rule was first +created, its condition was \emph{``is above 0''} +(Figure~\ref{fig:sre-rule-misconfigured}). A healthy probe returns 1, so the +condition was true whenever the services were \emph{up}. The rule went to +Pending at 8:29:40 PM and to Firing at 8:30:40 PM on October 28 while both +services were healthy (\texttt{A=1}). The condition was corrected to +\emph{``is below 1''} at 8:37:10 PM, and both instances returned to Normal +(Figure~\ref{fig:sre-incident-history}). The rule's summary annotation had also +been set to the runbook URL; it was corrected after the incident exercise. + +\srefig{rule-misconfigured.png}{0.8}{The original, incorrect alert condition +(\emph{is above 0}), which fired while both services were healthy. It was +replaced by \emph{is below 1}.}{fig:sre-rule-misconfigured} + +\textbf{Firing, delivery, and resolution.} The controlled Jenkins outage on +October 29 drove this rule through a real cycle: +\begin{itemize} + \item Pending at 4:09:40 PM and Firing at 4:10:40 PM; + \item Discord Firing message at 4:11 PM; + \item Normal at 4:14:10 PM; + \item Discord Resolved message at 4:16 PM. +\end{itemize} +The full timeline is in Section~\ref{sec:sre-incident} and +Figures~\ref{fig:sre-incident-discord} and~\ref{fig:sre-incident-history}. + +\textbf{Versioned definition.} The final rules, including \texttt{HostDiskLow} +(Section~\ref{sec:sre-hostdisk}), are exported (\emph{Alert rule +$\rightarrow$ More $\rightarrow$ Export}, YAML) to +\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/grafana/alerting/alert-rules.yaml}{\texttt{monitoring/grafana/alerting/alert-rules.yaml}}. +The export contains the contact-point name only, not the webhook URL. + +\subsection{Rule 2: \texttt{HostDiskLow}} +\label{sec:sre-hostdisk} +The second Grafana-managed rule watches free space on the Droplet's root +filesystem. It uses the same \texttt{/dev/vda1} device that the dashboard's Disk +Usage panel reports, so the alert and the dashboard describe one filesystem and +are not mixed with container or pseudo filesystems. + +\begin{tabularx}{\linewidth}{L{3.6cm}Y} +\toprule +\textbf{Setting} & \textbf{Value}\\ \midrule +Type & Grafana-managed alert rule, uid \texttt{bg2tu8l6pb20wc}, folder + ``SSW 590'', rule group \texttt{infrastructure-alerts}\\ +Owner & \texttt{kholmes7} (label \texttt{owner})\\ +Severity & \texttt{warning} (label \texttt{severity}); label + \texttt{team=ssw590}\\ +Query (A) & Prometheus data source, relative range 10 minutes to now, instant: + \texttt{100 * node\_filesystem\_avail\_bytes\{mountpoint="/", fstype!="rootfs", device="/dev/vda1"\} + / node\_filesystem\_size\_bytes\{\ldots same selector\ldots\}}. The result is + the \emph{percentage of the filesystem that is free}.\\ +Condition (C) & Threshold on A: \textbf{is below 15}. The series returned has + \texttt{device="/dev/vda1"}, \texttt{fstype="ext4"}, + \texttt{instance="node-exporter:9100"}, \texttt{job="node"}, + \texttt{mountpoint="/"}\\ +Evaluation & Group \texttt{infrastructure-alerts}, every \textbf{30 seconds} + (Figure~\ref{fig:sre-disk-eval})\\ +Pending period & \textbf{5 minutes}: free space must stay below the threshold + for five minutes before the rule fires. Keep firing for 0 s + (Figure~\ref{fig:sre-disk-eval})\\ +No data and error & \textbf{Alerting} for both \emph{no data or all values + null} and \emph{execution error or timeout} + (Figure~\ref{fig:sre-disk-settings}). If \texttt{node-exporter} stops + reporting the root-filesystem series, or the query fails, the rule alerts + instead of looking healthy\\ +Notification & Contact point \texttt{team-alerts} (Discord; + Figure~\ref{fig:sre-disk-settings})\\ +Summary & \texttt{Root filesystem free space below 15\% on node-exporter:9100}\\ +Description & Investigate root filesystem capacity on the monitored Droplet. + Check disk usage and Docker logs before taking action. Do not delete Docker + volumes or container data as an emergency response.\\ +Runbook & \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/src/branch/main/monitoring/RUNBOOK.md}{\texttt{monitoring/RUNBOOK.md}}\\ +\bottomrule +\end{tabularx} + +\srefig{hostdisklow-rule.png}{0.8}{October 30, 2026, 6:06 PM EDT --- +\texttt{HostDiskLow} rule in folder \emph{SSW 590}, group +\texttt{infrastructure-alerts}. Query A computes the free-space percentage of +\texttt{/dev/vda1} mounted at \texttt{/} (about 81.72\% free), and threshold C +(\emph{alert condition}) is \emph{is below 15}. The instance is Normal.}{fig:sre-disk-rule} + +\srefig{hostdisklow-eval.png}{0.6}{October 30, 2026, 6:54 PM EDT --- evaluation +behavior of \texttt{HostDiskLow}: group \texttt{infrastructure-alerts} is +evaluated every 30 s, the pending period is 5 minutes, and keep firing for is +0 s.}{fig:sre-disk-eval} + +\srefig{hostdisklow-settings.png}{0.5}{October 30, 2026, 6:37 PM EDT --- +\texttt{HostDiskLow} saved settings: pending period 5 minutes, contact point +\texttt{team-alerts}, and \emph{Alerting} as the state for both no data and +execution error or timeout.}{fig:sre-disk-settings} + +\textbf{Why 15\%, and what the operator does.} At the time of the test, about +82\% of the root filesystem was free, so the rule was far from firing. The 15\% +threshold is the assignment's capacity limit: it warns while there is still room +to investigate before builds, image pulls, or monitoring data run out of space. +The on-call owner follows the rule's description and \texttt{RUNBOOK.md}: +\begin{enumerate} + \item Acknowledge the message in Discord. + \item Check disk usage on the Droplet and the Docker container logs + \emph{before} taking any action, to find what is consuming space. + \item Free space only from data that is known to be disposable. Do not delete + Docker volumes or container data as an emergency response, and never run + \texttt{docker compose down -v}. + \item Confirm that the Resolved message arrives and that free space is back + above 15\%. +\end{enumerate} + +\textbf{Safe test.} The disk was not filled. Instead, the rule's threshold was +temporarily raised from 15 to \textbf{85} (Figure~\ref{fig:sre-disk-85}). The +real free space was about 81.7\%, which is below 85, so the real query result +counted as ``low'' and the condition evaluated to true. After the 5-minute +pending period the rule fired and Discord delivered the message. The threshold +was then restored to 15, and the rule resolved. + +\textbf{First run and repeat.} An earlier run of this test went from Pending +(6:13:30 PM) to Alerting (6:16:00 PM) in only 2 minutes 30 seconds, shorter than +the required five minutes (Figure~\ref{fig:sre-disk-history}). The test was +therefore repeated with the 5-minute pending period confirmed in +Figure~\ref{fig:sre-disk-eval}. The repeat is the evidence below. + +\begin{tabularx}{\linewidth}{L{2.5cm}YL{3.3cm}} +\toprule +\textbf{Time (EDT)} & \textbf{Event} & \textbf{Evidence}\\ \midrule +6:06 PM & Threshold is \emph{below 15}; query returns about 81.72; rule Normal + & Figure~\ref{fig:sre-disk-rule}\\ +6:53:20 PM & Rule updated: threshold raised to 85 (\emph{Normal (Updated)}) + & Figure~\ref{fig:sre-disk-history-repeat}\\ +6:53:30 PM & \textbf{Pending}, \texttt{A=81.718367}, \texttt{C=1} + & Figure~\ref{fig:sre-disk-history-repeat}\\ +6:54 PM & Pending period confirmed as 5 minutes; evaluation every 30 s + & Figure~\ref{fig:sre-disk-eval}\\ +6:58:30 PM & \textbf{Alerting} after exactly 5 minutes pending, + \texttt{A=81.713006}, \texttt{C=1} + & Figure~\ref{fig:sre-disk-history-repeat}\\ +6:59 PM & \textbf{Firing} message in Discord, \texttt{A=81.71300563363819}, + \texttt{C=1} & Figure~\ref{fig:sre-disk-firing}\\ +6:59:30 PM & Rule updated: threshold restored to 15 (\emph{Normal (Updated)}) + & Figure~\ref{fig:sre-disk-history-repeat}\\ +7:04 PM & \textbf{Resolved} message in Discord & Figure~\ref{fig:sre-disk-resolved}\\ +\bottomrule +\end{tabularx} + +\medskip +\textbf{Result.} Pending to Alerting took exactly 5 minutes (6:53:30 PM to +6:58:30 PM), matching the configured pending period. The Firing message arrived +within the same minute as the Alerting state. The Resolved message arrived at +7:04 PM, about 4.5 minutes after the rule was restored at 6:59:30 PM. This is +consistent with Grafana sending the resolved update at the next notification +group interval (5 minutes for the other rule, +Section~\ref{sec:sre-alerts}), not with a delivery fault. The restoration was +therefore seen in Discord later than it happened in Grafana. + +\srefig{hostdisklow-history-repeat.png}{0.85}{October 30, 2026 --- state history +of \texttt{HostDiskLow} for the repeat run: Normal (Updated) at 6:53:20 PM, +Pending at 6:53:30 PM, Alerting at 6:58:30 PM, and Normal (Updated) at +6:59:30 PM.}{fig:sre-disk-history-repeat} + +\srefig{hostdisklow-threshold-85.png}{1.0}{October 30, 2026, 6:39 PM EDT --- +the alert condition editor showing the temporary threshold, \emph{when query is +below 85}. The saved rule was restored to 15 +(Figure~\ref{fig:sre-disk-normal}).}{fig:sre-disk-85} + +\srefig{hostdisklow-firing.png}{0.85}{October 30, 2026, 6:59 PM EDT --- Grafana +\emph{Firing} message for \texttt{HostDiskLow} in Discord. \texttt{A} is the +measured free-space percentage (81.71) and \texttt{C=1} means the temporary +threshold condition was true. The labels identify the device, filesystem, +owner, severity, and team, and the runbook link is included.}{fig:sre-disk-firing} + +\srefig{hostdisklow-resolved.png}{0.85}{October 30, 2026, 7:04 PM EDT --- +Grafana \emph{Resolved} message for \texttt{HostDiskLow}, received after the +threshold was restored. The value is \texttt{[no value]} and +\texttt{grafana\_state\_reason} is \texttt{Updated}, which Grafana reports when +a rule is edited: the instance was resolved because the rule changed, not +because the free-space value moved.}{fig:sre-disk-resolved} + +\srefig{disk-usage-panel.png}{0.85}{October 30, 2026, 6:20:15 PM EDT --- the +dashboard's Disk Usage panel reports 18.2\% used on \texttt{/dev/vda1} at +\texttt{/}. This agrees with the alert query's 81.72\% free (18.28\% used) to +within 0.1 percentage point, so the alert and the dashboard describe the same +filesystem.}{fig:sre-disk-usage} + +\srefig{hostdisklow-normal.png}{1.0}{October 30, 2026, 6:22 PM EDT --- restored +settings. The query returns 81.72035 for the \texttt{/dev/vda1} series, and the +alert condition is \emph{when query is below 15}, which evaluates to 0 +(\textbf{Normal}).}{fig:sre-disk-normal} + +\srefig{hostdisklow-history.png}{0.85}{October 30, 2026 --- state history of +\texttt{HostDiskLow} for the first run: Normal (Updated) at 6:13:20 PM, Pending +at 6:13:30 PM, Alerting at 6:16:00 PM, and Normal (Updated) at 6:17:00 PM and +6:37:30 PM. Pending to Alerting took 2 minutes 30 seconds, less than the +required five minutes, so the test was repeated.}{fig:sre-disk-history} + +\textbf{Final threshold and versioned definition.} The restored rule uses the +required 15\% threshold (Figure~\ref{fig:sre-disk-normal}). + +The final rules for both alerts were exported from Grafana as YAML and merged +into one file, which was committed to \texttt{main} through the protected +branch. After a fast-forward pull on the Droplet (\texttt{main} at +\texttt{b400750}), the pull added 75 lines to the earlier 64-line file, which +held only \texttt{ServiceUnavailable}. The added lines are the +\texttt{HostDiskLow} group (\texttt{infrastructure-alerts}). Checks run on the +Droplet on October 30, 2026: + +\begin{minted}[breaklines,breakanywhere,fontsize=\small]{text} +$ git log -1 --format='%H %cI' -- monitoring/grafana/alerting/alert-rules.yaml +a482ef9ef9aac7671960a25c1d54d4a59ba2f3de 2026-10-30T23:24:14+00:00 +$ grep -c HostDiskLow monitoring/grafana/alerting/alert-rules.yaml +1 +$ grep -ci "discord.com/api/webhooks" monitoring/grafana/alerting/alert-rules.yaml +0 +$ sha256sum monitoring/grafana/alerting/alert-rules.yaml +b87eb04d239d93ae2bd26017384c3cb92eb36a9abfb5267c7a51901c92406052 +\end{minted} + +\noindent The last commit that changed the file is +\texttt{a482ef9}, committed at 7:24:14 PM EDT (23:24:14 UTC). It replaced the +earlier version, whose last change was \texttt{2ab41bd} on October 29, 2026. The +committed file contains the rule titles, thresholds (below 1 and below 15), +pending periods (1 minute and 5 minutes), \emph{Alerting} no-data and error +states, and the contact-point name \texttt{team-alerts}, and it contains no +webhook URL. +\section{Incident and Recovery} +\label{sec:sre-incident} + +\subsection{Exercise Plan} +The exercise stopped only the Jenkins container for about three minutes, so +that the \texttt{ServiceUnavailable} alert (Section~\ref{sec:sre-alerts}) would +fire and notify. Gitea, Caddy, and the monitoring stack were left running, and +no volume was touched. The plan was: +\begin{enumerate} + \item Announce the window to the team and confirm that no Jenkins build is + running or queued. + \item Record each action with a UTC timestamp in + \nolinkurl{/root/Scrap-Web/monitoring/incident.log}. + \item Inject the outage with \texttt{docker stop jenkins}. + \item Acknowledge the alert, then restore with \texttt{docker start jenkins}. + The command was kept ready, and the operator (\texttt{samahk13}) was to + restore early if the exercise ran long or affected other work. + \item Verify that Jenkins, the pipeline, Gitea, its webhook, and the manual + build work after recovery. +\end{enumerate} + +\begin{minted}[breaklines,breakanywhere]{bash} +cd /root/Scrap-Web/monitoring +echo "$(date -Is) PRECHECK $(docker ps --filter name=jenkins --format '{{.Status}}')" | tee -a incident.log +echo "$(date -Is) INJECT docker stop jenkins" | tee -a incident.log +docker stop jenkins +echo "$(date -Is) ACK alert received in Discord, restoring" | tee -a incident.log +echo "$(date -Is) RESTORE docker start jenkins" | tee -a incident.log +docker start jenkins +echo "$(date -Is) RESOLVED notification received" | tee -a incident.log +\end{minted} + +\subsection{Correlated Timeline} +All times are October 29, 2026, Eastern Daylight Time (UTC$-$4). The sources are +the operator log (\texttt{incident.log}), the raw Prometheus samples of +\texttt{probe\_success} for \nolinkurl{https://ci.ssw590-08.me/login}, the Grafana +alert-rule state history, and the Discord channel that receives the +\texttt{team-alerts} \gls{contactpoint}. + +\begin{tabularx}{\linewidth}{L{1.9cm}YL{3.1cm}} +\toprule +\textbf{Time} & \textbf{Event} & \textbf{Source}\\ \midrule +4:08:42 & Last successful Jenkins probe before the outage & Prometheus sample\\ +4:08:50 & Precheck: \texttt{jenkins} container ``Up 5 days'' & \texttt{incident.log}\\ +\textbf{4:08:54} & \textbf{Injection:} \texttt{docker stop jenkins} & \texttt{incident.log}\\ +4:09:12 & First failing probe (\texttt{probe\_success}=0) & Prometheus sample\\ +4:09:40 & Rule state Normal $\rightarrow$ \textbf{Pending} & Grafana state history\\ +4:10:40 & Rule state Pending $\rightarrow$ \textbf{Firing} (after the 1-minute pending period) & Grafana state history\\ +4:11 & \textbf{Firing} notification for the Jenkins instance only & Discord (minute precision)\\ +4:11:31 & \textbf{Acknowledged} (``ack -- Samah, restoring'') & \texttt{incident.log}, Discord\\ +\textbf{4:12:29} & \textbf{Restore:} \texttt{docker start jenkins} & \texttt{incident.log}\\ +4:12:42--4:13:12 & Probes still fail while Jenkins starts up & Prometheus samples\\ +4:13:42 & First successful probe after the restart & Prometheus sample\\ +4:14:10 & Rule state Firing $\rightarrow$ \textbf{Normal} & Grafana state history\\ +4:16 & \textbf{Resolved} notification & Discord; logged 4:16:18 in \texttt{incident.log}\\ +\bottomrule +\end{tabularx} + +\srefig{incident-probes.png}{1.0}{October 29, 2026, 4:08--4:14 PM EDT --- +\texttt{probe\_success\{job="https"\}} in Grafana Explore: the Jenkins probe +(green) is 0 from 4:09:12 to 4:13:12 PM, while the Gitea probe (yellow) stays at +1.}{fig:sre-incident-probes} + +\srefig{incident-discord.png}{0.8}{October 29, 2026 --- Discord +\texttt{team-alerts} channel: Firing notification at 4:11 PM, acknowledgement at +4:11 PM, and Resolved notification at 4:16 PM. The \emph{summary} annotation +still showed the runbook URL; it was corrected afterwards.}{fig:sre-incident-discord} + +\srefig{incident-state-history.png}{0.8}{October 29, 2026 --- Grafana state +history of \texttt{ServiceUnavailable} for the Jenkins instance: Pending 4:09:40, +Firing 4:10:40, Normal 4:14:10 PM.}{fig:sre-incident-history} + +\subsection{Measured Detection and Restoration Times} + +\begin{tabularx}{\linewidth}{L{5.0cm}L{2.0cm}Y} +\toprule +\textbf{Interval (start $\rightarrow$ end event)} & \textbf{Measured} & \textbf{Comparison with settings}\\ \midrule +Injection $\rightarrow$ first failing probe & 18 s & Expected 0--30 s (30-second scrape interval)\\ +Injection $\rightarrow$ rule Pending & 46 s & Expected up to 60 s (scrape interval plus 30-second evaluation interval)\\ +Injection $\rightarrow$ rule Firing & 1 min 46 s & Pending plus the 1-minute pending period, exactly as configured\\ +Injection $\rightarrow$ acknowledgement & 2 min 37 s & The notification arrived after Firing plus the 30-second group wait; the operator acknowledged within the same minute\\ +Restart $\rightarrow$ first successful probe & 1 min 13 s & Jenkins start-up time; the probes at 4:12:42 and 4:13:12 still failed\\ +Injection $\rightarrow$ first successful probe & 4 min 48 s & Observed user-facing outage, at 30-second resolution\\ +Restart $\rightarrow$ rule Normal & 1 min 41 s & First successful probe plus the next evaluation (4:14:10)\\ +Rule Normal $\rightarrow$ Resolved notification & about 2 min & Held until the next group-interval send window (5 minutes after the 4:11 notification)\\ +\bottomrule +\end{tabularx} + +\medskip +Detection matched the configuration. The alert fired 1 minute 46 seconds after +the injection and notified within about 2--2.5 minutes, consistent with a +30-second scrape interval, a 30-second evaluation interval, a 1-minute pending +period, and a 30-second group wait. Restoration was limited by the Jenkins +start-up time rather than by the response. The Resolved message arrived about +two minutes after the rule returned to Normal, because Grafana sends further +notifications for an alert group only at the 5-minute group interval. + +\subsection{Recovery and Integration Checks} +\begin{itemize} + \item \textbf{Jenkins HTTPS:} \url{https://ci.ssw590-08.me/login} loaded and + accepted login after the restart. + \item \textbf{Pipeline:} \texttt{Scrap-Web/main} run \#8, started after the + restart, passed Checkout, Syntax check, and Test. + \item \textbf{Gitea and webhook:} \url{https://git.ssw590-08.me/} stayed + available throughout (100\% of probes, + Section~\ref{sec:sre-short-window}). A \emph{Test Delivery} of the Jenkins + webhook after recovery succeeded. + \item \textbf{Manual build (not validated):} the only Gitea Actions runner + (\texttt{mac-latex-runner-new}, on a team member's laptop) was offline at the + time of the first check, unrelated to the outage. Later, Gitea Actions run + \#18 (\texttt{manual.yml}) on \texttt{main} at commit \texttt{b4007504b7} + ran for 2 minutes 2 seconds and \textbf{failed} + (Figure~\ref{fig:sre-manual-build}). Errors occurred while trying to + validate the automated manual build, and the run's log page did not load, so + the cause was not identified. No PDF artifact was downloaded, and no + successful automated build is claimed here. The re-run of commit + \texttt{3301e24} was not completed. +\end{itemize} + +\srefig{manual-build-recovery.png}{0.8}{Gitea Actions run \#18 on \texttt{main} +(commit \texttt{b4007504b7}, merge of pull request \#23): failed after +2m2s.}{fig:sre-manual-build} + +\subsection{Unavailable Service Versus Failed Build} +This outage differs from the failed build demonstrated in +\ChapterRef{ContinuousIntegration} +(Section~\ref{sec:ci-failure}). There, Jenkins was running and reachable. It +executed the pipeline on commit \texttt{a5180ad}, the Test stage failed, and +Jenkins reported a \emph{failure} commit status that blocked the merge until +repair commit \texttt{84a44f0} passed. That is the CI system working correctly +and rejecting bad code. + +Here, no code changed and no pipeline ran. The Jenkins service itself was +unavailable: its HTTPS login page failed the \gls{probe}, no commit statuses could be +posted, and pull requests would have waited with a missing check. Monitoring, +not CI, detected it. The response was to restore the service, not to fix code. + +\subsection{Blameless Review} +\begin{description} + \item[Impact:] Jenkins' web interface and CI were unavailable for about + 5 minutes (4:08:54--4:13:42 PM EDT). No builds were running or queued, and no + work was lost. Gitea, Caddy, and the monitoring stack were unaffected. + \item[Cause:] A planned, deliberate \texttt{docker stop jenkins} as part of + this exercise. + \item[Detection and response:] The \texttt{ServiceUnavailable} rule fired + within its configured delay and notified Discord. The alert was acknowledged + the same minute and Jenkins was restored with one command. All recovery + checks passed, except the manual build, which waited for its runner. + \item[What went well:] Per-service alerting identified Jenkins alone; the + no-data and error policy was in place; the timeline could be reconstructed to + the second from Prometheus and the Grafana state history. + \item[Measurement gaps:] + \begin{itemize} + \item The monitoring stack runs on the same Droplet as Jenkins and Gitea. A + Droplet-wide outage would stop collection and notifications as well, so + it would go unreported. + \item Probes run from the Droplet itself, which does not prove + reachability from users' networks. + \item A successful login-page probe does not prove that builds or Git + operations work. + \item Discord shows notification times only to the minute. + \item The 5-minute group interval delayed the Resolved message by about + 2 minutes. + \item The rule's \emph{summary} annotation contained the runbook URL + instead of the summary text (Figure~\ref{fig:sre-incident-discord}). It + was corrected after the exercise to + \texttt{\{\{ \$labels.instance \}\} HTTPS probe failing for 1m}. + \item The state history (Figure~\ref{fig:sre-incident-history}) also shows + an earlier false alert on October 28 (Pending 8:29:40 PM, Firing + 8:30:40 PM, both services) while the probes were succeeding + (\texttt{A=1}). The threshold condition had been set up incorrectly + when the rule was created. It was corrected at 8:37:10 PM, before the + exercise. The lesson: a new rule should be checked with \emph{Preview} + against known-healthy data before it is relied on. + \item The manual-build runner depends on one laptop being online. + \end{itemize} +\end{description} + +\textbf{Prioritized improvements} (Gitea issues): +\begin{enumerate} + \item \textbf{Add an external uptime check independent of the Droplet} + (\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/20}{issue \#20}, owner \texttt{samahk13}). A free external HTTPS + monitor would detect a total Droplet outage that the on-Droplet stack cannot + report. + \item \textbf{Move the manual-build runner to an always-on host} + (\href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/issues/21}{issue \#21}, owner \texttt{kholmes}). This removes the dependency + on a laptop for PDF builds. +\end{enumerate} +\section{Manual Integration and Traceability} +\label{sec:sre-manual} + +\begin{itemize} + \item \textbf{Version and history:} this manual is Version 1.6. The + Document History has a 1.6 entry for this chapter. + \item \textbf{Hosts and Passwords tables:} the Hosts table + (Table~\ref{tab:devops-hosts}) gained rows for \texttt{metrics.ssw590-08.me} + (443, through Caddy), Grafana (\texttt{grafana:3000}, internal), Prometheus + (9090), Node Exporter (9100), and Blackbox Exporter (9115), the last three + private on the \texttt{monitoring} network, and records the two named + volumes. The Passwords table (Table~\ref{tab:devops-passwords}) gained hints + only: the Grafana \texttt{admin} password is kept in + \texttt{grafana.secrets.env} on the Droplet, and the Discord webhook URL is + stored in Grafana only. + \item \textbf{Glossary:} added \gls{sre}, \gls{sli}, \gls{sla}, + \gls{errorbudget}, \gls{probe}, and \gls{contactpoint}. + \item \textbf{Citations:} the Google SRE Workbook~\cite{SREWorkbook}, the + Prometheus, Grafana, Node Exporter, and Blackbox Exporter + documentation~\cite{PrometheusDocs,GrafanaDocs,NodeExporter,BlackboxExporter,GrafanaAlerting}, + and DigitalOcean's SMTP policy~\cite{DOSMTP}. + \item \textbf{AI and reuse attribution:} recorded in the AI Prompt Log + (Appendix~\ChapterRef{AIPromptLog}). The Compose file and Prometheus + configuration were adapted from the assignment's reference configuration; + the dashboard was written for this deployment. + \item \textbf{Reviewed source:} pull request + \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/pulls/22}{\#22} from + \texttt{feature/issue-18-monitoring} into \texttt{main}, merged as commit + \href{https://git.ssw590-08.me/SSW-590-08/Scrap-Web/commit/1bfa31acc0597567e5121a802966853a38a54f1b}{\texttt{1bfa31acc0597567e5121a802966853a38a54f1b}}. + All monitoring configuration links in this chapter point to \texttt{main} + at or after this commit. + \textbf{Process deviation:} the pull request passed the required Jenkins + check but was merged by \texttt{samahk13}, using repository-administrator + rights, before \texttt{kholmes} had approved it. This bypassed the + one-approval rule on \texttt{main}. Gitea cannot approve a pull request that + is already merged, so \texttt{kholmes} reviewed the merged change afterwards + and recorded the review as a comment on pull request \#22 + on October 29, 2026 at 6:43~PM EDT. To prevent a repeat, \emph{Enable push/merge + restrictions for administrators} should be turned on in the \texttt{main} + branch rule, so that the approval requirement also applies to + administrators. + \item \textbf{Automated PDF build (not validated):} no Gitea Actions run + exists for merge commit \texttt{1bfa31a}. A later run, \#18 on commit + \texttt{b4007504b7}, failed after 2 minutes 2 seconds + (Figure~\ref{fig:sre-manual-build}). There were errors while trying to + validate the automated build; the log could not be loaded and the cause was + not identified. No automated build result is claimed for this chapter. +\end{itemize} + +\fussy diff --git a/manual/figures/gitea-jenkins-deployment.png b/manual/figures/gitea-jenkins-deployment.png new file mode 100644 index 0000000..acbbc96 Binary files /dev/null and b/manual/figures/gitea-jenkins-deployment.png differ diff --git a/manual/figures/sre-deployment.dot b/manual/figures/sre-deployment.dot new file mode 100644 index 0000000..be4f288 --- /dev/null +++ b/manual/figures/sre-deployment.dot @@ -0,0 +1,49 @@ +digraph G { + graph [rankdir=TB, fontname="DejaVu Sans", fontsize=20, labelloc=t, pad=0.2, nodesep=0.3, ranksep=0.5, newrank=true, + label="Gitea, Jenkins, and Monitoring on One Droplet (147.182.179.191)"]; + node [fontname="DejaVu Sans", fontsize=14, shape=box, style="rounded,filled", color="#44546a", margin="0.12,0.07"]; + edge [fontname="DejaVu Sans", fontsize=12, color="#44546a"]; + + browser [label="Browser (HTTPS)", shape=component, style=filled, fillcolor="#e8f0fb"]; + discord [label="Discord\nwebhook, HTTPS 443", style="rounded,filled,dashed", fillcolor="#fdeee6"]; + + subgraph cluster_droplet { + label="Droplet"; fontsize=16; color="#6c7f99"; style="rounded"; margin=14; + + caddy [label="Caddy\n80 / 443, TLS", fillcolor="#fff3d6"]; + + subgraph cluster_giteanet { + label="network: gitea-net (existing)"; fontsize=14; style="rounded,dashed"; color="#6c7f99"; margin=10; + gitea [label="Gitea 1.26.4\n:3000", fillcolor="#e6f4e6"]; + jenkins [label="Jenkins\n:8080", fillcolor="#efe8fb"]; + grafana [label="Grafana 13.2.5\n:3000, no host port", fillcolor="#dbe9fb"]; + } + + subgraph cluster_mon { + label="network: monitoring (new, private)"; fontsize=14; style="rounded,dashed"; color="#6c7f99"; margin=10; + prom [label="Prometheus v3.13.5\n:9090, 7 d / 5 GiB", fillcolor="#dbe9fb"]; + nexp [label="Node Exporter v1.12.1\n:9100, read-only host root", fillcolor="#dbe9fb"]; + bbx [label="Blackbox Exporter v0.29.0\n:9115, module http_2xx", fillcolor="#dbe9fb"]; + } + + vgraf [label="volume\ngrafana_data", shape=cylinder, style=filled, fillcolor="#f2f2f2"]; + vprom [label="volume\nprometheus_data", shape=cylinder, style=filled, fillcolor="#f2f2f2"]; + } + + browser -> caddy [label="HTTPS 443"]; + caddy -> gitea [label="git. :3000"]; + caddy -> jenkins [label="ci. :8080"]; + caddy -> grafana [label="metrics. :3000"]; + gitea -> jenkins [label="webhook", style=dashed]; + grafana -> prom [label="queries"]; + prom -> nexp [label="scrape 30 s"]; + prom -> bbx [label="scrape 30 s"]; + bbx -> caddy [label="HTTPS probes via\npublic hostnames", style=dashed, constraint=false]; + grafana -> discord [label="alerts", style=dashed]; + grafana -> vgraf [dir=none, style=dotted]; + prom -> vprom [dir=none, style=dotted]; + + {rank=same; gitea; jenkins; grafana; discord} + {rank=same; prom; nexp; bbx} + {rank=same; vgraf; vprom} +} diff --git a/manual/figures/sre-deployment.png b/manual/figures/sre-deployment.png new file mode 100644 index 0000000..91e8926 Binary files /dev/null and b/manual/figures/sre-deployment.png differ