From 1d04e01ab26d4860f123d7dd4253c494189fd17a Mon Sep 17 00:00:00 2001 From: Rayhan Hossain Date: Thu, 12 Nov 2026 10:14:20 -0800 Subject: [PATCH 1/2] docs: update the release agent to match the actual release process The release agent only bumped Chart.yaml and the CHANGELOG, built the CHANGELOG from date ranges, named the wrong workflows and pushed unsigned commits to origin. Rewrite it to follow how the 1.0.0, 1.1.0, 1.1.1 and 1.2.0 releases were actually prepared: - List every file that carries the operator version (Helm test image tags, index.md, before-you-start.md, release-strategy.md, upgrades.md) and grep for leftovers. - Promote [Unreleased] and check it against git log ..main so every shipped PR is listed. - Ask whether documentDbVersion changes and hand that to the database release workflows. - Detect CRD changes and require "apply CRDs before helm upgrade" plus upgrade-guide updates. - Validate with helm unittest/lint, mkdocs build --strict and a kind upgrade, rollback and fresh-install test. - Commit with -s, push to the fork, and give the correct post-merge steps (operator workflow names and inputs including source_ref, plain X.Y.Z tag, E2E_UPGRADE_PREVIOUS_VERSION). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9f1a71b4-9969-4456-9f65-8d19dd550d8e Signed-off-by: Rayhan Hossain --- .github/agents/release-agent.md | 495 ++++++++++++-------------------- 1 file changed, 180 insertions(+), 315 deletions(-) diff --git a/.github/agents/release-agent.md b/.github/agents/release-agent.md index 96b98173d..89b32c060 100644 --- a/.github/agents/release-agent.md +++ b/.github/agents/release-agent.md @@ -4,383 +4,248 @@ tools: [execute, read, terminal, editFiles] --- # Release Agent Instructions -You are a release agent for the DocumentDB Kubernetes Operator project. Your role is to automate the release preparation process by updating version numbers and generating changelog entries. +You are a release agent for the DocumentDB Kubernetes Operator project. You prepare an **operator release PR**: version bumps across every file that carries the operator version, a CHANGELOG entry, docs and upgrade-guide updates, validation, and the post-merge release steps. ## Trigger This agent is invoked when a user says: -- "cut a release" -- "prepare release" -- "bump version" +- "cut a release" / "prepare release" / "bump version" - "create release {version}" +- `/release`, `/release patch|minor|major`, `/release X.Y.Z` -## Release Process - -### Step 1: Determine New Version - -1. **Read current version** from `operator/documentdb-helm-chart/Chart.yaml` -2. **Determine new version**: - - If user provides a specific version (e.g., "release 0.2.0"), use that version - - If no version specified, increment the **patch version** by 1 (e.g., `0.1.3` → `0.1.4`) -3. **Validate version format**: Must match semantic versioning `X.Y.Z` - - Version must only contain numbers and dots (regex: `^[0-9]+\.[0-9]+\.[0-9]+$`) - - **Security**: Always validate version format BEFORE using in any shell commands to prevent command injection - - Reject any version containing shell metacharacters (`;`, `|`, `&`, `$`, `` ` ``, `(`, `)`, etc.) -4. **Validate version increment**: New version must be greater than current version - - Compare major, minor, then patch components - - If new version ≤ current version, show error: - ``` - ❌ Error: New version (0.1.2) must be greater than current version (0.1.3). - Please specify a version higher than 0.1.3. - ``` - - Do not proceed with release until a valid higher version is provided - -### Step 2: Update Chart.yaml - -Update `operator/documentdb-helm-chart/Chart.yaml`: -- Change `version:` to the new version -- Change `appVersion:` to the new version (with quotes) - -**Example:** -```yaml -apiVersion: v2 -name: documentdb-operator -version: 0.1.4 -description: A Helm chart for deploying the DocumentDB operator -appVersion: "0.1.4" -dependencies: - - name: cloudnative-pg - version: "0.26.1" - repository: "https://cloudnative-pg.github.io/charts/" -``` - -### Step 3: Generate Changelog Entry +## Background: Two Version Tracks -1. **Get the date of the most recent release**: - - Read `CHANGELOG.md` and find the date from the most recent release entry (format: `## [X.Y.Z] - YYYY-MM-DD`) - - Format: `## [X.Y.Z] - YYYY-MM-DD` +The project releases two independent tracks (see [`docs/designs/image-management.md`](../../docs/designs/image-management.md)): -2. **Fetch commit messages since last release**: - ```bash - git log --oneline --since="YYYY-MM-DD" --pretty=format:"- %s" - ``` - - Use the date from the most recent release entry in `CHANGELOG.md` - - **Note**: Filter out release preparation commits (e.g., `chore: prepare release`, changelog bump commits) as these belong to the previous release - - Alternatively, use the day **after** the last release date to avoid including release-day commits +| Track | Images | Version source | Released by | +|-------|--------|----------------|-------------| +| **Operator** | operator, sidecar (wal-replica later) | `Chart.yaml` `version` / `appVersion` | This agent's release PR + operator release workflows | +| **Database** | documentdb extension, gateway, documentdb-combined | `values.yaml` `documentDbVersion` and `DEFAULT_DOCUMENTDB_TAG` in `constants.go` | Database release workflows, which open their own version-bump PR | -3. **Categorize commits** based on conventional commit prefixes: - - `feat:` → **Major Features** - - `fix:` → **Bug Fixes** - - `docs:` → **Documentation** - - `refactor:`, `chore:`, `test:` → **Enhancements & Fixes** - - Other → **Enhancements & Fixes** +This agent prepares the **operator** release. If the default DocumentDB engine version also changes, the database track must be released first (see [Step 3](#step-3-database-track-check)). Never edit `documentDbVersion` or `DEFAULT_DOCUMENTDB_TAG` by hand. -4. **Create changelog entry** at the top of CHANGELOG.md (after the `# Changelog` header): - ```markdown - ## [X.Y.Z] - YYYY-MM-DD +## Release Process - ### Major Features - - **Feature description from commit** +### Step 0: Pre-flight - ### Bug Fixes - - Fix description from commit +```bash +git fetch origin main --tags +git status --porcelain # must be clean, or work in a new worktree +gh release list -L 5 # latest published releases +``` - ### Enhancements & Fixes - - Enhancement description from commit +1. **Last release tag**: the newest non-pre-release from `gh release list` (for example `1.1.1`). Tags are plain `X.Y.Z` with **no `v` prefix**. +2. **Current version**: read `version:` from `operator/documentdb-helm-chart/Chart.yaml` on `origin/main`. It normally equals the last release tag. +3. **Fork remote**: find the remote that points at the user's fork (`git remote -v`; any remote whose URL is not `documentdb/documentdb-kubernetes-operator`, for example `myfork`). Release branches are pushed to the fork, never to the upstream repository. If there is no fork remote, ask the user which remote to use. +4. Create the release branch from `origin/main`, preferably in a separate worktree: + ```bash + git worktree add -b /release-X.Y.Z ../release-X.Y.Z origin/main ``` -### Step 4: Verify Changes - -After making changes, display: -1. The updated `Chart.yaml` content -2. The new CHANGELOG entry -3. Summary of version bump (old → new) - -## File Locations - -| File | Path | What to Update | -|------|------|----------------| -| Chart.yaml | `operator/documentdb-helm-chart/Chart.yaml` | `version` and `appVersion` | -| CHANGELOG.md | `CHANGELOG.md` | Add new version entry at top | - -## Version Bump Rules - -| User Request | Action | -|--------------|--------| -| "cut a release" | Increment patch: `0.1.3` → `0.1.4` | -| "cut a minor release" | Increment minor: `0.1.3` → `0.2.0` | -| "cut a major release" | Increment major: `0.1.3` → `1.0.0` | -| "release 0.2.1" | Use exact version: `0.2.1` | - -## Changelog Format - -Follow the existing changelog format: +### Step 1: Determine the New Version -```markdown -# Changelog - -## [X.Y.Z] - YYYY-MM-DD - -### Major Features -- **Feature Name**: Brief description - -### Bug Fixes -- Fix: Description of bug fix +1. If the user gives a version, use it. Otherwise: + - `/release` or `/release patch`: `1.1.1` → `1.1.2` + - `/release minor`: `1.1.1` → `1.2.0` + - `/release major`: `1.1.1` → `2.0.0` +2. **Validate the format before using it in any shell command**: it must match `^[0-9]+\.[0-9]+\.[0-9]+$`. Reject anything else, including shell metacharacters (`;`, `|`, `&`, `$`, `` ` ``, `(`, `)`), to prevent command injection. +3. **Validate the increment**: the new version must be greater than the current version (compare major, then minor, then patch). Otherwise stop: + ``` + ❌ Error: New version (1.1.0) must be greater than current version (1.1.1). + ``` +4. **Recommend the right bump** from the changes since the last tag (Step 4 lists them). New CRD versions, new features or new Helm values call for a **minor** release; bug and security fixes only call for a **patch**. If the user's request doesn't match, say so and ask before continuing. -### Enhancements & Fixes -- Enhancement or chore description +### Step 2: Detect CRD Changes -## [Previous Version] - Previous Date -... +```bash +git diff --stat origin/main -- operator/documentdb-helm-chart/crds/ ``` -## Commit Message Parsing +If any CRD changed, this release **requires users to apply the new CRDs before `helm upgrade`** (Helm never upgrades CRDs). Remember this for Steps 5–7. -Parse commit messages to extract meaningful changelog entries: +### Step 3: Database Track Check -| Commit Message | Changelog Entry | -|----------------|-----------------| -| `feat: add backup scheduling` | **Major Features**: Add backup scheduling | -| `fix: resolve connection timeout` | **Bug Fixes**: Resolve connection timeout | -| `docs: update installation guide` | **Documentation**: Update installation guide | -| `chore: update dependencies` | **Enhancements & Fixes**: Update dependencies | - -## Output Format +Ask the user: **"Does this release change the default DocumentDB engine version (`documentDbVersion`)?"** -After completing the release preparation, output: +- **No** (the usual case): continue. The release only changes the operator, sidecar, CRDs and Helm chart. Say so in the CHANGELOG summary ("the default DocumentDB engine stays at `X`"). +- **Yes**: the database track must be released first: + 1. Run **RELEASE - Build DocumentDB Candidate Images** (`build_documentdb_images.yml`) with `version` set to the engine version (and `package_source` if needed). + 2. Run **RELEASE - Promote DocumentDB Images** (`release_documentdb_images.yml`) with `candidate_version`, `version` and `update_defaults: true`. It opens a PR on branch `auto/documentdb-` that bumps `constants.go`, the sidecar `config.go`, `values.yaml`, Helm test env values, workflow defaults, `Dockerfile_gateway_public_image` and the E2E schema-upgrade default pair. + 3. Merge that PR before the operator release PR, then rebase the release branch on `origin/main`. + 4. In the operator release PR, also update the engine column in `before-you-start.md` and `release-strategy.md`, and add an "Upgrading to DocumentDB X" section to `upgrades.md` if the schema needs migration. -```markdown -## Release Preparation Complete +### Step 4: Update Version References -### Version Bump -- **Previous Version**: 0.1.3 -- **New Version**: 0.1.4 +Update every file in this table: -### Files Updated -1. ✅ `operator/documentdb-helm-chart/Chart.yaml` - - `version: 0.1.4` - - `appVersion: "0.1.4"` - -2. ✅ `CHANGELOG.md` - - Added entry for version 0.1.4 - -### Changelog Entry Preview -[Show the new changelog entry] - -### Next Steps -1. Review the changes -2. Run `make manifests generate` from `operator/src/` if API changes were included -3. Run `make test` from `operator/src/` to verify everything works -4. Commit with message: `chore: prepare release 0.1.4` -5. Create PR for release -6. After merge, trigger the release workflow: - - Run "RELEASE - Build Candidate Images" workflow with version `0.1.4` - - Run "RELEASE - Promote Candidate Images and Publish Helm Chart" workflow to publish -``` +| File | What to update | Patch | Minor/Major | +|------|----------------|:-----:|:-----------:| +| `operator/documentdb-helm-chart/Chart.yaml` | `version: X.Y.Z` and `appVersion: "X.Y.Z"` | ✅ | ✅ | +| `operator/documentdb-helm-chart/tests/02_sidecar_injector_test.yaml` | default sidecar image tag `sidecar:X.Y.Z` | ✅ | ✅ | +| `operator/documentdb-helm-chart/tests/03_wal_replica_test.yaml` | default wal-replica image tag `wal-replica:X.Y.Z` | ✅ | ✅ | +| `operator/documentdb-helm-chart/tests/09_operator_deployment_test.yaml` | both operator image tags (`ghcr.io/...` and `mcr.microsoft.com/...`) | ✅ | ✅ | +| `CHANGELOG.md` | new release entry ([Step 5](#step-5-changelog)) | ✅ | ✅ | +| `docs/operator-public-documentation/v1/index.md` | "Operator `X.Y.Z` is generally available…" note | ✅ | ✅ | +| `docs/operator-public-documentation/v1/getting-started/before-you-start.md` | version-compatibility table row and the "Use operator `X.Y.Z`…" sentence | sentence only | ✅ | +| `docs/designs/release-strategy.md` | `vX.Y.x` rows in the support, Kubernetes compatibility, dependency and DocumentDB component tables | — | ✅ | +| `docs/operator-public-documentation/v1/operations/upgrades.md` | version ranges in upgrade notes, new migration or rollback notes | when CRDs or upgrade behavior change | when CRDs or upgrade behavior change | -## Error Handling +Then **search for anything the table missed**: -- If `Chart.yaml` cannot be found, report error and stop -- If `CHANGELOG.md` cannot be found, create a new one with proper header -- If git commands fail, proceed with a **manual changelog entry**: - - Ask the user to provide a list of changes in the following format, one per line: - - `- [type] description of the change` - - Valid `type` values: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`, `perf`, `breaking` - - Example: - ``` - - [feat] Add support for configurable backup window - - [fix] Resolve panic when scaling replicas to zero - - [docs] Clarify TLS configuration requirements - ``` - - Use the provided list to construct the new `CHANGELOG.md` entry for the release version and date, keeping the overall changelog style consistent with existing entries - - Map types to changelog sections: - - `feat`, `breaking` → **Major Features** - - `fix` → **Bug Fixes** - - `docs` → **Documentation** - - `chore`, `refactor`, `test`, `perf` → **Enhancements & Fixes** -- If version format is invalid, ask user to provide valid semantic version - -## Important Notes - -1. **Do not modify `values.yaml`** - The CI workflow handles image tag updates during release -2. **Keep existing changelog entries intact** - Only prepend the new entry -3. **Use current date** for the changelog entry in format `YYYY-MM-DD` -4. **Preserve Chart.yaml structure** - Only modify version and appVersion fields - -## Release Commands - -Use these commands to trigger the release agent: - -| Command | Description | Example | -|---------|-------------|---------| -| `/release` | Increment patch version | `0.1.3` → `0.1.4` | -| `/release patch` | Increment patch version | `0.1.3` → `0.1.4` | -| `/release minor` | Increment minor version | `0.1.3` → `0.2.0` | -| `/release major` | Increment major version | `0.1.3` → `1.0.0` | -| `/release X.Y.Z` | Set exact version | `/release 0.2.1` | - -## Example Usage - -### Basic Release (patch bump) -``` -@release-agent cut a release +```bash +# Old version everywhere except history files +git grep -nF "" -- . ':!CHANGELOG.md' ':!*go.sum' ':!*go.mod' +# Docs often still name the previous minor (e.g. 1.1.0 after a 1.1.1 patch) +git grep -nE '\b\.\.[0-9]+\b' -- docs README.md ``` -### Minor Version Release -``` -@release-agent cut a minor release -``` +Review each hit. Version strings for unrelated tools (for example `helm-unittest --version v1.1.0`) and test fixtures must not be changed. -### Major Version Release -``` -@release-agent cut a major release -``` +Do **not** edit: `values.yaml` image tags or `documentDbVersion` (the database workflows own them), generated CRDs, `zz_generated.*`, or `go.mod`. -### Specific Version Release -``` -@release-agent release 1.0.0 -``` +### Step 5: CHANGELOG -### Release with Custom Changelog Entry -``` -@release-agent release 0.2.0 with changelog: -- [feat] Add support for configurable backup window -- [fix] Resolve panic when scaling replicas to zero -- [docs] Clarify TLS configuration requirements -``` +Contributors add entries under `## [Unreleased]` as they merge. **Promote that section; do not regenerate it from scratch.** -The custom changelog format uses `[type] description` where type maps to sections: -- `feat`, `breaking` → **Major Features** -- `fix` → **Bug Fixes** -- `docs` → **Documentation** -- `chore`, `refactor`, `test`, `perf` → **Enhancements & Fixes** +1. Rename `## [Unreleased]` to `## [X.Y.Z] - YYYY-MM-DD` (today's date) and add a new empty `## [Unreleased]` above it. +2. Add a one-paragraph summary under the new heading: the default DocumentDB engine version, the headline change, and, if CRDs changed, **"Apply the X.Y.Z CRDs before `helm upgrade`."** Follow the style of the `1.1.0` entry. +3. **Check that every shipped change is listed.** Use the tag range, not `--since=` (dates and squash merges make date ranges unreliable): + ```bash + git log --oneline ..origin/main + ``` + Every PR number must appear in the entry unless it is intentionally excluded: + - release-preparation commits (`chore: release …`, `chore: prepare release …`) + - database-track-only changes (gateway or extension image builds) — they ship with the database release + - CI-only or test-only changes, unless they are worth noting + For each missing PR, add a line in the matching section (`feat:` → **Major Features**, `fix:` → **Bug Fixes**, `docs:` → **Documentation**, security fixes → **Security**, `chore:`/`refactor:`/`test:`/`perf:` → **Enhancements & Fixes**, upgrade-impacting changes → **Upgrade notes**). Reference the PR as `(#NNN)`. +4. If a commit in the range is already listed under an older release, or an older release is missing a change it shipped, flag it to the user and fix the older entry. Keep all other existing entries intact. +5. Check that the previous release's heading date matches its GitHub release date (`gh release view --json publishedAt`). -### Create PR After Review -``` -@release-agent create PR -``` +If git or `gh` is unavailable, ask the user for the change list in `- [type] description` form (`feat`, `fix`, `docs`, `chore`, `refactor`, `test`, `perf`, `breaking`) and map it to the sections above. -### Full Release Flow (prepare + PR) -``` -@release-agent cut a release and create PR -``` +### Step 6: CRD and Upgrade-Guide Updates -## Creating a Pull Request +If Step 2 found CRD changes: -After the release changes are reviewed, the agent can create a GitHub PR. +1. The CHANGELOG summary must say **"Apply the X.Y.Z CRDs before `helm upgrade`."** +2. In `docs/operator-public-documentation/v1/operations/upgrades.md`, **Step 3: Apply Updated CRDs**, make sure the version range in the "required when upgrading from …" box covers every older release whose CRDs are incompatible (for example "from `1.1.x` or earlier", not only the oldest one). +3. If the change adds or graduates an API version, check that the migration section names the release and that the **Operator Rollback** notes still hold (for example "keep the newer CRDs; don't re-apply older CRDs"). +4. The upgrade guide downloads CRDs from `raw.githubusercontent.com/documentdb/documentdb-kubernetes-operator/${TARGET_VERSION}/…`, so the release tag must be exactly `X.Y.Z`. -### Step 5: Create Release Branch and PR +### Step 7: Validate -When user says "create PR", "cut a PR", or "open PR": +Run all of these and report the results in the PR description. -1. **Create a release branch**: +1. **Helm unit tests and lint** (from `operator/documentdb-helm-chart/`): ```bash - git checkout -b release/v{version} + helm dependency build . # needs: helm repo add cnpg https://cloudnative-pg.github.io/charts/ + helm unittest . + helm lint . --set certManager.preflightCheck=false + helm template t . -n documentdb-operator --set certManager.preflightCheck=false \ + | grep -E 'image: .*documentdb-kubernetes-operator/(operator|sidecar)' # must show :X.Y.Z ``` - - **Branch naming convention**: `release/v{version}` (e.g., `release/v0.1.4`) - - This differs from feature branches which use `developer/feature-name` pattern - -2. **Check for other uncommitted changes**: +2. **Docs build** with the versions pinned in `.github/workflows/deploy_docs.yml`: ```bash - git status + python3 -m venv /tmp/mkdocs-venv + /tmp/mkdocs-venv/bin/pip install "mkdocs-material==9.5.19" "mike==2.1.3" "mkdocs-redirects==1.2.2" + /tmp/mkdocs-venv/bin/mkdocs build --strict -d /tmp/site ``` - - If there are other uncommitted changes besides `Chart.yaml` and `CHANGELOG.md`: - - **Option A**: Stash them first: `git stash push -m "WIP before release"` - - **Option B**: Ask user to commit or discard unrelated changes before proceeding - - Do NOT proceed if unrelated changes might be accidentally committed - -3. **Stage ONLY the release files** (do not add other files): +3. **Go unit tests** (`make test` from `operator/src/`) — only needed if the release PR changes Go code; a pure version bump does not. +4. **Kind release test.** The `X.Y.Z` images don't exist until after merge, so build them from the release branch. Use a `localhost/` repository: the chart prefixes bare repositories with `image.registry` (`ghcr.io`), while repositories whose first segment is `localhost` are used as-is. ```bash - git add operator/documentdb-helm-chart/Chart.yaml CHANGELOG.md + docker build -t localhost/documentdb-operator:X.Y.Z operator/src + docker build -t localhost/documentdb-sidecar:X.Y.Z operator/cnpg-plugins/sidecar-injector + kind create cluster --name release-test --image kindest/node: + kind load docker-image localhost/documentdb-operator:X.Y.Z localhost/documentdb-sidecar:X.Y.Z --name release-test + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download//cert-manager.yaml ``` + Then follow the public upgrade guide step by step: + 1. **Install the previous published chart**: `helm install documentdb-operator oci://ghcr.io/documentdb/documentdb-operator --version -n documentdb-operator --create-namespace --wait`. + 2. Create a `DocumentDB` (and a `ScheduledBackup`) using the API version that release served, and insert test data through the gateway with `mongosh` (`mongodb://…@documentdb-service-..svc:10260/?directConnection=true&authMechanism=SCRAM-SHA-256&tls=true&tlsAllowInvalidCertificates=true`). + 3. **Apply the new CRDs** with `kubectl apply --server-side --force-conflicts -f operator/documentdb-helm-chart/crds/`, and check that the old operator still works. + 4. **`helm upgrade`** to the release-branch chart with `--set image.documentdbk8soperator.repository=localhost/documentdb-operator --set image.sidecarinjector.repository=localhost/documentdb-sidecar --set image.documentdbk8soperator.pullPolicy=Never --set image.sidecarinjector.pullPolicy=Never`. + 5. **Verify**: the database pod UID is unchanged and has 0 restarts, the cluster is healthy, all data is intact, and the operator logs show no errors besides first-reconcile `object has been modified` retries. Create a new cluster with the current API version and do a read/write. If CRDs changed, check the webhook rejects an invalid change (for example a PVC shrink) through every served API version, and run any migration commands from the upgrade guide. + 6. **Rollback**: `helm rollback documentdb-operator ` and check the previous operator still works against the new CRDs (existing clusters healthy, it can create a new cluster). Then roll forward again with `helm upgrade`. + 7. **Fresh install**: on a new kind cluster, `helm install` the release-branch chart and create a cluster with the current API version. + + Delete the kind clusters and local images afterwards. -4. **Commit changes**: +### Step 8: Commit and Open the PR + +1. **Stage only the release files** from Step 4 (and any files fixed in Steps 5–6). Check `git status` first; stash or ask about unrelated changes. +2. **Commit with a DCO sign-off** — the DCO check blocks unsigned commits: ```bash - git commit -m "chore: prepare release {version}" + git commit -s -m "chore: release vX.Y.Z" -m "" + git log -1 --format='%(trailers:key=Signed-off-by)' # must print a trailer ``` - -5. **Push the branch to your fork**: + Include any trailers the user's tooling requires (for example `Co-authored-by:`). +3. **Push to the fork remote** found in Step 0, not to `origin`: ```bash - # Push to your fork (origin should point to your fork) - git push origin release/v{version} + git push /release-X.Y.Z ``` - -6. **Create Pull Request** using GitHub CLI (from fork to upstream): +4. **Open the PR against upstream `main`**: + ```bash + gh pr create --repo documentdb/documentdb-kubernetes-operator --base main \ + --head :/release-X.Y.Z \ + --title "chore: release vX.Y.Z" --body-file + ``` + The PR body must contain: **Summary** (operator version, engine version, headline change), **Changes** (per file group), **Testing** (Step 7 results), and the **Post-merge release steps** from Step 9 with the version filled in. + +### Step 9: Post-Merge Release Steps + +Release from the **merge commit on `main`** (``), never from the PR branch. The promote workflow packages the chart from `source_ref` and checks that `TEST - E2E` passed on that exact commit. Nothing else should merge to `main` between the release PR and the promotion. + +1. Wait for **TEST - E2E** to pass on ``. +2. Run **RELEASE - Build Operator Candidate Images** (`build_operator_images.yml`) on `main` with `version: X.Y.Z`. It pushes `X.Y.Z-test` operator and sidecar images. +3. Optional: smoke-test the candidates with the kind upgrade test from Step 7, using `image.*.tag=X.Y.Z-test`. +4. Run **RELEASE - Promote Operator Images and Publish Helm Chart** (`release_operator.yml`) with: + - `candidate_version: X.Y.Z-test` + - `version: X.Y.Z` + - `source_ref: ` (must be the commit the candidates were built from) + - `force`: leave off +5. Tag `` as **`X.Y.Z`** (no `v` prefix) and publish the GitHub release. If CRDs changed, put **"Apply the X.Y.Z CRDs before `helm upgrade`"** at the top of the release notes. +6. Verify: ```bash - gh pr create \ - --title "chore: release v{version}" \ - --body "## Release v{version} - - ### Changes - - Updated Chart.yaml version to {version} - - Updated appVersion to {version} - - Added CHANGELOG entry for v{version} - - ### Checklist - - [ ] Version numbers updated correctly - - [ ] CHANGELOG entry is accurate - - [ ] CI passes - - ### Post-Merge Steps - 1. Run 'RELEASE - Build Candidate Images' workflow with version \`{version}\` - 2. Run 'RELEASE - Promote Candidate Images and Publish Helm Chart' workflow to publish" \ - --base main \ - --repo documentdb/documentdb-kubernetes-operator + helm show chart oci://ghcr.io/documentdb/documentdb-operator --version X.Y.Z # appVersion: X.Y.Z + curl -sfo /dev/null -w '%{http_code}\n' \ + https://raw.githubusercontent.com/documentdb/documentdb-kubernetes-operator/X.Y.Z/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml # 200 ``` +7. Set the repository variable `E2E_UPGRADE_PREVIOUS_VERSION` to `X.Y.Z`. The E2E control-plane upgrade spec (`test/e2e/tests/upgrade/upgrade_control_plane_test.go`) skips when it is unset; once set, it tests upgrades from this release. -7. **Output the PR URL** for the user to review +## Output Format -### PR Commands +After preparing the release, output: -| Command | Description | -|---------|-------------| -| `/create-pr` | Create PR with current changes | -| `/cut-pr` | Alias for create-pr | -| `/open-pr` | Alias for create-pr | -| `create PR` | Natural language trigger | -| `cut a PR` | Natural language trigger | -| `open a pull request` | Natural language trigger | +```markdown +## Release Preparation Complete -### PR Output Format +### Version Bump +- **Operator**: → X.Y.Z () +- **Default DocumentDB engine**: +- **CRD changes**: -After creating the PR, output: +### Files Updated +- -```markdown -## Pull Request Created - -### PR Details -- **Branch**: `release/v0.1.4` -- **Title**: chore: release v0.1.4 -- **PR URL**: https://github.com/documentdb/documentdb-kubernetes-operator/pull/XXX - -### Files Changed -- `operator/documentdb-helm-chart/Chart.yaml` -- `CHANGELOG.md` - -### Next Steps -1. Review the PR: [PR Link] -2. Approve and merge -3. After merge, trigger release workflows: - - "RELEASE - Build Candidate Images" with version `0.1.4` - - "RELEASE - Promote Candidate Images and Publish Helm Chart" to publish -``` +### CHANGELOG Check +- PRs since : ; listed: ; intentionally excluded: -### Prerequisites for PR Creation +### Validation +- helm unittest / lint / template: +- mkdocs build --strict: +- kind upgrade, rollback and fresh-install test: -- GitHub CLI (`gh`) must be installed and authenticated -- User must have push access to the repository -- Working directory must be clean (except for release changes) +### PR +- -If `gh` CLI is not available, provide manual instructions: -```markdown -## Manual PR Creation +### Post-Merge Steps + +``` -GitHub CLI not available. Please create PR manually: +## Error Handling -1. Create branch: `git checkout -b release/v{version}` -2. Stage files: `git add operator/documentdb-helm-chart/Chart.yaml CHANGELOG.md` -3. Commit: `git commit -m "chore: prepare release {version}"` -4. Push: `git push origin release/v{version}` -5. Open: https://github.com/documentdb/documentdb-kubernetes-operator/compare/main...release/v{version} -``` -``` \ No newline at end of file +- `Chart.yaml` not found: report and stop. +- `CHANGELOG.md` not found: create it with a `# Changelog` header and an empty `## [Unreleased]` section. +- Invalid or non-increasing version: ask for a valid version and stop until one is given. +- No fork remote: ask the user which remote to push to; never push release branches to upstream. +- Validation failure: stop and report it; do not open the PR until it is fixed or the user accepts the risk. From 22fb04653daa921da2f986dadfd2f50b9c9ff641 Mon Sep 17 00:00:00 2001 From: Rayhan Hossain Date: Thu, 12 Nov 2026 10:44:56 -0800 Subject: [PATCH 2/2] docs: address review feedback on the release agent - Identify the upstream and fork remotes by URL and base everything on /main instead of assuming origin is upstream. - Kind test: share cluster setup and local-image overrides between the upgrade and fresh-install clusters, pass -n to helm rollback, and only require unchanged database pods when the release doesn't change the engine version or pod configuration. - Post-merge: the control-plane upgrade E2E spec also needs E2E_UPGRADE_CURRENT_CHART, which CI leaves empty, so it is skipped; don't treat a green E2E run as chart-upgrade coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9f1a71b4-9969-4456-9f65-8d19dd550d8e Signed-off-by: Rayhan Hossain --- .github/agents/release-agent.md | 77 ++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/.github/agents/release-agent.md b/.github/agents/release-agent.md index 89b32c060..1a0fcca3e 100644 --- a/.github/agents/release-agent.md +++ b/.github/agents/release-agent.md @@ -28,18 +28,22 @@ This agent prepares the **operator** release. If the default DocumentDB engine v ### Step 0: Pre-flight -```bash -git fetch origin main --tags -git status --porcelain # must be clean, or work in a new worktree -gh release list -L 5 # latest published releases -``` +1. **Identify the remotes** with `git remote -v`. Don't assume `origin` is upstream; a clone of a fork has `origin` pointing at the fork. + - ``: the remote whose URL is `documentdb/documentdb-kubernetes-operator` (often `origin` or `upstream`). + - ``: the remote that points at the user's fork (for example `myfork`, or `origin` in a fork clone). -1. **Last release tag**: the newest non-pre-release from `gh release list` (for example `1.1.1`). Tags are plain `X.Y.Z` with **no `v` prefix**. -2. **Current version**: read `version:` from `operator/documentdb-helm-chart/Chart.yaml` on `origin/main`. It normally equals the last release tag. -3. **Fork remote**: find the remote that points at the user's fork (`git remote -v`; any remote whose URL is not `documentdb/documentdb-kubernetes-operator`, for example `myfork`). Release branches are pushed to the fork, never to the upstream repository. If there is no fork remote, ask the user which remote to use. -4. Create the release branch from `origin/main`, preferably in a separate worktree: + If either is missing, ask the user. Release branches are pushed to the fork, never to upstream, and **every comparison and the release branch base use `/main`**, never a fork's `main`, which may be stale. +2. Fetch and check the state: + ```bash + git fetch main --tags + git status --porcelain # must be clean, or work in a new worktree + gh release list --repo documentdb/documentdb-kubernetes-operator -L 5 + ``` +3. **Last release tag**: the newest non-pre-release from `gh release list` (for example `1.1.1`). Tags are plain `X.Y.Z` with **no `v` prefix**. +4. **Current version**: read `version:` from `operator/documentdb-helm-chart/Chart.yaml` on `/main`. It normally equals the last release tag. +5. Create the release branch from `/main`, preferably in a separate worktree: ```bash - git worktree add -b /release-X.Y.Z ../release-X.Y.Z origin/main + git worktree add -b /release-X.Y.Z ../release-X.Y.Z /main ``` ### Step 1: Determine the New Version @@ -58,7 +62,7 @@ gh release list -L 5 # latest published releases ### Step 2: Detect CRD Changes ```bash -git diff --stat origin/main -- operator/documentdb-helm-chart/crds/ +git diff --stat /main -- operator/documentdb-helm-chart/crds/ ``` If any CRD changed, this release **requires users to apply the new CRDs before `helm upgrade`** (Helm never upgrades CRDs). Remember this for Steps 5–7. @@ -71,7 +75,7 @@ Ask the user: **"Does this release change the default DocumentDB engine version - **Yes**: the database track must be released first: 1. Run **RELEASE - Build DocumentDB Candidate Images** (`build_documentdb_images.yml`) with `version` set to the engine version (and `package_source` if needed). 2. Run **RELEASE - Promote DocumentDB Images** (`release_documentdb_images.yml`) with `candidate_version`, `version` and `update_defaults: true`. It opens a PR on branch `auto/documentdb-` that bumps `constants.go`, the sidecar `config.go`, `values.yaml`, Helm test env values, workflow defaults, `Dockerfile_gateway_public_image` and the E2E schema-upgrade default pair. - 3. Merge that PR before the operator release PR, then rebase the release branch on `origin/main`. + 3. Merge that PR before the operator release PR, then rebase the release branch on `/main`. 4. In the operator release PR, also update the engine column in `before-you-start.md` and `release-strategy.md`, and add an "Upgrading to DocumentDB X" section to `upgrades.md` if the schema needs migration. ### Step 4: Update Version References @@ -111,7 +115,7 @@ Contributors add entries under `## [Unreleased]` as they merge. **Promote that s 2. Add a one-paragraph summary under the new heading: the default DocumentDB engine version, the headline change, and, if CRDs changed, **"Apply the X.Y.Z CRDs before `helm upgrade`."** Follow the style of the `1.1.0` entry. 3. **Check that every shipped change is listed.** Use the tag range, not `--since=` (dates and squash merges make date ranges unreliable): ```bash - git log --oneline ..origin/main + git log --oneline ../main ``` Every PR number must appear in the entry unless it is intentionally excluded: - release-preparation commits (`chore: release …`, `chore: prepare release …`) @@ -155,20 +159,41 @@ Run all of these and report the results in the PR description. ```bash docker build -t localhost/documentdb-operator:X.Y.Z operator/src docker build -t localhost/documentdb-sidecar:X.Y.Z operator/cnpg-plugins/sidecar-injector - kind create cluster --name release-test --image kindest/node: - kind load docker-image localhost/documentdb-operator:X.Y.Z localhost/documentdb-sidecar:X.Y.Z --name release-test - kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download//cert-manager.yaml + + # Helm overrides that point the release-branch chart at the local images + LOCAL_IMAGES=(--set image.documentdbk8soperator.repository=localhost/documentdb-operator + --set image.sidecarinjector.repository=localhost/documentdb-sidecar + --set image.documentdbk8soperator.pullPolicy=Never + --set image.sidecarinjector.pullPolicy=Never) + + # Cluster setup; run it for every kind cluster used below + setup_kind() { + kind create cluster --name "$1" --image kindest/node: --wait 120s + kind load docker-image localhost/documentdb-operator:X.Y.Z localhost/documentdb-sidecar:X.Y.Z --name "$1" + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download//cert-manager.yaml + kubectl -n cert-manager rollout status deploy --timeout=180s + } + setup_kind release-upgrade ``` - Then follow the public upgrade guide step by step: + Then follow the public upgrade guide step by step on `release-upgrade`: 1. **Install the previous published chart**: `helm install documentdb-operator oci://ghcr.io/documentdb/documentdb-operator --version -n documentdb-operator --create-namespace --wait`. - 2. Create a `DocumentDB` (and a `ScheduledBackup`) using the API version that release served, and insert test data through the gateway with `mongosh` (`mongodb://…@documentdb-service-..svc:10260/?directConnection=true&authMechanism=SCRAM-SHA-256&tls=true&tlsAllowInvalidCertificates=true`). + 2. Create a `DocumentDB` (and a `ScheduledBackup`) using the API version that release served, and insert test data through the gateway with `mongosh` (`mongodb://…@documentdb-service-..svc:10260/?directConnection=true&authMechanism=SCRAM-SHA-256&tls=true&tlsAllowInvalidCertificates=true`). Record the database pod UIDs. 3. **Apply the new CRDs** with `kubectl apply --server-side --force-conflicts -f operator/documentdb-helm-chart/crds/`, and check that the old operator still works. - 4. **`helm upgrade`** to the release-branch chart with `--set image.documentdbk8soperator.repository=localhost/documentdb-operator --set image.sidecarinjector.repository=localhost/documentdb-sidecar --set image.documentdbk8soperator.pullPolicy=Never --set image.sidecarinjector.pullPolicy=Never`. - 5. **Verify**: the database pod UID is unchanged and has 0 restarts, the cluster is healthy, all data is intact, and the operator logs show no errors besides first-reconcile `object has been modified` retries. Create a new cluster with the current API version and do a read/write. If CRDs changed, check the webhook rejects an invalid change (for example a PVC shrink) through every served API version, and run any migration commands from the upgrade guide. - 6. **Rollback**: `helm rollback documentdb-operator ` and check the previous operator still works against the new CRDs (existing clusters healthy, it can create a new cluster). Then roll forward again with `helm upgrade`. - 7. **Fresh install**: on a new kind cluster, `helm install` the release-branch chart and create a cluster with the current API version. - - Delete the kind clusters and local images afterwards. + 4. **Upgrade**: `helm upgrade documentdb-operator operator/documentdb-helm-chart -n documentdb-operator "${LOCAL_IMAGES[@]}" --wait`. + 5. **Verify**: the cluster is healthy, all data is intact, and the operator logs show no errors besides first-reconcile `object has been modified` retries. Then check pod behavior against what the release should do: + - **Database images and pod configuration unchanged** (the usual operator-only release): database pod UIDs are unchanged with 0 restarts. + - **Default engine version or pod configuration changed** (Step 3, or a release that changes rendered pod specs): unpinned clusters are expected to roll. Check the restart is a normal rolling restart onto the new images, each pod returns to ready, and data is intact. Clusters that pin `spec.documentDBVersion` must not change images. + + Create a new cluster with the current API version and do a read/write. If CRDs changed, check the webhook rejects an invalid change (for example a PVC shrink) through every served API version, and run any migration commands from the upgrade guide. + 6. **Rollback**: `helm history documentdb-operator -n documentdb-operator`, then `helm rollback documentdb-operator -n documentdb-operator --wait`. Check the previous operator still works against the new CRDs: existing clusters stay healthy and it can create a new cluster. Then roll forward again with the `helm upgrade` command from step 4. + 7. **Fresh install** on a new cluster: + ```bash + setup_kind release-fresh + helm install documentdb-operator operator/documentdb-helm-chart -n documentdb-operator --create-namespace "${LOCAL_IMAGES[@]}" --wait + ``` + Create a cluster with the current API version and do a read/write. + + Delete the kind clusters (`kind delete cluster --name release-upgrade`, `--name release-fresh`) and local images afterwards. ### Step 8: Commit and Open the PR @@ -179,7 +204,7 @@ Run all of these and report the results in the PR description. git log -1 --format='%(trailers:key=Signed-off-by)' # must print a trailer ``` Include any trailers the user's tooling requires (for example `Co-authored-by:`). -3. **Push to the fork remote** found in Step 0, not to `origin`: +3. **Push to ``** from Step 0, never to ``: ```bash git push /release-X.Y.Z ``` @@ -210,7 +235,7 @@ Release from the **merge commit on `main`** (``), never from the PR b curl -sfo /dev/null -w '%{http_code}\n' \ https://raw.githubusercontent.com/documentdb/documentdb-kubernetes-operator/X.Y.Z/operator/documentdb-helm-chart/crds/documentdb.io_dbs.yaml # 200 ``` -7. Set the repository variable `E2E_UPGRADE_PREVIOUS_VERSION` to `X.Y.Z`. The E2E control-plane upgrade spec (`test/e2e/tests/upgrade/upgrade_control_plane_test.go`) skips when it is unset; once set, it tests upgrades from this release. +7. **Know what CI does and doesn't cover.** The E2E control-plane upgrade spec (`test/e2e/tests/upgrade/upgrade_control_plane_test.go`) needs `E2E_UPGRADE_PREVIOUS_VERSION` **and** `E2E_UPGRADE_CURRENT_CHART`, the chart built by that CI run. `test-e2e.yml` defaults `E2E_UPGRADE_CURRENT_CHART` to empty, and a fixed repository variable can't point at a per-run chart artifact, so the spec is **skipped** in CI. A green `TEST - E2E` run is therefore not chart-upgrade coverage; the Step 7 kind test is. Don't claim upgrade coverage from CI unless the job log shows this spec ran rather than skipped, and flag the gap to the user if it hasn't been wired up yet. ## Output Format