diff --git a/delivery/README.md b/delivery/README.md index f149097..276ca8b 100644 --- a/delivery/README.md +++ b/delivery/README.md @@ -38,6 +38,11 @@ and both recovery exercises require dated execution evidence. ## Attribution and preparation record +The 23 November [Java security update](../security/java/README.md) replaces the +trusted agent's Java runtime with pinned Temurin 21.0.13.1+2. Its current image +is `ssw590-delivery-agent:20261114-java21.0.13.1-2`; historical execution evidence +below retains the original versions actually used. + On 14 November 2026 Vincent asked Codex to review the assignment and begin preparation while he started Docker Desktop. Codex checked the repository's AI requirements and usage guide, read Chapter 6 and the example sources, diff --git a/delivery/agent/Dockerfile b/delivery/agent/Dockerfile index 9ee1c17..2b8cc71 100644 --- a/delivery/agent/Dockerfile +++ b/delivery/agent/Dockerfile @@ -1,8 +1,12 @@ +FROM eclipse-temurin:21.0.13.1_2-jdk-jammy@sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db AS patched_java FROM docker:29-cli@sha256:5a7af0dcb0e46c803efe9b45371dd21cb500e5b4453250394ac6f06d49b6e6f1 AS dockercli FROM aquasec/trivy:0.76.2@sha256:8f6bb947dbc528902e11f2f5be52f7b519f6a39d5d148f41166f2040499768fb AS scanner FROM jenkins/inbound-agent:jdk21@sha256:25a3704f7de4d3d0becc441f5683a227556658df1473865ee94c5232355678ab USER root +RUN rm -rf /opt/java/openjdk +COPY --from=patched_java /opt/java/openjdk /opt/java/openjdk +ENV JAVA_VERSION=jdk-21.0.13.1+2 RUN apt-get update \ && apt-get install -y --no-install-recommends python3 python3-venv git openssh-client ca-certificates curl \ && rm -rf /var/lib/apt/lists/* diff --git a/delivery/agent/compose.droplet.yaml b/delivery/agent/compose.droplet.yaml index 494a960..37fe863 100644 --- a/delivery/agent/compose.droplet.yaml +++ b/delivery/agent/compose.droplet.yaml @@ -1,7 +1,7 @@ name: ssw590-delivery services: agent: - image: ssw590-delivery-agent:20261114 + image: ssw590-delivery-agent:20261114-java21.0.13.1-2 restart: unless-stopped entrypoint: ["java", "-jar", "/usr/share/jenkins/agent.jar"] command: diff --git a/delivery/agent/compose.yaml b/delivery/agent/compose.yaml index c580e80..6becdfb 100644 --- a/delivery/agent/compose.yaml +++ b/delivery/agent/compose.yaml @@ -1,7 +1,7 @@ name: ssw590-delivery services: agent: - image: ssw590-delivery-agent:20261114 + image: ssw590-delivery-agent:20261114-java21.0.13.1-2 restart: "no" entrypoint: ["java", "-jar", "/usr/share/jenkins/agent.jar"] command: diff --git a/delivery/bootstrap/start-agent.ps1 b/delivery/bootstrap/start-agent.ps1 index 5bd6844..53e817a 100644 --- a/delivery/bootstrap/start-agent.ps1 +++ b/delivery/bootstrap/start-agent.ps1 @@ -18,7 +18,7 @@ $sshArguments = @('-i', $IdentityFile, '-o', 'IdentitiesOnly=yes', '-o', 'BatchM & ssh @sshArguments 'docker exec -u jenkins gitea-jenkins-1 cat /var/jenkins_home/delivery-bootstrap/agent-secret' | & docker run --rm -i --network none --user 0:0 --entrypoint sh ` --mount 'type=volume,source=ssw590-delivery-identity,target=/identity' ` - ssw590-delivery-agent:20261114 -c 'set -eu; umask 077; cat > /identity/agent-secret; test -s /identity/agent-secret; chown 1000:1000 /identity /identity/agent-secret; chmod 700 /identity; chmod 400 /identity/agent-secret' + ssw590-delivery-agent:20261114-java21.0.13.1-2 -c 'set -eu; umask 077; cat > /identity/agent-secret; test -s /identity/agent-secret; chown 1000:1000 /identity /identity/agent-secret; chmod 700 /identity; chmod 400 /identity/agent-secret' Push-Location $repoPath try { & docker compose -f delivery/agent/compose.yaml up -d diff --git a/delivery/bootstrap/start-droplet-agent.sh b/delivery/bootstrap/start-droplet-agent.sh index eae1fe1..6424fa2 100644 --- a/delivery/bootstrap/start-droplet-agent.sh +++ b/delivery/bootstrap/start-droplet-agent.sh @@ -10,14 +10,14 @@ DOCKER_GID=$(stat -c '%g' /var/run/docker.sock) # Numeric group only, not a credential. Keep it available for later Compose use. printf 'DOCKER_GID=%s\n' "$DOCKER_GID" > .env chmod 644 .env -docker image inspect ssw590-delivery-agent:20261114 >/dev/null +docker image inspect ssw590-delivery-agent:20261114-java21.0.13.1-2 >/dev/null docker compose -f compose.droplet.yaml config --quiet docker exec -u jenkins gitea-jenkins-1 test -s /var/jenkins_home/delivery-bootstrap/agent-secret docker volume create ssw590-delivery-identity >/dev/null docker exec -u jenkins gitea-jenkins-1 cat /var/jenkins_home/delivery-bootstrap/agent-secret | docker run --rm -i --network none --user 0:0 --entrypoint sh \ --mount type=volume,source=ssw590-delivery-identity,target=/identity \ - ssw590-delivery-agent:20261114 -c \ + ssw590-delivery-agent:20261114-java21.0.13.1-2 -c \ 'set -eu; umask 077; cat > /identity/agent-secret; test -s /identity/agent-secret; chown 1000:1000 /identity /identity/agent-secret; chmod 700 /identity; chmod 400 /identity/agent-secret' docker compose -f compose.droplet.yaml up -d --pull never agent=ssw590-delivery-agent-1 diff --git a/demo/DEMO_SCRIPT.md b/demo/DEMO_SCRIPT.md new file mode 100644 index 0000000..9bff116 --- /dev/null +++ b/demo/DEMO_SCRIPT.md @@ -0,0 +1,295 @@ +# TikZRefinery DevOps demonstration script + +Vincent Sun and Billy Ye | SSW 590 | December 2, 2026 + +Plan for **16 minutes of presentation and 4 minutes for questions or delays**. +Demonstrate an issue becoming a reviewed source change, a cloud build, automated +test results and a versioned application artifact. TikZRefinery supplies the C++/Qt +workload; Gitea, Jenkins and Grafana supply the workflow and operational view. + +This is a rehearsal plan. Before the final rehearsal, complete the reviewed +baseline Jenkins run and record the actual issue, change, job URL and build number. +The proposed provider naming refactor remains a candidate from the senior-project +handoff. Prepare its issue/comment and patch only after that baseline succeeds. +Zammad is a separate assignment. The unfinished VPN is outside this demonstration. + +## Preparation before the presentation + +Suggested roles: Vincent operates Git, Jenkins and the application; Billy explains +configuration and the tool comparison, and performs his own peer review. Agree on +the split together and rehearse the handovers. Approval must reflect Billy's actual +review, even during the timed demonstration. + +Complete these steps before calling the walkthrough ready: + +- Merge the reviewed security and baseline PRs, preserving both manual records. + Their current references are [security PR 30](https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/30) + and [baseline PR 31](https://git.yebilly.me/ssw590-group1/vpn-dns-gateway/pulls/31). +- Configure the separate artifact job to load `demo/Jenkinsfile` from reviewed + `main`. Run it once and verify SCM checkout, stage execution, JUnit display, + artifact archiving, a downloaded artifact and its provenance/checksum. The + existing PR check and the new artifact job are separate checks. +- After that baseline passes, agree on the live issue/change and rehearse the + feature-branch, review, merge and artifact-build sequence. Reserve the actual + demonstration commit/push for the assessed workflow. +- Preserve the original snapshot manifest. The current verifier deliberately + rejects any changed imported byte. An intentional product increment needs an + explicit, tested provenance record for its changed files; do not simply disable + verification or continue claiming all files are unchanged from the original. +- Record the real demo issue URL, branch, expected behavior, baseline build URL, + artifact job URL and last successful fallback build. These values are pending. +- Sign in to Gitea, Jenkins and Grafana privately before screen sharing. Check Git + authentication beforehand; pause sharing if a password/token prompt appears. +- Test HTTPS from the actual classroom network. The cloud workers avoid the + laptop-to-Droplet SSH connection that previously failed on school Wi-Fi. +- Ensure the trusted agent is online and idle, toolchain images are present and + disk/memory headroom is adequate. Avoid overlapping manual and delivery builds + on this single-CPU host. Use normal build settings; do not clear shared caches. +- Open the issue, source diff, PR, artifact job, Grafana dashboard and artifact + output tabs in advance. Use the same build number throughout the presentation. +- Keep a completed Jenkins run and its downloaded artifacts available as a + clearly labelled fallback. Earlier SSH rehearsals are not Jenkins results. + +The November 25 cloud rehearsal sampled approximately 146 seconds for native +build/tests, 75 seconds for reports, 10 seconds for architecture and 49 seconds for +the final package. These are sampled phase spans, not a measured Jenkins duration. +Measure the real job before accepting this timing plan. + +## Timed walkthrough + +| Time | Lead | Show and do | +| --- | --- | --- | +| 0:00-1:00 | Vincent | Introduce the application and the issue-to-artifact workflow. | +| 1:00-2:00 | Vincent | Select the existing demo issue and post the planned-change comment. | +| 2:00-4:00 | Both | Make the agreed meaningful change, inspect the diff, commit/push, then review and merge through Gitea. | +| 4:00-4:30 | Vincent | Trigger the artifact job from the reviewed main revision. | +| 4:30-6:45 | Billy | Explain configuration while the build runs. | +| 6:45-8:45 | Billy | Present the two-tool SWOT chart below. | +| 8:45-10:00 | Vincent | Show live stages and cloud CPU/memory observations. | +| 10:00-12:00 | Vincent | Show tests, compiled report, versioned image archive and source identity. | +| 12:00-13:15 | Billy | Open the source-generated architecture output for the bonus. | +| 13:15-14:30 | Vincent | Illustrate the desktop workload using the verified Windows package. | +| 14:30-16:00 | Both | Recap traceability, protections and measured limits. | +| 16:00-20:00 | Both | Questions and timing reserve. | + +### Opening and issue tracking + +**Vincent:** "TikZRefinery is a desktop editor for a supported subset of TikZ. We +use a frozen senior-project checkpoint as the application workload in our DevOps +repository. The application's upstream baseline is 0.1.4-alpha. Our delivery +artifact has a separate version, so we can trace a build without rewriting the +senior project's history." + +"We will follow one issue through a source change, Git review, cloud compilation, +automated tests and a packaged result. This lets us explain how the tools work +together using a real application." + +Open the agreed existing issue. Show its acceptance criterion and submit a short +comment describing the work about to happen and how it will be checked. Prepare +the final wording after baseline verification, using the actual agreed change. +Read its intent aloud rather than reading every field. + +### Source update and review + +Perform the rehearsed edit after the issue comment. Show the meaningful source +diff and explain the effect in one sentence. Run these checks from the demo +checkout, then stage only the agreed files: + +```powershell +git status --short --branch +git diff --check +git diff --stat +``` + +Use a commit message that describes the actual change and references the real +issue. Push the feature branch using the established Gitea login flow. Keep +credentials off screen. Show the pushed commit and PR. Billy reviews it, checks +the configured checks and submits his own decision. Vincent merges only after +the required approval and successful checks. + +**Billy:** "Gitea keeps the issue, source revision, review and merge connected. +The required PR checks protect main. Our artifact job then builds from that +reviewed main revision on the trusted cloud worker." + +If review or checks take longer than rehearsed, use the explanation/SWOT slots +while waiting. Keep their actual result visible; do not force a merge or present +an earlier green result as the current one. + +### Trigger and configuration explanation + +Open the separate artifact job and trigger its normal build after main contains +the reviewed increment. Show the build URL and checked-out revision. + +**Vincent:** "The job checks source provenance before compiling. It runs the +application tests, builds both LaTeX report editions, extracts diagrams from C++ +and packages an application image. A failed gate prevents a successful package." + +**Billy:** "We keep the orchestration in source control, so a reviewer can see +the build policy alongside the application. The job uses our existing trusted +agent. Docker access makes that worker privileged with respect to the host, so +unreviewed source does not belong on it." + +Use this configuration tour; explain purpose rather than reading syntax aloud: + +| File | Point to explain | +| --- | --- | +| `demo/Jenkinsfile` | Reviewed-main ancestry check, named stages, one concurrent build per job, timeout, JUnit and archived artifacts. | +| `demo/ci/run-cloud.sh` | Agent-volume path mapping; sequential work; offline, read-only build containers with CPU, RAM and PID limits. The native/report/architecture limit is 768 MiB RAM and 0.75 CPU. | +| `demo/toolchain.json` and `demo/ci/toolchain.Dockerfile` | Verified image IDs plus the compiler, Qt, LaTeX, Doxygen and Graphviz environment. Package inventory records what was installed. | +| `demo/ci/build-report.sh` | Disposable report build, bibliography/index/reference work and figure-index validation. Historical canonical PDFs remain preserved. | +| `demo/ci/package.py` and `demo/ci/application.Dockerfile` | Eight required passing suites, versioned image, real provider module, non-root runtime and bounded headless smoke check. | +| `.gitea/workflows/manual.yml` | The existing Actions job builds the cumulative manual on main using `latex-local` and uploads its PDF and diagnostics. Its pinned action revisions make dependencies explicit. | + +### Gitea Actions and Jenkins SWOT comparison + +Use this as the required chart. The tradeoffs describe this group's deployment; +they do not claim one tool is universally better. + +| SWOT | Gitea Actions in this project | Jenkins in this project | +| --- | --- | --- | +| Strengths | Workflow YAML, source history and PDF artifacts are reached from the same Gitea project. The existing manual build is a compact, repeatable use case. | Named stages, test reports and artifacts make the multi-stage Qt/report/package workflow visible. The group also has established release and approval workflows. | +| Weaknesses | The workflow depends on the runner label and compiler image being available. Our pinned legacy artifact action needs deliberate compatibility maintenance. | The controller, agents, plugins and Java runtime add maintenance work. The trusted worker's Docker access needs careful separation from unreviewed builds. | +| Opportunities | Reuse the manual workflow for other course documents and strengthen source/artifact traceability without adding another control service. | Extend the verified baseline into rehearsed issue-linked increments and retain test, load and provenance records for each release. | +| Threats | Runner outages or incompatible action changes can block builds. Overlapping heavy jobs compete for the same Droplet resources. | Runtime/plugin vulnerabilities, resource contention and an incorrectly scoped trusted job can affect the shared host. The team must keep review and runtime updates effective. | + +**Billy:** "We use Actions for the cumulative manual and Jenkins for the richer +application workflow. Both delegate work to separately operated workers, so +availability, maintenance and trust still belong to us. We compare them using the +work we actually operate." + +For the tool mechanics, see the official +[Gitea Actions overview](https://docs.gitea.com/usage/actions/overview/) and +[Jenkins Pipeline handbook](https://www.jenkins.io/doc/book/pipeline/). +The chart's deployment tradeoffs are the group's engineering assessment. + +### Cloud execution and load + +Open [the Group 1 SRE dashboard](https://metrics.yebilly.me/d/group1-sre/group-1-sre) +with a time window covering the build. Show Jenkins' executing stage alongside +the CPU and available-memory panels. If a panel refresh is too coarse, show the +job's per-phase load CSV as additional evidence. + +**Vincent:** "These processes run on The-Ocean, our 2 GiB, single-CPU Droplet. +The stage limits bound the build containers while Gitea, Jenkins, monitoring and +the earlier applications share the host. We observe CPU and available memory +before and during the build, and check available disk for the output." + +"The measurements describe the shared host. Other services and dashboard refresh +intervals affect what we see, so we do not attribute every change solely to this +job. We keep the actual build times and samples together." + +Do not promise a particular peak or a cold build. Use the real chart and CSV +values, units and timestamps; identify cache reuse if it affects the duration. + +### Tests and deployment artifact + +Open the current build's JUnit page. Explain the actual result. The baseline +registers eight suites covering the provider contract, core foundations, +rectangle/segment display, whole-element movement, rectangle resize, sidebar and +session history. Module loading and compatibility checks exercise the real +provider. These automated checks do not establish complete interactive acceptance. + +Open the compiled `TikZRefinery-report.pdf` from that build. Then show: + +- `TikZRefinery-1.0.N-linux-image.tar.gz`, using the actual Jenkins build number + in place of `N`, and the matching `ssw590-tikzrefinery:1.0.N` image tag. +- `delivery-info.json`: actual delivery version, upstream identity, downstream + commit, execution kind and image ID. +- `SHA256SUMS` and the package verification result. +- The same build's test and load records. + +**Vincent:** "Here major and minor identify the delivery line; the final component +is the Jenkins build number. This is the required major.minor.changelist format. +The metadata connects the artifact to its source and toolchain. SHA-256 checks +detect byte changes during transfer; they do not establish authenticity by +themselves." + +"The image is a deployable Linux desktop application package with a headless +runtime check. It is not a new website. The source is reviewed, the tests passed +and the saved image's manifest, configuration and layers were verified." + +Download the small metadata/report files live. Downloading the full image during +the timed presentation is optional; its download/checksum procedure must already +have passed in the baseline rehearsal. Cite the current build's real results. + +### Source architecture bonus + +Open the current `TikZRefinery-1.0.N-architecture.zip`, extract it and open +`html/index.html`. Show one generated provider relationship graph and explain the +interface/implementation relationship. The baseline rehearsal produced 25 source +graphs; quote the current build's actual count if the increment changes it. + +**Billy:** "Doxygen reads the C++ declarations and Graphviz draws the relationships. +These graphs are included with the build output. The separately authored TikZ/UML +report diagrams communicate the design; this output supplies source extraction." + +### Windows application illustration + +Use the verified portable Windows package to illustrate the workload. It is a +separate Windows baseline build, not the Linux artifact just produced by Jenkins. +Keep its `build-info.json` and source identity available if asked. + +Before presenting, copy `demo/tikzrefinery/code/examples/explicit-coordinates/boxes-initial.tex` +to an ignored rehearsal folder. Open that copy, move the right rectangle, resize a +corner and use session undo/redo. Show how the source pane follows a committed +edit. Save only the disposable copy if demonstrating Save. + +**Vincent:** "The application edits existing supported shapes. The rectangle +implementation is loaded as a separate module. Creation, folder browsing, plugin +updating and an integrated LaTeX/PDF viewer remain planned. Our DevOps workflow +builds and tests the implemented subset." + +### Closing and questions + +**Billy:** "We can trace the issue comment to a source change, reviewed main +revision, cloud run, automated result and versioned artifact. The configuration +and observed resource use explain how that workflow runs on our host." + +**Vincent:** "We preserve failed results and prior artifacts rather than rewriting +them. The next increments can use the same review and artifact trail. We have +four minutes for questions." + +Useful short answers: + +- **Why two CI tools?** Actions builds the group manual; Jenkins orchestrates the + application, report, tests and package with the group's established agent model. +- **Does the laptop need Docker during the presentation?** The build workers run + on the Droplet. The Windows GUI package runs natively on the laptop. +- **What happens when a test fails?** The job stops before successful packaging; + Jenkins retains available test results and diagnostics. Inspect that failure. +- **Is the Linux GUI running in the browser?** No. The container is checked + offscreen; the classroom GUI illustration uses the separate Windows package. +- **Why keep two versions?** Upstream identifies the imported application + checkpoint; the delivery version identifies an artifact produced by this job. + +## Recovery within the time limit + +| Observed problem | Response | +| --- | --- | +| Jenkins waits for the agent or another job | Show the queue/agent state, continue the explanation and retain the real timing. Do not start competing heavy jobs. | +| Current build fails | Show the failed stage and diagnostics. Use the identified previous successful Jenkins build to explain the later stages, clearly distinguishing both runs. | +| Classroom web request returns 403 | Check the actual source network against the approved web allowlist through the established maintenance procedure. Keep authentication and source restrictions enabled. | +| Network or artifact download stalls | Show the completed run and pre-downloaded fallback files with their matching build/version. Do not label them as this live run. | +| Live review takes longer than planned | Continue the configuration/SWOT explanation. Preserve the real review requirement and use the timing reserve. | +| Time reaches 16 minutes | Stop optional GUI detail and additional graphs. Preserve time for questions. | + +## Rubric evidence checklist + +| Assessed area | Visible evidence | +| --- | --- | +| Issue tracking | Existing issue and newly posted plan comment before the edit. | +| Version control | Meaningful diff, purpose-specific commit, push and real review/merge. | +| Pipeline trigger | Current artifact build URL and triggering action. | +| Build visibility | Native compilation, LaTeX and packaging stage progress. | +| Automated tests | Current JUnit pass/fail page. | +| Versioned deployment artifact | Current `1.0.N` image archive and provenance. | +| Two-tool SWOT | The complete four-row comparison above. | +| Configuration | Explain the Jenkins, workflow, Docker and build-script roles. | +| Demo quality | Rehearsed handovers, clear source identities and timing. | +| Cloud execution | Droplet worker, stage timing and real load observations. | +| Architecture bonus | Source-generated graph opened from the current artifact. | + +Assignment source: [Canvas Final Project Demo](https://sit.instructure.com/courses/188774/assignments/703597), +checked November 25, 2026. Canvas lists December 2 at 11:59 p.m.; the demonstration +itself has a 20-minute limit including questions. The script's speaker split and +minute-by-minute allocation are rehearsal choices. diff --git a/demo/README.md b/demo/README.md index 976f45b..619bae0 100644 --- a/demo/README.md +++ b/demo/README.md @@ -132,6 +132,12 @@ provider rename remains pending until that verification succeeds. ## Demonstration and ownership +Use [the timed demonstration script](DEMO_SCRIPT.md) for the proposed speaker +handoffs, configuration tour, two-tool SWOT and rubric evidence checklist. +Finalize its live issue/change and build references after the baseline Jenkins +run passes. The [November 25 web-access record](evidence/web-access-20261125.json) +captures the authorized home-source addition without publishing the address. + The professor's stated evaluation scope is the DevOps workflow. Zammad remains a separate assignment and the unfinished VPN is not represented as implemented. The final demonstration must show an existing issue and planned-change comment, diff --git a/demo/evidence/web-access-20261125.json b/demo/evidence/web-access-20261125.json new file mode 100644 index 0000000..6053cd6 --- /dev/null +++ b/demo/evidence/web-access-20261125.json @@ -0,0 +1,38 @@ +{ + "authorized_by": "Vincent Sun", + "event_date_eastern": "2026-11-25", + "applied_at_utc": "2026-11-26T04:22:34.316662+00:00", + "change": "Append current SSH connection IPv4 as /32 to existing CI_TEAM_IPS web allowlist", + "personal_address_values_recorded": false, + "existing_team_entries": 1, + "new_team_entries": 2, + "existing_entries_preserved": true, + "compose_change_scope": "caddy environment CI_TEAM_IPS only", + "recreated_service": "caddy", + "validation": "passed", + "proxy_image_and_persistent_mounts_preserved": true, + "other_running_container_ids_preserved": true, + "proxy_and_compose_source_files_unchanged": true, + "root_only_rollback_directory": "/root/ssw590-web-access-20261125", + "public_checks_at_utc": "2026-11-26T04:25:17.0999004Z", + "home_anonymous_https": { + "https://ci.yebilly.me/login": 200, + "https://ci.yebilly.me/api/json": 403, + "https://metrics.yebilly.me/login": 200, + "https://metrics.yebilly.me/api/user": 401, + "https://git.yebilly.me/": 200, + "https://app.yebilly.me/health": 200, + "https://staging.yebilly.me/health": 200 + }, + "unlisted_droplet_source_https": { + "https://ci.yebilly.me/login": 403, + "https://metrics.yebilly.me/login": 403 + }, + "chrome_observation": { + "jenkins": "Sign in to Jenkins form visible", + "grafana": "Existing authenticated session reached Grafana home" + }, + "account_permissions_or_credentials_changed": false, + "new_cloud_resources_or_plan_changes": false, + "source_commit_or_push_performed_by_codex": false +} diff --git a/deploy/README.md b/deploy/README.md index 40a28c7..6eae137 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -152,6 +152,10 @@ Remove it with `docker rm -f color-buttons-app`, delete the block, and reload. ## Jenkins CI (Assignment 6 / Instructor Manual Chapter 4) +The 23 November runtime-only [Java security update](../security/java/README.md) +retains Jenkins 2.580.1 and pins patched Temurin 21.0.13.1+2 in the Dockerfile. +Compose now selects `ssw590-jenkins:2.580.1-java21.0.13.1-2`. + `jenkins/Dockerfile` extends the official `jenkins/jenkins:2.580.1-lts-jdk21` image (digest pinned) with `python3` and the plugins in `jenkins/plugins.txt`. Builds run on the controller's single executor. Jenkins publishes no port: diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 17a4b73..d6c03cf 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -44,7 +44,7 @@ services: # Bounded so Gitea keeps memory on the 512 MB droplet. jenkins: build: ./jenkins - image: ssw590-jenkins:2.580.1 + image: ssw590-jenkins:2.580.1-java21.0.13.1-2 restart: unless-stopped environment: # The capacity test's 128 MiB heap ran builds, but the web UI hit "OutOfMemoryError: diff --git a/deploy/jenkins/Dockerfile b/deploy/jenkins/Dockerfile index fd4ea52..f14bfca 100644 --- a/deploy/jenkins/Dockerfile +++ b/deploy/jenkins/Dockerfile @@ -1,8 +1,12 @@ # Official Jenkins LTS image plus what the controller executor needs to run the # pipeline: python3 for the tests and the pinned plugin lockfile. +FROM eclipse-temurin:21.0.13.1_2-jdk-jammy@sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db AS patched_java FROM jenkins/jenkins:2.580.1-lts-jdk21@sha256:a660310e39ade10631f774bacd5219de767dfd08947ea5c32a739b5e5bb382c1 USER root +RUN rm -rf /opt/java/openjdk +COPY --from=patched_java /opt/java/openjdk /opt/java/openjdk +ENV JAVA_VERSION=jdk-21.0.13.1+2 RUN apt-get update \ && apt-get install -y --no-install-recommends python3 \ && rm -rf /var/lib/apt/lists/* diff --git a/manual/latex/devopsAIPromptLog.tex b/manual/latex/devopsAIPromptLog.tex index 9907205..e4138da 100644 --- a/manual/latex/devopsAIPromptLog.tex +++ b/manual/latex/devopsAIPromptLog.tex @@ -1107,6 +1107,53 @@ build and visual review. Passwords hints, credentials, permissions, earlier coursework, Billy/Claude records and shared services were preserved. Vincent handles final commits/pushes and submission; Billy reviews the final PR. +\section{Java Runtime Security Maintenance} +Date: November 23, 2026; Tool: OpenAI Codex; Human: Vincent Sun. +Vincent asked Codex to assess DigitalOcean's PHP and OpenJDK email alerts, +then explicitly authorized patching after loading his SSH key privately. +Codex read the alerts and verified the Java fix against Adoptium's advisory. +The earlier PHP inventory found no PHP. The local Docker VM and the Droplet +both lacked the AVX-512 VBMI feature required for the documented Java exploit; +this hardware qualification was distinguished from having a patched runtime. + +The controller used Temurin 21.0.12.1+1 before this update. +The delivery agent used Temurin 21.0.13+9. +Codex selected the official fixed Temurin 21.0.13.1+2 image, +verified its registry digest, retained original image and Compose checkpoints, +and built runtime-only replacement images under bounded resources. An initial +Adoptium assets endpoint returned 404; official GitHub release metadata and +Docker Hub provided the release and pinned image instead. Isolated version +checks passed before service replacement. Codex checked for unfinished or +queued Jenkins work, stopped the idle agent and recreated only the controller +and agent. The controller returned HTTP 200, the agent logged Connected, both +running containers reported the fixed Java build and their persistent mounts +matched the checkpoint. Existing private Gitea and Grafana checks passed. +A post-check initially assumed Java was process 1; Jenkins uses the normal +\texttt{tini} wrapper. Codex corrected the check to inspect the Java processes' +actual executables rather than treating the wrapper as a service failure. + +Codex updated source Dockerfiles, current image selectors, bootstrap references, +the current host inventory, maintenance runbook and this log. The live controller +build recipe was also patched with its original retained. Jobs, plugins, +permissions, credentials, release records, existing application containers and +other services were preserved. No release pipeline, human approval, commit or +push was performed. Root-only recovery checkpoints remain on the existing paid +Droplet; selected non-secret evidence remains in the ignored local build folder. +Local Zammad and its data remain stopped and unchanged; its future image review +is separate from this completed cloud runtime update. The full manual is rebuilt +with TinyTeX and affected pages are visually reviewed for this record. + +On November 25 Vincent requested separate branches after confirming the +Assignment 8 merge. Codex fetched and verified merge \texttt{6064cce}, +then prepared a separate worktree from that main on: +\begin{quote}\small +\path{codex/security-java-runtime} +\end{quote} +Only the Java source/runbook changes and their manual records +were placed here; Zammad and demo work remain in separate worktrees. +Original mixed changes were preserved and verified before separation. +No additional runtime operation, commit or push was performed. + \section{Frozen TikZRefinery Demo Baseline} Date: November 25, 2026; Tool: OpenAI Codex; Human: Vincent Sun. Vincent reported that the professor evaluates the DevOps workflow and supplied @@ -1183,3 +1230,75 @@ Shared manual sections were separated by task with a hash-verified local preservation copy. This branch starts at the verified merged main; historical rehearsal metadata retains its actual earlier parent. No new commit, push, issue or provider change was performed. Actual Jenkins verification remains pending. + +\section{Home Web Access and Final Demo Rehearsal} +Date: November 25, 2026 Eastern; Tool: OpenAI Codex; Human: Vincent Sun. +After Vincent pushed the security and demo baseline commits, Codex verified +PRs~30 and 31 in Gitea: their required checks passed and each still needed +one official approval. These checks were distinguished from the separately +pending artifact-only baseline Jenkins run. Vincent asked what could proceed +while Billy reviewed, then explicitly authorized web access first and the +demo script afterward. No approval, merge or final source increment was supplied +by Codex on behalf of a human. + +The initial checks found that Jenkins was healthy and that the saved and +running web allowlists matched. The current SSH source was absent. Codex +derived that source on the host without requesting or publishing the home address. +It preserved the existing team entry, added only the authorized IPv4 /32 in +the host's existing private environment file, and validated Caddy before +application. A comparison of resolved Compose configuration verified that only +the Caddy allowlist value changed. Root-only original environment and operation +logs remain on the Droplet for rollback. Caddy alone was recreated to receive +the environment; the image, persistent mounts, Caddyfile/Compose source hashes +and every other running container identity were verified unchanged. + +From the laptop, Jenkins and Grafana login URLs returned HTTPS 200, while +anonymous protected API requests returned 403 and 401 respectively. Gitea +and both pricing health endpoints returned 200. Requests from an unlisted +Droplet source still received 403 at both login URLs. Chrome displayed the +Jenkins sign-in form and Grafana's existing authenticated home. The selected +record in \path{demo/evidence/web-access-20261125.json} excludes address values, +environment contents and credentials. Hosts records the network-access change; +service accounts, application permissions and password hints were unchanged. +This used the existing paid Droplet, with no new cloud plan, instance or port. + +Codex reread the live Canvas final-demo assignment, which allocates 20 minutes +including questions, and the frozen senior-project handoff. Using the writing +skill while honoring the repository destination, it prepared +\path{demo/DEMO_SCRIPT.md}: a proposed 16-minute walkthrough with four minutes +for questions/delays, suggested speaker handovers, configuration explanations, +a Gitea Actions/Jenkins SWOT chart and an evidence checklist. Tool mechanics +were checked against the official Gitea Actions overview and Jenkins Pipeline +handbook; deployment tradeoffs are identified as engineering assessment. +The Windows illustration is distinguished from the Linux output, authored +diagrams from source extraction, and shared-host observations from exclusive +job attribution. + +The script keeps the real baseline Jenkins run, final issue/change and artifact +references as readiness dependencies. The existing strict snapshot verifier +must continue preserving original provenance when a later intentional product +increment is prepared. No provider rename, issue/comment publication, new job, +pipeline execution, commit or push was performed in this access/script task. +The original senior checkout and frozen imported files remain unchanged. +The complete group manual is rebuilt with TinyTeX and affected pages are +visually reviewed; only reproducible current-task scratch is removed. + + +\section{Baseline PR Conflict Resolution} +Date: November 25, 2026 Eastern; Tool: OpenAI Codex; Human: Vincent Sun. +Vincent reported Billy's approvals and his merge of the security PR, then +asked Codex to inspect the baseline PR and prepare the commands to push its +resolution with a fresh login prompt. Chrome showed approval and passing +checks on PR~31, with conflicts in the AI log and Document History. A fetch +verified security PR~30 at merged main \texttt{8e06815}. Both branches had +added independent entries at the same positions; no application or pipeline +code conflicted. + +Codex preserved the six uncommitted access/script files before starting a +local merge of that main into the baseline branch. It retained both original +task records, both history entries, the security host inventory and the later +web-access/script work. The complete manual is rebuilt with TinyTeX and +affected pages are visually reviewed. Frozen upstream bytes are checked again; +the real artifact-only Jenkins baseline remains pending the reviewed merge. +The merge is left ready for Vincent to commit and push. Codex does not commit, +push, merge the remote PR, change approvals or run a pipeline in this task. diff --git a/manual/latex/devopsDocumentHistory.tex b/manual/latex/devopsDocumentHistory.tex index e0933ad..5efaf73 100644 --- a/manual/latex/devopsDocumentHistory.tex +++ b/manual/latex/devopsDocumentHistory.tex @@ -12,7 +12,10 @@ link each entry to the changed chapter, table, figure, or controlled artifact. \multicolumn{4}{l}{\small\itshape Document Update History (continued)}\\ \toprule \textbf{Date / Version} & \textbf{Author Initials} & \textbf{Change} & \textbf{Changed At}\\ \midrule \endhead \bottomrule \endlastfoot +November 25, 2026 / 6.4 baseline integration & VS, CDX & Resolved the baseline PR conflicts against merged security PR~30, preserving both original AI and history records and the later access/rehearsal work. Verified the frozen snapshot and rebuilt the complete manual. Vincent retains commit/push and remote merge authority; the actual artifact-only Jenkins run remains pending. & \hyperref[Chapter:AIPromptLog]{AI log}\\ +November 25, 2026 / 6.4 demo rehearsal & VS, CDX & Restored authorized home web access to Jenkins and Grafana with one /32 addition to the existing allowlist. Validated configuration, recreated only Caddy and verified authentication, denied-source behavior and healthy existing sites. Prepared a timed final-demo script, two-tool SWOT, configuration explanations and rubric checklist; actual baseline Jenkins verification and the subsequent issue-linked source increment remain pending review/merge. & \hyperref[Chapter:HostsPasswords]{Hosts}, \hyperref[Chapter:AIPromptLog]{AI log}\\ November 25, 2026 / 7.0 demo preparation & VS, CDX & Imported Vincent's frozen TikZRefinery 0.1.4-alpha checkpoint with byte-level provenance. Verified Windows and isolated cloud builds, eight suites on each platform, portable Windows module loading, both report editions, source-extracted diagrams and a versioned Linux image. Prepared an artifact-only Jenkins pipeline; actual Jenkins checkout/archive verification and the separate issue-linked provider rename remain pending. Existing assignments and live services are retained. & \hyperref[Chapter:AIPromptLog]{AI log}\\ +November 23, 2026 / 7.0 maintenance & VS, CDX & At Vincent's request, patched the live Jenkins controller and trusted delivery agent to Temurin 21.0.13.1+2 for CVE-2026-114938. Retained application versions, plugins, persistent mounts and recovery images; verified controller HTTP and agent reconnection. Updated future build recipes, image selectors and current host inventory. Local Zammad remains stopped; Assignment 9 remains incomplete. & \hyperref[Chapter:HostsPasswords]{Hosts}, \hyperref[Chapter:AIPromptLog]{AI log}\\ November 15, 2026 / 6.4 & VS, BY, CDX & Verified Billy's PR~\#27 review and Vincent's merge; completed human-approved production rollback (build 8), blocked staging fault (9), and original-configuration recovery with changed=0 (10). Preserved build 7's pre-deployment runner error, measured HTTPS interruptions and monitoring sampling limits. Added original CSVs, hashes, runtime state, timelines, source/access links and final evidence; created issue~\#28 with Vincent's approval during finalization. Updated the Hosts table and architecture to production v1/staging v2; Passwords hints and permissions are unchanged. Prepared the complete manual for submission review. & \ChapterRef{SecureDelivery}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\ November 15, 2026 / 6.3 & BY, VS, CDX & Recorded PR~\#26's review/merge and successful Jenkins v1/v2 releases 5/6, zero-change reruns, actual vsun1 approvals and identical per-release staging/production digests. Saved the four real selectors for review. Applied the reviewed production probe/panel after healthy v1, verified live targets/Grafana and preserved one HTTP 502 sample during v2 replacement. Updated both-app inventory and architecture; prepared a staging-only fault patch and reviewed-history/revert procedure for the still-pending recovery exercises. Passwords hints and access scopes are unchanged. & \ChapterRef{SecureDelivery}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\ November 15, 2026 / 6.2 & VS, CDX & Verified PR~\#25's review/merge and ran pricing build 4: scans/publication and initial staging checks passed; the unchanged rerun blocked at the three-second Docker health deadline. Tested ten seconds under identical limits in an isolated temporary container: eight checks passed, then the container was removed. Prepared the health correction and separate v2 source/test change for one review preserving both commits. Updated staging inventory, diagram and actual evidence; Passwords hints are unchanged. No production approval or completed release is claimed. & \ChapterRef{SecureDelivery}, \ChapterRef{HostsPasswords}, \ChapterRef{AIPromptLog}\\ diff --git a/manual/latex/devopsHostsPasswords.tex b/manual/latex/devopsHostsPasswords.tex index 5168ca1..504cc3b 100644 --- a/manual/latex/devopsHostsPasswords.tex +++ b/manual/latex/devopsHostsPasswords.tex @@ -36,6 +36,16 @@ staging-only fault; build 10 restored staging v2 with changed=0. Final productio is v1 and staging v2. The production probe and Grafana panel were added after healthy production. No credential or permission changed during these runs. +On November 25, 2026, Vincent authorized adding his current home IPv4 source +as a single /32 to the existing web allowlist for Jenkins and Grafana. +The former team entry and campus rules were preserved. Only Caddy was +recreated to receive the updated environment; its image, certificate/config +volumes and all other running container identities were retained. The address +and rollback environment remain outside Git on the authorized host. +HTTPS login pages were reachable from the laptop; anonymous protected +requests still required authentication, and an unlisted source received 403. +Service accounts, application permissions and credential hints are unchanged. + \section{Hosts} \small \begin{tabularx}{\linewidth}{@{}L{3.3cm}Y@{}} @@ -47,12 +57,15 @@ healthy production. No credential or permission changed during these runs. \bottomrule \endlastfoot Role & Gitea work hub (Gitea 1.27.3 behind Caddy 2.11.4 TLS proxy); since 22 Oct 2026 also the Jenkins 2.580.1 LTS controller, which runs the CI builds; +its Java runtime was patched to Temurin 21.0.13.1+2 on 23 Nov 2026; since 28 Oct 2026 also the monitoring stack (Prometheus 3.15.1, Grafana OSS 13.2.5, Node Exporter 1.12.1, Blackbox Exporter 0.29.1). The Assignment 3 Color Buttons app (29 Sep 2026) is retired: container stopped with restart policy \texttt{no}; its Caddy route remains\\ Delivery agent & Legacy node \texttt{ssw590-vince-delivery}, label \texttt{delivery-trusted}, one exclusive executor; image -\texttt{ssw590-delivery-agent:20261114}. RAM / RAM+swap: 512 / 768 MiB, +\texttt{ssw590-delivery-agent:}\allowbreak +\texttt{20261114-java21.0.13.1-2}, with patched Temurin 21.0.13.1+2 +(23 Nov 2026). RAM / RAM+swap: 512 / 768 MiB, 0.5 CPU; separate pinned BuildKit: 256 / 384 MiB, 0.5 CPU. Private WebSocket to Jenkins and SSH through Docker host gateway with pinned public-IP host-key alias. Docker socket control grants host administration. diff --git a/security/java/Dockerfile b/security/java/Dockerfile new file mode 100644 index 0000000..6288cf9 --- /dev/null +++ b/security/java/Dockerfile @@ -0,0 +1,12 @@ +# Runtime-only update for an existing Jenkins controller or trusted agent image. +# BASE_IMAGE must be a local rollback tag verified against the running image ID. +# The final image retains the application's version, tools, plugins and user. +ARG BASE_IMAGE +FROM eclipse-temurin:21.0.13.1_2-jdk-jammy@sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db AS patched_java +FROM ${BASE_IMAGE} +USER root +RUN rm -rf /opt/java/openjdk +COPY --from=patched_java /opt/java/openjdk /opt/java/openjdk +ENV JAVA_VERSION=jdk-21.0.13.1+2 +USER jenkins +RUN java -version diff --git a/security/java/README.md b/security/java/README.md new file mode 100644 index 0000000..6138a28 --- /dev/null +++ b/security/java/README.md @@ -0,0 +1,99 @@ +# Java runtime security maintenance - 23 November 2026 + +Vincent authorized patching CVE-2026-114938 after reviewing DigitalOcean's +OpenJDK alert. This is operational maintenance, separate from the pending +Assignment 9 Zammad setup. No commits or pushes were requested. + +The running Jenkins controller used Temurin 21.0.12.1+1 and its trusted delivery +agent used 21.0.13+9. Both were replaced with **Temurin 21.0.13.1+2**, which +[Adoptium identifies as fixed](https://adoptium.net/news/2026/11/temurin-november-2026-cspu-java4shell). +The Droplet's exposed CPU flags did not include AVX-512 VBMI; that is a required +hardware condition for the documented exploit. Updating the runtimes avoids +depending on that hardware limitation. + +| Service | Updated image | Actual local image ID | +| --- | --- | --- | +| Jenkins controller | `ssw590-jenkins:2.580.1-java21.0.13.1-2` | `05067cf69fd76a98de8d434e7af9782cb9f979e0db3301760038da557cd5927b` | +| Trusted delivery agent | `ssw590-delivery-agent:20261114-java21.0.13.1-2` | `8d6302db4598887010c11ee7de0f87b0f62ab92e53bf7ec1e81fbab98d9778a7` | + +The official `eclipse-temurin:21.0.13.1_2-jdk-jammy` runtime stage is pinned to +index digest `sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db`. +Its Linux/amd64 manifest was +`sha256:4e38bcd64a552586921cdd011831cabc0d56c4f7c950aa460c0b9e03237871ed`. +Only `/opt/java/openjdk` and its descriptive `JAVA_VERSION` environment value +were replaced in the existing application images. Jenkins remains 2.580.1; +plugins, tools, identity and workspace were retained. No production release, +approval, dependency upgrade or database migration was performed. + +## Procedure and verification + +`patch-existing.py` is deliberately specific to The-Ocean's two existing Compose +projects. Review its paths before reuse. Its `prepare` action captures selected +non-secret metadata, saves Compose copies, refuses unfinished/queued Jenkins +work, pulls the pinned runtime and builds both images sequentially. Builds used +512 MiB and 0.5 CPU limits. Isolated smoke containers have no network or data +mounts and a read-only filesystem. The legacy builder warning was retained; +this choice permits explicit build-container limits on this small host. + +The `apply` action checks the checkpoint again, changes only the two image +selectors, stops the idle agent, recreates the controller, waits for its login +page, and recreates the agent. It verifies the fixed runtime, running state, +absence of OOM kills, and identical persistent mounts. It does not automatically +roll back after an error; inspect the checkpoint and service state first. + +Executed verification confirmed Jenkins login HTTP 200 and the agent's +`Connected` message. Gitea and Grafana private HTTP checks passed. The live +controller Dockerfile was also updated to retain the fix on future builds; +its original was preserved. The pricing containers, proxy, monitoring and +manual runner were not recreated. No full release pipeline was triggered. + +Selected-field evidence is retained in ignored +`build/evidence/java-patch-20261123/`. On the Droplet, checkpoints and logs remain +in root-only `/root/ssw590-java-patch-20261123/`. Credentials and full Docker +inspect output are excluded. No additional cloud resource or plan was created; +this used the existing paid Droplet, with transient CPU, storage and network use. + +## Recovery + +The original images retain the local tags +`ssw590-java-rollback:jenkins-20261123` and +`ssw590-java-rollback:agent-20261123` as recovery checkpoints. They contain the +old runtime; do not select them during normal operation. + +If the new runtime causes a verified operational regression, first stop or drain +Jenkins work. On the authorized host, restore the corresponding saved Compose +file from the root-only checkpoint directory to its original path: + +- `jenkins-compose.before` -> `/root/gitea/docker-compose.yml` +- `agent-compose.before` -> `/opt/ssw590-delivery-agent/compose.droplet.yaml` + +Validate with `docker compose -f config --quiet`, then recreate +only that service using `up -d --no-deps --pull never ` from its project +directory. Original image tags remain present. Preserve volumes and identities; +never use `down -v`. Restoring the old controller Dockerfile is needed only if +its future build recipe must also be reverted. If running the old Java build on +affected hardware, the vendor's interim mitigation is +`-XX:-UseBASE64Intrinsics` followed by a service restart. + +Retain the checkpoint images and files until the group has reviewed the update. +Do not prune shared Docker images, build caches or volumes to clean up this task. + +## Scope limits + +Local Zammad remains stopped and unchanged. Its Elasticsearch Java build also +predates the fix, but the laptop's Docker VM was verified to lack AVX-512 VBMI. +Review its official patched image before the next local setup session. +The earlier PHP inventory found no PHP; this Java patch does not install PHP. +The NGINX alert and its separately recorded HTTP/2 assessment remain separate. + +For a future full source rebuild, the controller and agent Dockerfiles also +copy the same pinned fixed Java stage. Build the agent from `delivery/`: + +```sh +docker build -f agent/Dockerfile -t ssw590-delivery-agent:20261114-java21.0.13.1-2 . +``` + +Build the controller using its Compose project. Full source rebuild image IDs +will differ from the runtime-only maintenance images above; verify Java again. +The stopped laptop fallback requires the patched agent image to be built or +loaded before it can be used. Never start it alongside the active cloud agent. diff --git a/security/java/patch-existing.py b/security/java/patch-existing.py new file mode 100644 index 0000000..a1ee91e --- /dev/null +++ b/security/java/patch-existing.py @@ -0,0 +1,160 @@ +"""Targeted The-Ocean Java update; run as root after reviewing this file. + +prepare builds and smoke-tests images without restarting services. apply +requires those prepared images and refuses active/queued Jenkins work. +Rollback copies and selected-field evidence remain outside the repository. +""" +import argparse +import json +import os +from pathlib import Path +import shutil +import subprocess +import time +import xml.etree.ElementTree as ET + +ROOT = Path('/root/ssw590-java-patch-20261123') +JAVA_IMAGE = ('eclipse-temurin:21.0.13.1_2-jdk-jammy@' + 'sha256:4b3d0998ee65462bd86ff060c87119b3575294cb3d0927372afa6f3708b0c8db') +SERVICES = [ + dict(name='gitea-jenkins-1', service='jenkins', + directory='/root/gitea', compose='docker-compose.yml', + image='ssw590-jenkins:2.580.1-java21.0.13.1-2'), + dict(name='ssw590-delivery-agent-1', service='agent', + directory='/opt/ssw590-delivery-agent', compose='compose.droplet.yaml', + image='ssw590-delivery-agent:20261114-java21.0.13.1-2'), +] + + +def run(*args, capture=True, **kwargs): + result = subprocess.run(args, check=True, text=True, + stdout=subprocess.PIPE if capture else None, + stderr=subprocess.STDOUT, **kwargs) + return result.stdout.strip() if capture else '' + + +def inspect(name): + # Never serialize full inspect output: it can contain secret environment values. + obj = json.loads(run('docker', 'inspect', name))[0] + return dict(name=name, image=obj['Image'], reference=obj['Config']['Image'], + running=obj['State']['Running'], oom=obj['State']['OOMKilled'], + restarts=obj['RestartCount'], + mounts=[dict(type=m['Type'], source=m['Source'], + destination=m['Destination'], rw=m['RW']) + for m in obj['Mounts']]) + + +def assert_idle(): + home = Path(run('docker', 'volume', 'inspect', '-f', '{{.Mountpoint}}', + 'gitea_jenkins-home')) + active = [] + for path in (home / 'jobs').rglob('build.xml'): + tree = ET.parse(path).getroot() + if tree.find('result') is None: + active.append(str(path.relative_to(home))) + assert not active, 'Refusing restart: unfinished Jenkins builds: ' + repr(active) + queue = home / 'queue.xml' + if queue.exists(): + tree = ET.parse(queue).getroot() + assert not list(tree.iter('item')), 'Refusing restart: Jenkins queue is nonempty' + for items in tree.iter('items'): + assert not list(items), 'Refusing restart: Jenkins queue contains work' + + +def smoke(image): + result = run('docker', 'run', '--rm', '--pull', 'never', '--network', 'none', + '--read-only', '--cap-drop', 'ALL', '--security-opt', + 'no-new-privileges', '--entrypoint', 'java', image, '-version') + assert '21.0.13.1' in result and '+2' in result, result + return result + + +def compose(spec, *args): + return run('docker', 'compose', '-f', spec['compose'], *args, + cwd=spec['directory']) + + +def prepare(): + ROOT.mkdir(mode=0o700, exist_ok=True) + os.chmod(ROOT, 0o700) + before_path = ROOT / 'before.json' + if before_path.exists(): + before = json.loads(before_path.read_text()) + assert [inspect(s['name'])['image'] for s in SERVICES] == [ + s['image'] for s in before], 'Current images differ from original checkpoint' + else: + before = [inspect(s['name']) for s in SERVICES] + before_path.write_text(json.dumps(before, indent=2) + '\n') + for spec in SERVICES: + shutil.copy2(Path(spec['directory']) / spec['compose'], + ROOT / (spec['service'] + '-compose.before')) + assert_idle() + run('docker', 'pull', JAVA_IMAGE, capture=False) + smoke(JAVA_IMAGE) + env = dict(os.environ, DOCKER_BUILDKIT='0') + # No application state, Compose backup or evidence enters the build context. + context = ROOT / 'empty-context' + context.mkdir(exist_ok=True) + built = [] + for spec, old in zip(SERVICES, before): + rollback = 'ssw590-java-rollback:' + spec['service'] + '-20261123' + run('docker', 'tag', old['image'], rollback) + run('docker', 'build', '--pull=false', '--memory', '512m', + '--cpu-quota', '50000', '--build-arg', 'BASE_IMAGE=' + rollback, + '-t', spec['image'], '-f', str(ROOT / 'Dockerfile'), str(context), + env=env, capture=False) + built.append(dict(name=spec['name'], reference=spec['image'], + image=run('docker', 'image', 'inspect', '-f', '{{.Id}}', spec['image']), + java=smoke(spec['image']), rollback=rollback)) + (ROOT / 'prepared.json').write_text(json.dumps(built, indent=2) + '\n') + print(json.dumps(built, indent=2)) + + +def apply(): + before = json.loads((ROOT / 'before.json').read_text()) + prepared = json.loads((ROOT / 'prepared.json').read_text()) + assert_idle() + for spec, old, built in zip(SERVICES, before, prepared): + assert inspect(spec['name'])['image'] == old['image'], 'Unexpected current image' + assert run('docker', 'image', 'inspect', '-f', '{{.Id}}', spec['image']) == built['image'] + path = Path(spec['directory']) / spec['compose'] + assert path.read_bytes() == (ROOT / (spec['service'] + '-compose.before')).read_bytes(), 'Compose changed after preparation' + source = path.read_text() + needle = 'image: ' + old['reference'] + assert source.count(needle) == 1, 'Expected exactly one original image selector' + path.write_text(source.replace(needle, 'image: ' + spec['image'])) + compose(spec, 'config', '--quiet') + # Stop the idle agent first so no delivery job can start during maintenance. + compose(SERVICES[1], 'stop', '-t', '30', 'agent') + compose(SERVICES[0], 'up', '-d', '--no-deps', '--pull', 'never', 'jenkins') + for _ in range(60): + try: + code = run('docker', 'exec', SERVICES[0]['name'], 'curl', '-sS', + '--max-time', '5', '-o', '/dev/null', '-w', '%{http_code}', + 'http://localhost:8080/login') if inspect(SERVICES[0]['name'])['running'] else '000' + except subprocess.CalledProcessError: + code = '000' + if code == '200': + break + time.sleep(3) + else: + raise RuntimeError('Controller did not return HTTP 200; retain checkpoint and investigate') + compose(SERVICES[1], 'up', '-d', '--no-deps', '--pull', 'never', 'agent') + after = [] + for spec, old in zip(SERVICES, before): + now = inspect(spec['name']) + assert now['running'] and not now['oom'] + assert now['mounts'] == old['mounts'], 'Persistent mounts changed' + now['java'] = run('docker', 'exec', spec['name'], 'java', '-version') + assert '21.0.13.1' in now['java'] and '+2' in now['java'] + after.append(now) + (ROOT / 'after.json').write_text(json.dumps(after, indent=2) + '\n') + print(json.dumps(after, indent=2)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('action', choices=['prepare', 'apply']) + args = parser.parse_args() + assert os.geteuid() == 0, 'Run as root on the authorized host' + {'prepare': prepare, 'apply': apply}[args.action]()