Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# CLAUDE.md β€” uaa-release

## System Overview

`uaa-release` is a **BOSH release** that packages and deploys [Cloud Foundry UAA](https://github.com/cloudfoundry/uaa) (the OAuth2/SSO identity provider for Cloud Foundry) as a set of VMs/jobs on a BOSH-managed platform. This repo does not contain UAA's application logic β€” that lives in the `src/uaa` git submodule (a separate Java/Spring Boot codebase) β€” it contains the **deployment glue**: ERB templates, packaging scripts, BOSH job/package specs, and Ruby/Go tests that turn the UAA WAR file into a runnable, configurable BOSH job. Architecturally this is a **BOSH release (packaging + deployment orchestration)** around a monolithic Java web application (Tomcat or embedded Spring Boot Tomcat), not a microservices system.

## Core Tech Stack & Tools

- **Deployment framework**: [BOSH](https://bosh.io) release format (`jobs/`, `packages/`, `spec` files, `.final_builds`/`.dev_builds`)
- **Application runtime** (packaged, not authored here): Java (BellSoft JDK, see `jdk-25.0.3/`), Apache Tomcat (`apache-tomcat-*.tar.gz`), Spring Boot (embedded Tomcat mode)
Comment thread
duanemay marked this conversation as resolved.
- **Templating**: ERB (`*.erb` files under `jobs/*/templates`) rendered by BOSH into job configs (`uaa.yml`, `bpm.yml`, `log4j2.properties`, `tomcat/server.xml`, etc.)
- **Config/process supervision**: [BPM](https://github.com/cloudfoundry/bpm-release) (`config/bpm.yml.erb`), Monit (`jobs/*/monit`)
- **Test frameworks**:
- Ruby / RSpec (`bundle exec rake` or `rspec spec`) β€” validates ERB template rendering against fixture manifests (`spec/input/*.yml` β†’ `spec/compare/*`)
- Go / Ginkgo (`src/acceptance_tests`) β€” end-to-end acceptance tests run as a BOSH errand job against a live deployment
- **Dependency management**: Bundler (`Gemfile`/`Gemfile.lock`) for Ruby, Go modules (`go.mod`/`go.sum`) for acceptance tests, git submodule for `src/uaa`
- **CI**: GitHub Actions (`.github/`)
- **Backup/restore**: [BBR](https://github.com/cloudfoundry-incubator/bosh-backup-and-restore) scripts for the UAA database (`jobs/bbr-uaadb`)

## Repository Directory Structure

```
uaa-release/
β”œβ”€β”€ jobs/ # BOSH job definitions β€” one per deployable role
β”‚ β”œβ”€β”€ uaa/ # The UAA app itself
β”‚ β”‚ β”œβ”€β”€ spec # Job spec: properties, templates, provides/consumes links
β”‚ β”‚ β”œβ”€β”€ monit # Process supervision config
β”‚ β”‚ └── templates/ # ERB templates rendered at deploy time
β”‚ β”‚ β”œβ”€β”€ bin/ # start/stop/health-check/pre-start scripts
β”‚ β”‚ β”œβ”€β”€ config/ # uaa.yml, bpm.yml, log4j2, tomcat server.xml, etc.
β”‚ β”‚ └── bbr/ # backup/restore lock scripts
β”‚ β”œβ”€β”€ bbr-uaadb/ # Errand job: backup/restore of the UAA database via BBR
β”‚ └── acceptance-tests/ # Errand job: runs the Go/Ginkgo acceptance suite on-network
β”‚ └── templates/run.erb # entrypoint invoked by `bosh run-errand`
β”œβ”€β”€ packages/ # BOSH packages β€” how binaries are compiled/assembled
β”‚ β”œβ”€β”€ uaa/
β”‚ β”‚ β”œβ”€β”€ packaging # Bash script: unpacks JDK + Tomcat, drops in the UAA WAR
β”‚ β”‚ └── spec # Declares source files (uaa/**/*, JDK tarball, Tomcat tarball)
β”‚ └── acceptance-tests/ # Packaging for the Go acceptance test binary
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ uaa/ # GIT SUBMODULE β†’ github.com/cloudfoundry/uaa (Java/Spring app)
β”‚ β”‚ # UAA's actual application code lives here, NOT in this repo
β”‚ └── acceptance_tests/ # Go source for the Ginkgo acceptance suite (not a submodule)
β”œβ”€β”€ spec/ # Ruby RSpec tests for this release's ERB templates
β”‚ β”œβ”€β”€ *_spec.rb # e.g. uaa-release.erb_spec.rb, tomcat.server.xml.erb_spec.rb
β”‚ β”œβ”€β”€ input/ # sample BOSH manifests used as spec fixtures
β”‚ β”œβ”€β”€ compare/ # expected rendered output, diffed against actual render
β”‚ └── support/ # custom matchers (e.g. yaml_eq)
β”œβ”€β”€ config/ # Release-level blob/final-version tracking (blobs.yml, final.yml)
β”œβ”€β”€ scripts/ # Dev workflow scripts: create-dev-release, run-locally, test-runner, etc.
β”œβ”€β”€ bin/ # CI/release helper scripts (build/deploy, show version, licenses)
β”œβ”€β”€ docs/ # Legacy bosh-micro-cli era docs
β”œβ”€β”€ releases/uaa/ # Finalized release manifests (*.yml) tracked per version
β”œβ”€β”€ .dev_builds/ , .final_builds/# BOSH-managed blob storage for compiled dev/final releases
β”œβ”€β”€ Rakefile, Gemfile # Ruby test runner entrypoint (`rake` β†’ runs spec/**/*_spec.rb)
└── manifest*.yml, opsfile.yml # Example/working BOSH deployment manifests + an ops-file
```

## Key Architecture & Data Flow

**Build/package time** (`bosh create-release` / CI):
`packages/uaa/spec` (declares inputs: `src/uaa` submodule output, JDK tarball, Tomcat tarball) β†’ `packages/uaa/packaging` (bash script compiles/assembles: unpacks JDK, unpacks Tomcat, copies in `cloudfoundry-identity-uaa.war` as `ROOT.war`, copies the statsd WAR and Tomcat listener jar) β†’ a versioned, immutable **compiled package** blob.

**Deploy time** (`bosh deploy`):
Operator-supplied BOSH manifest properties β†’ `jobs/uaa/spec` (declares/validates properties, and BOSH links like `uaa_db`, `uaa_keys`, `router`, `database`) β†’ ERB templates under `jobs/uaa/templates/` are rendered with those properties β†’ produces `config/uaa.yml`, `config/bpm.yml`, `config/tomcat/server.xml`, `config/log4j2.properties`, `bin/pre-start`, `bin/health_check`, etc. on the target VM β†’ **Monit** starts the job via **BPM**, which launches either Tomcat (WAR deployment, `runtime.tomcat.enabled=true`) or the embedded Spring Boot runtime β†’ the running UAA app talks to the UAA database (via the `uaa_db`/`database` BOSH link) and optionally an LDAP/SAML IdP per configured properties.

**Errand jobs** run on-demand via `bosh run-errand`:
- `acceptance-tests` β€” deployed alongside UAA on the same network, shells out to `bosh ssh`/`bosh scp` and makes HTTP calls directly to the UAA instance (deliberately avoids jumpboxes, per the comment in `jobs/acceptance-tests/spec`).
Comment thread
duanemay marked this conversation as resolved.
- `bbr-uaadb` β€” invoked by BOSH Backup and Restore to lock/dump/restore the UAA database.

**Verification loop** (this repo's own tests, not UAA's): RSpec renders each ERB template against fixture manifests in `spec/input/*.yml` and diffs the output against golden files in `spec/compare/*`, catching template regressions before a real deploy.

## Development Setup & Crucial Commands

**Requirements**: Ruby + Bundler (template tests), Go (acceptance tests), a BOSH director + `bosh` CLI (real deploys), git submodules initialized (`src/uaa`).

| Task | Command |
|---|---|
| Clone with submodules | `git clone --recursive <repo>` or `git submodule update --init` |
| Install Ruby deps | `bundle install` |
| Run all template specs | `bundle exec rake` (or `bundle exec rspec spec`) |
| Run a single template spec | `bundle exec rspec spec/uaa-release.erb_spec.rb` |
| Run Ruby template tests (explicit) | `scripts/run-template-tests.rb` |
| Shellcheck the release's scripts | `scripts/shellcheck.sh` |
| Create a dev release (local blob) | `scripts/create-dev-release.sh` |
| Deploy locally against bosh-lite/local director | `scripts/run-locally.sh` |
| Run acceptance tests locally (Docker) | `./scripts/run-locally.sh` then `go run github.com/onsi/ginkgo/ginkgo -v --progress --trace -r .` inside `src/acceptance_tests` (see `src/acceptance_tests/README.md`; do **not** use Docker for Mac β€” it's broken for this flow) |
Comment thread
duanemay marked this conversation as resolved.
| Run acceptance tests via BOSH errand | `bosh run-errand acceptance-tests` |
| Perform an official release | `scripts/perform-release.sh` |
| Refresh a local uaa-release deployment | `scripts/refresh-uaa-deployment.sh` |
| Tear down local BOSH env | `scripts/teardown-local.sh` |

## Guardrails & Design Patterns

- **Never edit UAA application code in this repo.** `src/uaa` is a pinned git submodule tracking `github.com/cloudfoundry/uaa`. Application/business-logic changes belong in that upstream repo and land here only as a submodule SHA bump (see recent commit history: `Bump UAA to <sha>`). This repo owns *packaging and deployment*, not app behavior.
- **Every property exposed to operators must be declared in the job `spec` file** (`jobs/uaa/spec`, `jobs/bbr-uaadb/spec`, `jobs/acceptance-tests/spec`) before it can be referenced in an ERB template β€” BOSH validates templates against the spec's `properties:` block.
- **Template changes require a corresponding RSpec fixture/golden-file update.** Any change to a file under `jobs/*/templates` should have a matching case in `spec/*_spec.rb`, an input manifest in `spec/input/`, and expected output in `spec/compare/`. Run `bundle exec rake` before considering a template change done.
- **Deprecated properties must keep working.** See `spec/input/deprecated-properties-still-work.yml` β€” this release maintains backward compatibility for renamed/deprecated manifest properties rather than breaking existing deployments.
- **Packaging scripts (`packages/*/packaging`) run with `set -e -x`** β€” treat them as fail-fast; don't suppress errors, and any added step should preserve strict-mode safety (check exit codes explicitly where subshells are involved, as the existing JDK/Tomcat unpack steps do).
- **Errand jobs run on-network deliberately.** The `acceptance-tests` job's placement is a documented workaround (see comment block in `jobs/acceptance-tests/spec`) for jumpbox/SOCKS5 timeouts and read-only `/etc/hosts` on Concourse workers β€” don't "simplify" this back onto an off-network worker without re-reading that rationale.
- **Two build stages exist for blobs**: `.dev_builds/` (local, iterative) vs `.final_builds/` (official, versioned) β€” tracked via `config/blobs.yml`/`config/final.yml`. Don't hand-edit blob directories; use the `scripts/`/`bosh create-release --final` flow.
- **Repo-root scratch/diagnostic files are not part of the release.** Files like `check-*.sh`, `find-*.sh`, `*-diagnostics.md`, `tomcat-troubleshooting-guide.md`, `manifest-*.yml` variants, and the `apache-tomcat-*.tar.gz`/`jdk-25.0.3/` directories at repo root are local working/debug artifacts, not tracked release inputs β€” the canonical manifest inputs are `manifest.yml`/`opsfile.yml` and the `jobs/`/`packages/` specs.
Comment thread
duanemay marked this conversation as resolved.