Skip to content

[ci][doc] Apply redirects on every run instead of gating on HEAD~1 - #66427

Merged
dstrodtman merged 3 commits into
masterfrom
doc-1300-fix-redirect-apply-gate
Sep 24, 2026
Merged

dstrodtman merged 3 commits into
masterfrom
doc-1300-fix-redirect-apply-gate

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

The postmerge doc: apply redirects step, enabled in #66024, has failed on every run since it was turned on, and it never applied a redirect change. The one change that merged since then, the /data/dataset.html target updated in #66024 itself, didn't reach Read the Docs until a maintainer applied it by hand.

There are two problems, and both come from the HEAD~1..HEAD gate at the top of the step:

  1. The gate checks the wrong range. The step isn't scheduled on every master merge. In the postmerge builds since 2026-09-18, it appears only in the full builds that release automation triggers, a few times a day, and not in the per-merge builds. A git diff HEAD~1 HEAD -- doc/redirects/ check sees only the single commit that build is on, so a redirect merge that isn't that commit is never applied.
  2. The skip path reports failure. All 12 runs from postmerge #19792 through #19893 logged no doc/redirects/ change in this merge; nothing to apply, then logout, then The command exited with status 1. The command runs under bash -elic, so the exit 0 likely goes through login-shell logout handling. I inferred that cause from the log and couldn't reproduce it locally.

