Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change HTTP method to comply with spec #9100

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

nikitakalyanov
Copy link
Contributor

@nikitakalyanov nikitakalyanov commented Sep 23, 2024

There is discrepancy with the spec, it has PUT

Problem

Summary of changes

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • Do we need to implement analytics? if so did you add the relevant metrics to the dashboard?
  • If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section.

Checklist before merging

  • Do not forget to reformat commit message to not include the above checklist

Summary by CodeRabbit

  • New Features

    • Updated the archival configuration endpoint to use the PUT method, reflecting a change from creating to updating resources.
  • Bug Fixes

    • Corrected the HTTP method for the archival configuration across multiple components to ensure consistency in API interactions.

There is discrepancy with the spec, it has PUT
@nikitakalyanov nikitakalyanov requested a review from a team as a code owner September 23, 2024 11:50
Copy link

coderabbitai bot commented Sep 23, 2024

Walkthrough

The changes across the various files involve modifying the HTTP method for handling archival configuration requests from POST to PUT. This adjustment reflects a shift in the intended operation from creating new resources to updating existing ones. The affected routes and client methods have been updated accordingly to ensure consistency in the API's behavior.

Changes

Files Change Summary
pageserver/client/src/mgmt_api.rs Changed HTTP method from POST to PUT for the request in the Client implementation.
pageserver/src/http/routes.rs Updated route for archival configuration from POST to PUT.
storage_controller/src/http.rs Changed HTTP method from POST to PUT for the archival configuration route in make_router.
storage_controller/src/pageserver_client.rs Modified timeline_archival_config request method from Method::Post to Method::Put.
test_runner/fixtures/pageserver/http.py Updated request method from POST to PUT in the timeline_archival_config function.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server

    Client->>Server: PUT /v1/tenant/{tenant_id}/timeline/{timeline_id}/archival_config
    Server-->>Client: 200 OK (Updated successfully)
Loading

Poem

🐇 In the meadow where bunnies play,
A change was made, hip-hip-hooray!
From POST to PUT, a shift so bright,
Updating configs, all feels just right!
With hops and jumps, we celebrate,
For better APIs, we can’t wait! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
storage_controller/src/pageserver_client.rs (1)

Server-side PUT method implementation missing

The change from POST to PUT for the timeline_archival_config endpoint updates the HTTP method. However, the server-side implementation for handling PUT requests was not found. This may lead to the server not recognizing PUT requests for this endpoint, causing potential runtime errors and inconsistent API behavior.

Please ensure that the server correctly handles PUT requests for timeline_archival_config and update the API documentation to reflect this change.

Analysis chain

Line range hint 239-246: Approve the HTTP method change and verify consistency

The change from POST to PUT for the timeline_archival_config endpoint aligns with the PR objectives to comply with the spec. This modification implies that the endpoint is now used for updating existing resources rather than creating new ones.

To ensure consistency and prevent potential issues, please run the following verification steps:

  1. Check for any client code that might be affected by this change:

  2. Verify that the server-side implementation correctly handles PUT requests for this endpoint:

  3. Update any relevant API documentation to reflect this change:

Please ensure that all affected areas are updated accordingly and that the change is thoroughly tested to prevent any regressions.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any calls to timeline_archival_config in the codebase
rg --type rust "timeline_archival_config" -C 5

Length of output: 9025


Script:

#!/bin/bash
# Search for the server-side implementation of the timeline_archival_config endpoint
rg --type rust "fn.*timeline_archival_config.*Method::Put" -C 10

Length of output: 66


Script:

#!/bin/bash
# Search for API documentation mentioning timeline_archival_config
rg --type markdown "timeline_archival_config"

Length of output: 45

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 59b4c2e and 7564667.

Files selected for processing (5)
  • pageserver/client/src/mgmt_api.rs (1 hunks)
  • pageserver/src/http/routes.rs (1 hunks)
  • storage_controller/src/http.rs (1 hunks)
  • storage_controller/src/pageserver_client.rs (1 hunks)
  • test_runner/fixtures/pageserver/http.py (1 hunks)
Additional comments not posted (2)
test_runner/fixtures/pageserver/http.py (1)

634-636: Approve changing the HTTP method from POST to PUT.

Modifying the HTTP method from POST to PUT for updating the archival configuration aligns with the RESTful convention of using PUT for updates to existing resources. As long as the server endpoint handles PUT requests correctly for this operation, this change improves the adherence to HTTP method semantics without altering the functionality.

storage_controller/src/http.rs (1)

Line range hint 1852-1862: HTTP method change aligns with RESTful principles, but consider implications

The change from POST to PUT for the /v1/tenant/:tenant_id/timeline/:timeline_id/archival_config endpoint aligns better with RESTful API design principles, as PUT is typically used for updating existing resources. However, consider the following points:

  1. Backward compatibility: This change might break existing clients expecting a POST endpoint. Ensure that this change is communicated clearly in the API documentation and consider versioning the API if backward compatibility is a concern.

  2. Consistency: Verify that this change is consistent with other similar endpoints in the API to maintain a uniform design.

  3. Implementation impact: Review the handle_tenant_timeline_archival_config function to ensure it correctly handles the semantics of a PUT request (i.e., updating an existing resource) rather than a POST request (creating a new resource).

To check for consistency and potential impacts, run the following script:

pageserver/client/src/mgmt_api.rs Show resolved Hide resolved
pageserver/src/http/routes.rs Show resolved Hide resolved
@nikitakalyanov nikitakalyanov requested a review from jcsp September 23, 2024 12:22
Copy link

github-actions bot commented Sep 23, 2024

5003 tests run: 4839 passed, 0 failed, 164 skipped (full report)


Flaky tests (3)

Postgres 17

Postgres 16

Code coverage* (full report)

  • functions: 32.1% (7447 of 23214 functions)
  • lines: 49.9% (59956 of 120184 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
7564667 at 2024-09-23T13:52:00.946Z :recycle:

@arpad-m arpad-m merged commit f446e08 into main Sep 23, 2024
83 checks passed
@arpad-m arpad-m deleted the nikitakalyanov/change-method branch September 23, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants