Skip to content

Redundant discovery processes created by additional daemon instances #1981

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

Open
3 tasks done
per1234 opened this issue Nov 17, 2022 · 1 comment
Open
3 tasks done
Assignees
Labels
status: waiting for information More information must be provided before work can proceed topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Milestone

Comments

@per1234
Copy link
Contributor

per1234 commented Nov 17, 2022

Describe the problem

Pluggable discovery tools supply Arduino CLI with a list of "ports" of connected Arduino boards. When Arduino CLI is running as a daemon, these tools are started when a gRPC request is received that requires a port listing and then left running for the remainder of the session.

🐛 Redundant processes for each discovery tool are created by additional instances of the Arduino CLI daemon. It is possible that discovery tools may not be designed to operate correctly in this way, and the multiple processes might interfere with each other.

To reproduce

Setup

$ arduino-cli version

arduino-cli  Version: 0.29.0-rc.1 Commit: 76251df9 Date: 2022-11-17T03:35:12Z

$ arduino-cli daemon

Daemon is now listening on 127.0.0.1:50051

Demo

run the following grpcurl commands in another terminal:

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Create

{
  "instance": {
    "id": 1
  }
}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Init

$ pgrep -a -f 'serial-discovery'  # Discovery tools have not yet been started

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.BoardList

[...]

$ pgrep -a -f 'serial-discovery'  # A process for each discovery tool was created

134825 /home/per/.arduino15/packages/builtin/tools/serial-discovery/1.3.2/serial-discovery

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Create

{
  "instance": {
    "id": 2
  }
}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 2}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Init

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 2}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.BoardList

[...]

$ pgrep -a -f 'serial-discovery'

134825 /home/per/.arduino15/packages/builtin/tools/serial-discovery/1.3.2/serial-discovery
135007 /home/per/.arduino15/packages/builtin/tools/serial-discovery/1.3.2/serial-discovery

🐛 A new process is created for each discovery tool by additional Arduino CLI daemon instances.

Expected behavior

A single instance of each discovery tool should be shared by all Arduino CLI daemon instances.

Arduino CLI version

76251df

Operating system

Windows, Ubuntu

Operating system version

Windows 10, Ubuntu 20.04

Additional context

Related: #1960

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Nov 17, 2022
@cmaglie cmaglie added this to the Arduino CLI 1.0 milestone Nov 17, 2022
@cmaglie
Copy link
Member

cmaglie commented Feb 1, 2023

Fixing this requires a medium refactoring of the DiscoveryManager, there is an actual real-world scenario when this could be a problem? If this is not a critical issue, I'd like to postpone it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for information More information must be provided before work can proceed topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

5 participants