Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

tftp,http: support url sources#272

Closed
bennyz wants to merge 6 commits intojumpstarter-dev:mainfrom
bennyz:http-url
Closed

tftp,http: support url sources#272
bennyz wants to merge 6 commits intojumpstarter-dev:mainfrom
bennyz:http-url

Conversation

@bennyz
Copy link
Copy Markdown
Member

@bennyz bennyz commented Feb 12, 2025

And use a base FileServer client

Summary by CodeRabbit

  • New Features

    • Introduced a unified file management interface that streamlines operations such as server control and file transfers across different protocols.
  • Refactor

    • Consolidated and simplified file operation workflows within HTTP and TFTP integrations to ensure a more consistent and maintainable user experience.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 12, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update refactors several client classes to centralize file-server functionality. The HttpServerClient and TftpServerClient classes now inherit from the new FileServerClient, with redundant file operations removed from both. In parallel, a comprehensive FileServerClient class has been introduced in another package to manage server operations such as starting, stopping, listing files, uploading, and deleting files. Documentation and method signatures were also updated to reflect these changes.

Changes

File(s) Change Summary
packages/jumpstarter-driver-http/.../client.py and
packages/jumpstarter-driver-tftp/.../client.py
Updated client classes to inherit from FileServerClient instead of DriverClient. Removed file operations (start, stop, list_files, delete_file, get_host, get_port) and, in the TFTP client, updated the put_file signature (now accepts filename, src_stream, and optional checksum).
packages/jumpstarter-driver-opendal/.../client.py Introduced a new FileServerClient class (extending DriverClient) that adds methods for starting/stopping the server, listing files, uploading files (including from a source with URL handling), deleting files, and retrieving host/port information.

Sequence Diagram(s)

sequenceDiagram
    participant User as Application
    participant Client as FileServerClient
    participant Server as FileServer

    User->>Client: start()
    User->>Client: put_file(filename, src_stream, [checksum])
    Note right of Client: Optionally compute checksum internally
    Client->>Server: Upload file data
    User->>Client: list_files()
    Client->>Server: Retrieve file list
    User->>Client: stop()
Loading

Poem

Oh, what a hop in the code today,
A refactor leap in a clever way.
Files flow smooth like a gentle stream,
With less clutter and a fresher theme.
I, the rabbit, cheer each renewed byte—
Bounding through changes with sheer delight!
🐇✨


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
Copy Markdown
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 (3)
packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (1)

11-11: Docstring is minimal, but sufficient.

The simple docstring adequately describes the purpose of get_url. If needed, clarify that the method delegates the call to the driver backend.

packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py (2)

79-90: Consider handling server startup and listing errors.

  1. start() and list_files() methods simply forward RPC calls without explicit error handling.
  2. If driver-level exceptions occur, consider catching them here to provide more context.

113-141: Potential security considerations when uploading from remote URLs.

  1. Fetching data from an arbitrary http/https endpoint can pose security risks (e.g., malicious files).
  2. Document or verify how untrusted content is handled or sanitized.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a9c72c3 and 3173856.

📒 Files selected for processing (3)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (1 hunks)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py (2 hunks)
  • packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py (1)
Learnt from: bennyz
PR: jumpstarter-dev/jumpstarter#241
File: packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py:52-60
Timestamp: 2025-01-29T11:52:43.554Z
Learning: The TFTP driver (packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver.py) handles all low-level concerns like path validation, error handling, and checksum computation. The client (packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py) should remain simple as it delegates these responsibilities to the driver.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: e2e
  • GitHub Check: pytest-matrix (3.11)
🔇 Additional comments (9)
packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (2)

3-3: Inherited base class reference looks good.

Importing FileServerClient here aligns with the new architecture consolidating file handling logic into a common client.


7-7: Dataclass inheritance approach is coherent.

Switching HttpServerClient to extend FileServerClient is consistent with the shared file server functionalities introduced across protocols. No issues found.

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py (3)

4-4: Aligned import with new base class.

Importing FileServerClient suggests that TFTP-related file operations are now consolidated in the base class.


11-12: Class inheritance is consistent with TFTP design.

Adopting FileServerClient follows the principle of keeping the TFTP client simple and delegating core functionality to the driver, as per retrieved learnings.


14-30: Checksum-based optimization is well-structured.

  1. The optional checksum parameter and conditional skip logic provide a performance boost by avoiding redundant uploads.
  2. Log message clarifies why the upload is skipped.
  3. Ensure the TFTP driver implements the "check_file_checksum" call; otherwise, this logic will fail.
packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py (4)

2-2: Importing urlparse broadens protocol support.

Adding urlparse for URL support is a solid approach. No conflicts identified.


76-78: Base class introduction is a good architectural move.

Centralizing common file server actions in FileServerClient prevents duplication and ensures consistent behavior.


91-112: Checksum usage is flexible yet requires driver support.

  1. Checking hasattr(self, "check_file_checksum") ensures compatibility with drivers that may not implement this feature.
  2. Ensure that if "client_checksum" in self.call("put_file").__code__.co_varnames: is robust against changes in the driver. This introspection approach is somewhat fragile if the driver’s method signature evolves.

142-153: Minimal methods for deletion and server info seem sufficient.

  1. Methods delete_file, get_host, and get_port are straightforward wrappers with no logic overhead.
  2. Confirm that exceptions raised by the driver are handled consistently upstream.

@bennyz bennyz marked this pull request as draft February 12, 2025 16:42
@bennyz bennyz requested a review from mangelajo February 12, 2025 16:42
path = str(Path(source).resolve())
filename = Path(path).name

with OpendalAdapter(client=self, operator=operator, path=path, mode="rb") as handle:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can be wrong, but I suspect this would make the client download and push it to the exporter through the stream...

Can we verify if there's a way to have the exporter download it directly and save the extra hop?

i.e. the presigned sources.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

so it should be ok for the authless urls i'm testing this with, based on:
https://opendal.apache.org/docs/rust/src/opendal/services/http/backend.rs.html#229

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.

Yes that's the case here.

@mangelajo
Copy link
Copy Markdown
Member

This is marked as Draft @bennyz is it still Draft?

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 19, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 4c53eaf
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67b5cc2c6bc1cb00084cdea3
😎 Deploy Preview https://deploy-preview-272--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

And use a base FileServer client

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>

CHUNK_SIZE = 4 * 1024 * 1024

class FileServerClient(DriverClient):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we also generalize the driver side common stuff?

@NickCao do you have some ideas around this?

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.

It works the same way, just factor the file server related methods into a base class.

@NickCao
Copy link
Copy Markdown
Collaborator

NickCao commented Feb 27, 2025

Superseded by jumpstarter-dev/jumpstarter#313 and jumpstarter-dev/jumpstarter#311

@NickCao NickCao closed this Feb 27, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Mar 3, 2025
@mangelajo mangelajo added this to the 0.6.0 milestone May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants