Skip to content

[ci][doc] Fail the redirect apply step clearly when the RtD token fetch fails - #66624

Merged
dstrodtman merged 2 commits into
masterfrom
doc-1725-redirect-secret-failure
Oct 1, 2026
Merged

dstrodtman merged 2 commits into
masterfrom
doc-1725-redirect-secret-failure

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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 and #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 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

…ch fails

`export RTD_API_TOKEN="$(aws ...)"` returns export's status, so a failed
Secrets Manager fetch fell through to `rtd-redirects apply` with an empty
token and reported "RTD_API_TOKEN is not set", hiding the AWS error.
Assign and export separately, fail at the fetch with a message naming the
secret and the required permission, and document the IAM grant the runner
role needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman marked this pull request as ready for review October 1, 2026 12:32
@dstrodtman
dstrodtman requested a review from a team as a code owner October 1, 2026 12:32
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Oct 1, 2026

@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 improves error handling when fetching the ReadTheDocs API token from AWS Secrets Manager in the Buildkite pipeline by separating the token assignment from the export command and checking for empty values. Feedback suggests redirecting the error message to standard error (stderr) and splitting the long log message into multiple lines for better readability.

Comment thread .buildkite/doc.rayci.yml Resolved
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 core Issues that should be addressed in Ray Core devprod labels Oct 1, 2026
@dstrodtman
dstrodtman merged commit 4188050 into master Oct 1, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-1725-redirect-secret-failure branch October 1, 2026 18:54
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

core Issues that should be addressed in Ray Core 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