Skip to content

Commit

Permalink
storcon: add peer token for peer to peer communication (#9695)
Browse files Browse the repository at this point in the history
## Problem

We wish to stop using admin tokens in the infra repo, but step down
requests use the admin token.

## Summary of Changes

Introduce a new "ControllerPeer" scope and use it for step-down requests.
  • Loading branch information
VladLazar authored Nov 11, 2024
1 parent 2fcac0e commit ceaa80f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions libs/utils/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ pub enum Scope {
/// Allows access to storage controller APIs used by the scrubber, to interrogate the state
/// of a tenant & post scrub results.
Scrubber,

/// This scope is used for communication with other storage controller instances.
/// At the time of writing, this is only used for the step down request.
#[serde(rename = "controller_peer")]
ControllerPeer,
}

/// JWT payload. See docs/authentication.md for the format
Expand Down
3 changes: 2 additions & 1 deletion pageserver/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ pub fn check_permission(claims: &Claims, tenant_id: Option<TenantId>) -> Result<
| Scope::SafekeeperData
| Scope::GenerationsApi
| Scope::Infra
| Scope::Scrubber,
| Scope::Scrubber
| Scope::ControllerPeer,
_,
) => Err(AuthError(
format!(
Expand Down
3 changes: 2 additions & 1 deletion safekeeper/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ pub fn check_permission(claims: &Claims, tenant_id: Option<TenantId>) -> Result<
| Scope::PageServerApi
| Scope::GenerationsApi
| Scope::Infra
| Scope::Scrubber,
| Scope::Scrubber
| Scope::ControllerPeer,
_,
) => Err(AuthError(
format!(
Expand Down
2 changes: 1 addition & 1 deletion storage_controller/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ async fn handle_update_preferred_azs(req: Request<Body>) -> Result<Response<Body
}

async fn handle_step_down(req: Request<Body>) -> Result<Response<Body>, ApiError> {
check_permissions(&req, Scope::Admin)?;
check_permissions(&req, Scope::ControllerPeer)?;

let req = match maybe_forward(req).await {
ForwardOutcome::Forwarded(res) => {
Expand Down

1 comment on commit ceaa80f

@github-actions
Copy link

Choose a reason for hiding this comment

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

5446 tests run: 5205 passed, 9 failed, 232 skipped (full report)


Failures on Postgres 16

  • test_sharded_ingest[github-actions-selfhosted-1]: release-x86-64
  • test_compaction[github-actions-selfhosted]: release-x86-64
  • test_compaction_l0_memory[github-actions-selfhosted]: release-x86-64
  • test_download_churn[github-actions-selfhosted-1-tokio-epoll-uring-30]: release-x86-64
  • test_download_churn[github-actions-selfhosted-1-std-fs-30]: release-x86-64
  • test_download_churn[github-actions-selfhosted-10-tokio-epoll-uring-30]: release-x86-64
  • test_download_churn[github-actions-selfhosted-10-std-fs-30]: release-x86-64
  • test_download_churn[github-actions-selfhosted-100-tokio-epoll-uring-30]: release-x86-64
  • test_download_churn[github-actions-selfhosted-100-std-fs-30]: release-x86-64
# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_sharded_ingest[release-pg16-github-actions-selfhosted-1] or test_compaction[release-pg16-github-actions-selfhosted] or test_compaction_l0_memory[release-pg16-github-actions-selfhosted] or test_download_churn[release-pg16-github-actions-selfhosted-1-tokio-epoll-uring-30] or test_download_churn[release-pg16-github-actions-selfhosted-1-std-fs-30] or test_download_churn[release-pg16-github-actions-selfhosted-10-tokio-epoll-uring-30] or test_download_churn[release-pg16-github-actions-selfhosted-10-std-fs-30] or test_download_churn[release-pg16-github-actions-selfhosted-100-tokio-epoll-uring-30] or test_download_churn[release-pg16-github-actions-selfhosted-100-std-fs-30]"
Flaky tests (1)

Postgres 17

Code coverage* (full report)

  • functions: 31.7% (7871 of 24806 functions)
  • lines: 49.4% (62278 of 126036 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
ceaa80f at 2024-11-11T11:33:20.766Z :recycle:

Please sign in to comment.