This PR replaces the gate with two changes:

  • Converge on every run. rtd-redirects apply already converges: when the live project matches current.yaml, it makes only read calls, prints apply: no changes, and exits 0 (cli.py in anyscale-rtd-redirects 0.2.0). A redirect merge now goes live on the next postmerge run of the step, not only when it happens to be that build's commit.
  • Guard against stale checkouts. Release automation triggers postmerge with its own branch and commit (.buildkite/release-automation/pre_release.rayci.yml). In September, 18 of the 88 full postmerge builds ran on releases/*. Because apply deletes live redirects that aren't in the file, applying an older current.yaml would roll back newer redirects. The step now applies only on a master build whose doc/redirects/ matches the freshly fetched origin/master. Otherwise it logs why it skipped and passes. It skips the same way if the fetch fails. Cursor Bugbot flagged this on the first revision.

The skip path no longer calls exit, and the token is fetched only when the step applies. The step comment and doc/redirects/README.md are updated to match. The step is still skip-on-premerge and still reads the dedicated oss-ci/rtd-api-token secret.

Related PRs

Testing

  • pre-commit run --files .buildkite/doc.rayci.yml doc/redirects/README.md: passes.
  • Parsed .buildkite/doc.rayci.yml with yaml.safe_load and confirmed the doc_redirects_apply commands are the file guard, the pinned install, and the guarded apply block.
  • Extracted the guarded block, with the token fetch and apply replaced by fakes, and ran it with bash -e in a scratch git repo against a local bare origin:
    • master at the tip: applies.
    • Older master SHA with the same doc/redirects/: applies.
    • releases/2.50.0: skips, exit 0.
    • Older master SHA whose doc/redirects/ has since changed: skips, exit 0.
    • Fetch fails: skips with its own message, exit 0. The fetch runs only on master builds, and a missed apply converges on the next run.
  • rtd-redirects plan --project anyscale-ray --file doc/redirects/current.yaml --strict with 0.2.0 against the live project showed the one missed update. apply --strict --yes applied it (1 updated), and a follow-up plan reports 0 add, 0 update, 0 delete, 0 reorder. https://docs.ray.io/en/latest/data/dataset.html now 301s to /en/latest/data/api/dataset.html.
  • The step runs only on postmerge, so this PR's CI doesn't exercise it. The check is the first postmerge run after merge: it should log apply: no changes and pass.

AI assistance

This PR was prepared with AI assistance (Claude Code). I reviewed every changed line and the Buildkite evidence above.

🤖 Generated with Claude Code

The postmerge redirect apply step gated on `git diff HEAD~1 HEAD --
doc/redirects/`, but the step is scheduled only on some postmerge builds,
not on every master merge. A redirect change that did not land as the
HEAD of one of those builds was never applied. Every run since the step
was enabled also took the early-exit path and reported status 1.

Drop the gate. `rtd-redirects apply` already converges and exits 0
with "apply: no changes" when the live project matches current.yaml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman requested review from a team as code owners September 23, 2026 17:24

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the diff-gating logic from the postmerge documentation redirect step in .buildkite/doc.rayci.yml and updates the corresponding documentation in doc/redirects/README.md. Since this step is only scheduled on some postmerge builds, running it on every postmerge run ensures that all redirect changes eventually converge. The review feedback suggests clarifying 'every run' to 'every postmerge run' in both the YAML comments and the README to avoid ambiguity, as this step is skipped on premerge builds.

Comment thread .buildkite/doc.rayci.yml Resolved
Comment thread doc/redirects/README.md Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit eb99809. Configure here.

Comment thread .buildkite/doc.rayci.yml Resolved
Release automation triggers postmerge with its own branch and commit,
including releases/* branches and master SHAs older than the tip. Since
`apply` deletes live redirects missing from the file, an ungated apply
from such a checkout could roll back newer redirects.

Apply only on master builds whose doc/redirects/ matches the fetched
origin/master tip; otherwise log why and pass. The skip path avoids
`exit`, and the token is fetched only when applying.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation devprod labels Sep 23, 2026
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Sep 24, 2026
dstrodtman added a commit that referenced this pull request Sep 24, 2026
…66459)

## Why are these changes needed?

The Ray example and tutorial templates are fetched at doc build time
through `sphinx-collections` (`doc/source/template_collections.py`) and
build under `/_collections/<target>/`. #63971 deleted the stale in-tree
copies, but no redirects were added for the URLs those copies served.

Probing docs.ray.io shows where it broke:

- `releases-2.55.1` and earlier: the old path, such as
`/ray-overview/examples/e2e-rag/README.html`, returns 200. The
`/_collections/` path returns 404.
- `releases-2.56.0` and later, including `/latest` and `/master`: the
old path returns 404. The `/_collections/` path returns 200.

So since 2.56.0 became `/latest`, external links and search results
pointing at the old template pages have returned 404. Some of the old
paths fall under the legacy catch-alls (`/serve/tutorials/*`,
`/train/examples/*`, `/tune/examples/*`), which land readers on a
generic index instead of the page they wanted.

## What

This PR adds 63 `page` redirects to `doc/redirects/current.yaml`, one
per removed template URL that was actually served on 2.55.1, each
pointing at that page's `/_collections/` path:

- 40 move 1:1, so the target is `/_collections/<same path>`.
- 23 lived under a `content/` directory the sync no longer produces, so
the target drops that segment. A few single-notebook templates now build
only a `README`, so those point at the `README`:
`unstructured_data_ingestion`, `tune_pytorch_asha`, and
`model_composition_recsys`, which was renamed to
`model-composition-recsys`.

The block sits right after the Ray Data rules and ahead of every
wildcard rule, so the specific rules win over the catch-alls. `page`
rules without `force` fire only on 404, so 2.55 and earlier keep serving
their own in-tree copies.

Out of scope, and deliberately skipped:

- 9 removed paths that already returned 404 on 2.55.1, because they were
excluded from the build. These are the `llamafactory-llm-fine-tune`
pages and two `train/tutorials/content/*/README` indexes.
- 3 paths whose only 2.55.1 response was a catch-all 301, so they were
never pages.

## Related PRs

- #63971 removed the in-tree template copies.
- #66427 fixes the postmerge redirect apply step. Once it merges, this
change goes live on the next postmerge run. Until then, a maintainer
applies it manually.
- Duplicate check: no open PR touches template redirects. The only other
open PRs that touch `doc/redirects/` are #66427 (CI apply gate) and
#66027 (release-gated `master.yaml`), and neither adds these rules.
#66027 also edits `current.yaml`, so whichever merges second might need
a trivial rebase.

## Testing

- Built the URL list from `git show --name-status 70eade0` (#63971),
keeping deleted pages whose URL isn't produced at HEAD.
- Probed every old URL on `releases-2.55.1`, and every candidate target
on `/en/master/`. Targets were cross-checked against the `_collections/`
docnames in the live `objects.inv`. All 63 targets return 200.
- `rtd-redirects validate doc/redirects/current.yaml`: 0 errors. It
reports the same 44 pre-existing chain warnings as master and none from
the new rules.
- `rtd-redirects diff-file --file doc/redirects/current.yaml --base
upstream/master --head HEAD --repo .`: 63 add, 0 update, 0 delete.
- `rtd-redirects plan --project anyscale-ray --file
doc/redirects/current.yaml` against the live project: 63 add, 0 update,
0 delete. The reorders are position shifts from the insertion.
- `pre-commit run --files doc/redirects/current.yaml`: passes.
- Five `mcp-ray-serve` paths contain spaces, and one also contains
parentheses. Read the Docs matches redirects on the Django-decoded
request path, so a `%20` request should match the literal space in
`from`. I'll confirm that with a live request after apply.

## AI assistance

This PR was prepared with AI assistance (Claude Code). I reviewed every
added rule and the probe results above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread .buildkite/doc.rayci.yml Outdated
set +x
export RTD_API_TOKEN="$$(aws secretsmanager get-secret-value --region us-west-2 --secret-id oss-ci/rtd-api-token --query SecretString --output text)"
- rtd-redirects apply --project anyscale-ray --file doc/redirects/current.yaml --yes --strict
git fetch -q origin master

@elliot-barn elliot-barn Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move the fetch into the elif
elif ! { git fetch -q origin master && git diff --quiet HEAD FETCH_HEAD -- doc/redirects/; }; then
No need to git fetch if its not on master

Move the stale-checkout fetch into the guard's elif chain so non-master
builds skip before fetching. A failed fetch now skips the step with its
own message instead of failing it, since apply converges on the next run.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman enabled auto-merge (squash) September 24, 2026 18:03
@dstrodtman
dstrodtman merged commit 8253aac into master Sep 24, 2026
7 checks passed
@dstrodtman
dstrodtman deleted the doc-1300-fix-redirect-apply-gate branch September 24, 2026 18:27
dstrodtman added a commit that referenced this pull request Oct 1, 2026
…ch fails (#66624)

## What

Two changes to the postmerge `:book: doc: apply redirects` step in
`.buildkite/doc.rayci.yml`:

1. Fail the step at the Secrets Manager fetch, with a message that names
the secret and the permission it needs, when `get-secret-value` fails or
returns an empty value. Previously `export RTD_API_TOKEN="$(aws ...)"`
returned `export`'s status rather than `aws`'s. The step fell through to
`rtd-redirects apply` with an empty token, which failed with
`RTD_API_TOKEN is not set. Export your RtD API token before running.`
That message reads like a local-environment problem and hides the real
AWS error a few lines up.
2. Document the IAM permission the runner role needs, in the step
comment.

## Why: the step has never been able to read its token

Every master postmerge run of this step since it was enabled in #66024
and reworked in #66427 has failed at the secret fetch, for example
[postmerge
#20026](https://buildkite.com/ray-project/postmerge/builds/20026) and
[#20049](https://buildkite.com/ray-project/postmerge/builds/20049). The
job log shows:

```
An error occurred (AccessDeniedException) when calling the GetSecretValue operation:
User: arn:aws:sts::029272617770:assumed-role/bk-runner-queue-small-branch-Role/i-... is not authorized to perform:
secretsmanager:GetSecretValue on resource: oss-ci/rtd-api-token
```

The `oss-ci/rtd-api-token` secret exists, but the runner role can't read
it. Release-branch builds such as
[#20050](https://buildkite.com/ray-project/postmerge/builds/20050)
aren't affected, because the step's branch guard skips them before the
fetch.

## IAM grant needed (CI infra)

This PR doesn't fix the access. It makes the failure say what's wrong.
For the step to work, the CI stack needs this grant:

- **Principal:** `bk-runner-queue-small-branch-Role`, the role of the
postmerge runner queue this step lands on. The step sets no
`instance_type`, so it runs on the default small queue.
- **Action:** `secretsmanager:GetSecretValue`
- **Resource:** the `oss-ci/rtd-api-token` secret in `us-west-2`,
account `029272617770`. Scope it to that one secret ARN, not a wildcard.
The token is deliberately isolated from other steps.
- If the secret uses a customer-managed KMS key, the role also needs
`kms:Decrypt` on that key.

`fossa analyze` (`.buildkite/others.rayci.yml`) reads
`oss-ci/fossa-api-key` the same way from an `instance_type: small` step,
so the grant should follow whatever pattern covers that secret.

Until the grant lands, this step keeps failing on master postmerge
builds, now with a clear message. It doesn't block master. If the
release-candidate noise is a problem in the meantime, re-adding a
`disabled` tag to the step turns it off, as the step comment describes.

## Not a duplicate

No open PR touches the redirect apply step. This follows up on #66024
and #66427.

## Testing

- Pulled the command block out of the YAML, replaced `$$` with `$` as
Buildkite does, and ran the apply branch under `bash -elc` with a stub
`aws`:
- `AccessDeniedException`, exit 254: the step prints the new error and
exits 1 without calling `apply`.
  - Empty secret value: the step prints the new error and exits 1.
- Non-empty value: the token is exported and reaches `rtd-redirects
apply`.
- `pre-commit run --files .buildkite/doc.rayci.yml`: the generic
whitespace, end-of-file, and large-file hooks passed. No
language-specific hook applies to this file.
- No Buildkite run. The step is `skip-on-premerge`, so a PR build can't
exercise it. Its first real run is the next master postmerge build after
merge.

## AI assistance

AI assistance (Claude Code) prepared this change and ran the checks
above. The submitter reviews every changed line before merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ay-project#66459)

## Why are these changes needed?

The Ray example and tutorial templates are fetched at doc build time
through `sphinx-collections` (`doc/source/template_collections.py`) and
build under `/_collections/<target>/`. ray-project#63971 deleted the stale in-tree
copies, but no redirects were added for the URLs those copies served.

Probing docs.ray.io shows where it broke:

- `releases-2.55.1` and earlier: the old path, such as
`/ray-overview/examples/e2e-rag/README.html`, returns 200. The
`/_collections/` path returns 404.
- `releases-2.56.0` and later, including `/latest` and `/master`: the
old path returns 404. The `/_collections/` path returns 200.

So since 2.56.0 became `/latest`, external links and search results
pointing at the old template pages have returned 404. Some of the old
paths fall under the legacy catch-alls (`/serve/tutorials/*`,
`/train/examples/*`, `/tune/examples/*`), which land readers on a
generic index instead of the page they wanted.

## What

This PR adds 63 `page` redirects to `doc/redirects/current.yaml`, one
per removed template URL that was actually served on 2.55.1, each
pointing at that page's `/_collections/` path:

- 40 move 1:1, so the target is `/_collections/<same path>`.
- 23 lived under a `content/` directory the sync no longer produces, so
the target drops that segment. A few single-notebook templates now build
only a `README`, so those point at the `README`:
`unstructured_data_ingestion`, `tune_pytorch_asha`, and
`model_composition_recsys`, which was renamed to
`model-composition-recsys`.

The block sits right after the Ray Data rules and ahead of every
wildcard rule, so the specific rules win over the catch-alls. `page`
rules without `force` fire only on 404, so 2.55 and earlier keep serving
their own in-tree copies.

Out of scope, and deliberately skipped:

- 9 removed paths that already returned 404 on 2.55.1, because they were
excluded from the build. These are the `llamafactory-llm-fine-tune`
pages and two `train/tutorials/content/*/README` indexes.
- 3 paths whose only 2.55.1 response was a catch-all 301, so they were
never pages.

## Related PRs

- ray-project#63971 removed the in-tree template copies.
- ray-project#66427 fixes the postmerge redirect apply step. Once it merges, this
change goes live on the next postmerge run. Until then, a maintainer
applies it manually.
- Duplicate check: no open PR touches template redirects. The only other
open PRs that touch `doc/redirects/` are ray-project#66427 (CI apply gate) and
ray-project#66027 (release-gated `master.yaml`), and neither adds these rules.
ray-project#66027 also edits `current.yaml`, so whichever merges second might need
a trivial rebase.

## Testing

- Built the URL list from `git show --name-status 70eade0` (ray-project#63971),
keeping deleted pages whose URL isn't produced at HEAD.
- Probed every old URL on `releases-2.55.1`, and every candidate target
on `/en/master/`. Targets were cross-checked against the `_collections/`
docnames in the live `objects.inv`. All 63 targets return 200.
- `rtd-redirects validate doc/redirects/current.yaml`: 0 errors. It
reports the same 44 pre-existing chain warnings as master and none from
the new rules.
- `rtd-redirects diff-file --file doc/redirects/current.yaml --base
upstream/master --head HEAD --repo .`: 63 add, 0 update, 0 delete.
- `rtd-redirects plan --project anyscale-ray --file
doc/redirects/current.yaml` against the live project: 63 add, 0 update,
0 delete. The reorders are position shifts from the insertion.
- `pre-commit run --files doc/redirects/current.yaml`: passes.
- Five `mcp-ray-serve` paths contain spaces, and one also contains
parentheses. Read the Docs matches redirects on the Django-decoded
request path, so a `%20` request should match the literal space in
`from`. I'll confirm that with a live request after apply.

## AI assistance

This PR was prepared with AI assistance (Claude Code). I reviewed every
added rule and the probe results above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ay-project#66427)

## Why are these changes needed?

The postmerge `doc: apply redirects` step, enabled in ray-project#66024, has failed
on every run since it was turned on, and it never applied a redirect
change. The one change that merged since then, the `/data/dataset.html`
target updated in ray-project#66024 itself, didn't reach Read the Docs until a
maintainer applied it by hand.

There are two problems, and both come from the `HEAD~1..HEAD` gate at
the top of the step:

1. **The gate checks the wrong range.** The step isn't scheduled on
every master merge. In the postmerge builds since 2026-09-18, it appears
only in the full builds that release automation triggers, a few times a
day, and not in the per-merge builds. A `git diff HEAD~1 HEAD --
doc/redirects/` check sees only the single commit that build is on, so a
redirect merge that isn't that commit is never applied.
2. **The skip path reports failure.** All 12 runs from [postmerge
ray-project#19792](https://buildkite.com/ray-project/postmerge/builds/19792)
through
[ray-project#19893](https://buildkite.com/ray-project/postmerge/builds/19893)
logged `no doc/redirects/ change in this merge; nothing to apply`, then
`logout`, then `The command exited with status 1`. The command runs
under `bash -elic`, so the `exit 0` likely goes through login-shell
logout handling. I inferred that cause from the log and couldn't
reproduce it locally.

This PR replaces the gate with two changes:

- **Converge on every run.** `rtd-redirects apply` already converges:
when the live project matches `current.yaml`, it makes only read calls,
prints `apply: no changes`, and exits 0 (`cli.py` in
anyscale-rtd-redirects 0.2.0). A redirect merge now goes live on the
next postmerge run of the step, not only when it happens to be that
build's commit.
- **Guard against stale checkouts.** Release automation triggers
postmerge with its own branch and commit
(`.buildkite/release-automation/pre_release.rayci.yml`). In September,
18 of the 88 full postmerge builds ran on `releases/*`. Because `apply`
deletes live redirects that aren't in the file, applying an older
`current.yaml` would roll back newer redirects. The step now applies
only on a `master` build whose `doc/redirects/` matches the freshly
fetched `origin/master`. Otherwise it logs why it skipped and passes. It
skips the same way if the fetch fails. Cursor Bugbot flagged this on the
first revision.

The skip path no longer calls `exit`, and the token is fetched only when
the step applies. The step comment and `doc/redirects/README.md` are
updated to match. The step is still `skip-on-premerge` and still reads
the dedicated `oss-ci/rtd-api-token` secret.

## Related PRs

- ray-project#66024 enabled the step.
- ray-project#65866 added it, disabled.
- Duplicate check: no open PR touches this step. I searched open PRs for
"redirect apply" and reviewed the open redirect PR ray-project#66027, which stages
release-gated redirects and doesn't change the apply gate.

## Testing

- `pre-commit run --files .buildkite/doc.rayci.yml
doc/redirects/README.md`: passes.
- Parsed `.buildkite/doc.rayci.yml` with `yaml.safe_load` and confirmed
the `doc_redirects_apply` commands are the file guard, the pinned
install, and the guarded apply block.
- Extracted the guarded block, with the token fetch and `apply` replaced
by fakes, and ran it with `bash -e` in a scratch git repo against a
local bare `origin`:
    - `master` at the tip: applies.
    - Older `master` SHA with the same `doc/redirects/`: applies.
    - `releases/2.50.0`: skips, exit 0.
- Older `master` SHA whose `doc/redirects/` has since changed: skips,
exit 0.
- Fetch fails: skips with its own message, exit 0. The fetch runs only
on `master` builds, and a missed apply converges on the next run.
- `rtd-redirects plan --project anyscale-ray --file
doc/redirects/current.yaml --strict` with 0.2.0 against the live project
showed the one missed update. `apply --strict --yes` applied it (`1
updated`), and a follow-up `plan` reports `0 add, 0 update, 0 delete, 0
reorder`. `https://docs.ray.io/en/latest/data/dataset.html` now 301s to
`/en/latest/data/api/dataset.html`.
- The step runs only on postmerge, so this PR's CI doesn't exercise it.
The check is the first postmerge run after merge: it should log `apply:
no changes` and pass.

## AI assistance

This PR was prepared with AI assistance (Claude Code). I reviewed every
changed line and the Buildkite evidence above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ch fails (ray-project#66624)

## What

Two changes to the postmerge `:book: doc: apply redirects` step in
`.buildkite/doc.rayci.yml`:

1. Fail the step at the Secrets Manager fetch, with a message that names
the secret and the permission it needs, when `get-secret-value` fails or
returns an empty value. Previously `export RTD_API_TOKEN="$(aws ...)"`
returned `export`'s status rather than `aws`'s. The step fell through to
`rtd-redirects apply` with an empty token, which failed with
`RTD_API_TOKEN is not set. Export your RtD API token before running.`
That message reads like a local-environment problem and hides the real
AWS error a few lines up.
2. Document the IAM permission the runner role needs, in the step
comment.

## Why: the step has never been able to read its token

Every master postmerge run of this step since it was enabled in ray-project#66024
and reworked in ray-project#66427 has failed at the secret fetch, for example
[postmerge
ray-project#20026](https://buildkite.com/ray-project/postmerge/builds/20026) and
[ray-project#20049](https://buildkite.com/ray-project/postmerge/builds/20049). The
job log shows:

```
An error occurred (AccessDeniedException) when calling the GetSecretValue operation:
User: arn:aws:sts::029272617770:assumed-role/bk-runner-queue-small-branch-Role/i-... is not authorized to perform:
secretsmanager:GetSecretValue on resource: oss-ci/rtd-api-token
```

The `oss-ci/rtd-api-token` secret exists, but the runner role can't read
it. Release-branch builds such as
[ray-project#20050](https://buildkite.com/ray-project/postmerge/builds/20050)
aren't affected, because the step's branch guard skips them before the
fetch.

## IAM grant needed (CI infra)

This PR doesn't fix the access. It makes the failure say what's wrong.
For the step to work, the CI stack needs this grant:

- **Principal:** `bk-runner-queue-small-branch-Role`, the role of the
postmerge runner queue this step lands on. The step sets no
`instance_type`, so it runs on the default small queue.
- **Action:** `secretsmanager:GetSecretValue`
- **Resource:** the `oss-ci/rtd-api-token` secret in `us-west-2`,
account `029272617770`. Scope it to that one secret ARN, not a wildcard.
The token is deliberately isolated from other steps.
- If the secret uses a customer-managed KMS key, the role also needs
`kms:Decrypt` on that key.

`fossa analyze` (`.buildkite/others.rayci.yml`) reads
`oss-ci/fossa-api-key` the same way from an `instance_type: small` step,
so the grant should follow whatever pattern covers that secret.

Until the grant lands, this step keeps failing on master postmerge
builds, now with a clear message. It doesn't block master. If the
release-candidate noise is a problem in the meantime, re-adding a
`disabled` tag to the step turns it off, as the step comment describes.

## Not a duplicate

No open PR touches the redirect apply step. This follows up on ray-project#66024
and ray-project#66427.

## Testing

- Pulled the command block out of the YAML, replaced `$$` with `$` as
Buildkite does, and ran the apply branch under `bash -elc` with a stub
`aws`:
- `AccessDeniedException`, exit 254: the step prints the new error and
exits 1 without calling `apply`.
  - Empty secret value: the step prints the new error and exits 1.
- Non-empty value: the token is exported and reaches `rtd-redirects
apply`.
- `pre-commit run --files .buildkite/doc.rayci.yml`: the generic
whitespace, end-of-file, and large-file hooks passed. No
language-specific hook applies to this file.
- No Buildkite run. The step is `skip-on-premerge`, so a PR build can't
exercise it. Its first real run is the next master postmerge build after
merge.

## AI assistance

AI assistance (Claude Code) prepared this change and ran the checks
above. The submitter reviews every changed line before merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devprod docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants