Skip to content

Conversation

@agners
Copy link
Member

@agners agners commented Apr 23, 2025

Proposed change

Currently we have the /refresh_updates endpoint which updates the main component versions (Core, OS, Supervisor, Plug-ins) and the add-on store at the same time. This leads to much more updates then necessary.

To allow more fine grained update refresh control introduce a new endpoint /refresh_update which only refreshes the main component versions.

The /store/reload endpoint already allows to update the add-on store only.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

Summary by CodeRabbit

  • New Features
    • Introduced a new API endpoint to refresh updater information independently from other components.
  • Tests
    • Added tests to verify the new updater refresh endpoint functions correctly.

@agners agners added the new-feature A new feature label Apr 23, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 23, 2025

📝 Walkthrough

Walkthrough

A new POST API endpoint /reload_updates has been introduced. The endpoint is registered in the root API handler and implemented as an asynchronous method in the APIRoot class. The new reload_updates method refreshes only the updater's update information, distinct from the existing method that refreshes both the updater and the store. A corresponding test was added to verify this new endpoint. No changes were made to the signatures of existing public entities.

Changes

File(s) Change Summary
supervisor/api/init.py Registered a new POST route /reload_updates in the root API, mapping it to APIRoot.reload_updates.
supervisor/api/root.py Added reload_updates async method to APIRoot for refreshing only the updater's update information.
tests/api/test_root.py Added async test test_api_reload_updates to verify the new /reload_updates endpoint functionality.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API (RestAPI/APIRoot)
    participant Updater

    Client->>API: POST /reload_updates
    API->>Updater: reload()
    Updater-->>API: Reload complete
    API-->>Client: Response
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92509b4 and ae714e9.

📒 Files selected for processing (1)
  • supervisor/api/__init__.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • supervisor/api/init.py
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build armv7 supervisor
  • GitHub Check: Build armhf supervisor
  • GitHub Check: Build aarch64 supervisor
  • GitHub Check: Run tests Python 3.13.3
  • GitHub Check: Check pylint
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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 or @coderabbitai title 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.

@agners agners force-pushed the add-dedicated-update-refresh branch from 08b7819 to 6075cfc Compare April 23, 2025 09:30
Currently we have the /refresh_updates endpoint which updates the main
component versions (Core, OS, Supervisor, Plug-ins) and the add-on
store at the same time. This combined update causes more update
information reloads than necessary.

To allow fine grained update refresh control introduce a new endpoint
/reload_updates which asks Supervisor to only update main component
versions (learned through the version json files).

The /store/reload endpoint already allows to update the add-on store
separately.
@agners agners force-pushed the add-dedicated-update-refresh branch from 6075cfc to 906c24f Compare April 23, 2025 11:19
Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
tests/api/test_root.py (1)

86-99: Good addition of a test case for the new /reload_updates endpoint.

The test correctly verifies that the endpoint refreshes only the updater information by patching and asserting that fetch_data is called exactly once. This aligns with the PR objective of creating a more fine-grained update refresh process.

Consider enhancing the test to explicitly verify that coresys.store.reload is NOT called when accessing this endpoint, which would further emphasize the key differentiation from the existing /refresh_updates endpoint:

async def test_api_reload_updates(
    coresys: CoreSys,
    api_client: TestClient,
):
    """Test reload updates."""
    coresys.updater.channel = UpdateChannel.STABLE
+   coresys.store.reload = AsyncMock()
    with (
        patch("supervisor.updater.Updater.fetch_data") as fetch_data,
    ):
        resp = await api_client.post("/reload_updates")

        fetch_data.assert_called_once_with()
+       assert not coresys.store.reload.called

    assert resp.status == 200
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 906c24f and 115b7d6.

📒 Files selected for processing (1)
  • tests/api/test_root.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build armv7 supervisor
  • GitHub Check: Build armhf supervisor
  • GitHub Check: Build aarch64 supervisor
  • GitHub Check: Run tests Python 3.13.3
🔇 Additional comments (3)
tests/api/test_root.py (3)

4-5: Appropriate import additions.

The new imports are correctly added to support the test case's requirements.


6-6: Properly imported TestClient for type hinting.

The TestClient import allows for proper type annotation in the test function parameters.


9-9: Correctly imported UpdateChannel enum.

The UpdateChannel enum is properly imported to set up the test environment.

@agners agners force-pushed the add-dedicated-update-refresh branch from 115b7d6 to 92509b4 Compare April 23, 2025 12:51
Copy link
Member

@sairon sairon left a comment

Choose a reason for hiding this comment

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

Looks good. But let's not forgot about the client library and documentation update (along with the deprecation notice probably).

@agners agners changed the title Add dedicated version update refresh Add dedicated version update refresh for main components Apr 24, 2025
@agners agners merged commit de497cd into main Apr 24, 2025
22 checks passed
@agners agners deleted the add-dedicated-update-refresh branch April 24, 2025 13:46
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants