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

#1447 - back-end usage scenario #1536

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

4ntoine
Copy link
Contributor

@4ntoine 4ntoine commented Nov 3, 2021

Add .proto file (messages and a service), generate go files.
(Draft to demonstrate the proposal).

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?
    The MR Draft demonstrates the back-end scenario when client and server are on different hosts thus making direct files access problematic. So the client can't read neither the sketches content, nor the compiled binaries.
  • What is the current behavior?
    The feature is not implemented
  • What is the new behavior?
    There is "file system" service allowing to request file content.
  • Other information:
    This is an alternative to returning file content every here and there.

See how to contribute

Add .proto file (messages and a service), generate go files.
(Draft to demonstrate the proposal).
@4ntoine 4ntoine force-pushed the issue-1447_file-service branch 2 times, most recently from 24f5c6b to 4631037 Compare November 4, 2021 06:04
Move to a proper location (fix compilation).
Simplify API (remove error)
Add `FilesService` impl.

message LoadFileRequest {
// path as it's returned in LoadSketchResponse for instance
string path = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could use repeated to be able to return few file entires with just 1 call

// File content
bytes content = 1;
// is skipped in case of error
ContentType type = 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

could be removed to avoid duplication. The reason it's still here is that the server might still return not the requested type (for any reason)


message LoadFileResponse {
// File content
bytes content = 1;
Copy link
Contributor Author

@4ntoine 4ntoine Nov 4, 2021

Choose a reason for hiding this comment

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

or it could be smth like (depends on the design if whether we want to let the client know error code to add custom behaviour):

oneof {
    bytes content = 1;
    grpc.status error = 2;
}

Add TODO (Type support).
@silvanocerza
Copy link
Contributor

Interesting proposal but I have some concerns.

Protocol buffers are not meant to be used with large data sets as per documentation, sending the whole content of a file via gRPC is not a great idea I think.

But the major concern is about security, if the arduino-cli is running on a backend and any client can ask the content of any file that has permission to read you open up a BIG hole I think. Am not really confortable with this.

In the end I think this must not be a concern of the CLI, files exchange should be handled by another service.

@4ntoine
Copy link
Contributor Author

4ntoine commented Nov 4, 2021

@silvanocerza Yeah, your concerns are more than reasonable. I've been also thinking about that. It seems if we limit the paths to user and build dirs only (to be able to load the sketches and compiled binaries) it should be ok. Also we might register the service to the server only if daemon is started with a new --with-file-system flag (switched off by default), so users who intentionally want to run it for back-end use case will be able to do it (and the rest will be not affected at all).

If we're talking about sketches and compiled binaries - they don't exceed kilobytes (megabytes max), so size seems to be not a huge issue. Also we can compress (see Type = raw/zip/etc) to reduce the size if still having some concerns on it.

I also agree that external (dedicated) service should do it better, but imo it's very small additional feature to provide a full set of needed functional so it seems to be not a big deal. I doubt that average user will be able to install smth like https://github.com/hubot-grpc/filesystem-grpc and want to deal with dockers, daemons, etc.

But instead it will allow users to use their laptops/desktops or even Raspi's with arduino-cli to compile for Arduino from any mobile client (smartphones, tablet, smart devices, etc).

@ubidefeo
Copy link

ubidefeo commented Nov 4, 2021

@4ntoine

But instead it will allow users to use their laptops/desktops or even Raspi's with arduino-cli to compile for Arduino from any mobile client (smartphones, tablet, smart devices, etc).

This is a use case I was interested in, but I have opted for running CLI on a Pi, editing files over SSH and then running the appropriate command over SSH with the board attached to the Pi's USB port.
Have you thought about "mapping" the remote FS using SAMBA?
You could in theory configure the CLI to have the paths required be subfolders of that mounted path.
Not sure it would work on iPad, though

directories:
  data: /Users/ubi/Library/Arduino15
  downloads: /Users/ubi/Library/Arduino15/staging
  user: /data/Dropbox/AppsDocuments/Arduino

@4ntoine
Copy link
Contributor Author

4ntoine commented Nov 4, 2021

@ubidefeo

yes, i tried different scenarios including samba (and it worked).

I'm thinking about "average user" and Arduino is awesome due to it's simplicity. So imo if it costs only 42 lines of code as in this MR lot's of people will say "thank you guys for doing our life easier"

@4ntoine
Copy link
Contributor Author

4ntoine commented Nov 9, 2021

@silvanocerza will it work for you to address security concerns? i can update the MR

@per1234 per1234 linked an issue Mar 31, 2022 that may be closed by this pull request
@per1234 per1234 added topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface labels Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Q: back-end scenario and file contents (not just paths)
5 participants