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

Added specific CLI return error-code if inventory can not be created #2402

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Nov 3, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • 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)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Add a specific exit code for the CLI to signal failure on initializing the "inventory" storage.

What is the current behavior?

In case of failure to initialize inventory, the CLI returned a generic error code 7, i.e. ErrBadArgument.

What is the new behavior?

In case of failure to initialize inventory, the CLI return an error code 10, i.e. ErrInitializingInventory.

Does this PR introduce a breaking change, and is titled accordingly?

Other information

Fix #2352

@cmaglie cmaglie added type: imperfection Perceived defect in any part of project topic: CLI Related to the command line interface labels Nov 3, 2023
@cmaglie cmaglie self-assigned this Nov 3, 2023
@kittaakos
Copy link
Contributor

Thanks for the PR!

Avoid startup fatal error if the data directory can not be created.

Why? Is the CLI (daemon) fully functional if the directories.data is missing?

Why no fail with a specific exit code?

@cmaglie cmaglie force-pushed the daemon-startup-error branch from 1b45064 to 38b5fd8 Compare November 6, 2023 14:51
@cmaglie cmaglie force-pushed the daemon-startup-error branch from 38b5fd8 to 2d40049 Compare November 6, 2023 14:52
@cmaglie
Copy link
Member Author

cmaglie commented Nov 6, 2023

Why? Is the CLI (daemon) fully functional if the directories.data is missing?

Uhm... actually you can recover from this situation by changing the data_dir using Settings API, but you're right, it's a very convoluted use case, in this case is better to exit with another exit code.

I've changed the PR accordingly.

@cmaglie cmaglie changed the title Do not exit with a fatal error running CLI daemon if data dir can't be created Added specific CLI return error-code if inventory can not be created Nov 6, 2023
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (aeac305) 64.60% compared to head (2d40049) 64.58%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2402      +/-   ##
==========================================
- Coverage   64.60%   64.58%   -0.02%     
==========================================
  Files         207      207              
  Lines       19634    19634              
==========================================
- Hits        12684    12681       -3     
- Misses       5861     5863       +2     
- Partials     1089     1090       +1     
Flag Coverage Δ
unit 64.58% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
internal/cli/cli.go 87.26% <0.00%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cmaglie cmaglie merged commit c45ab20 into arduino:master Nov 6, 2023
95 checks passed
@cmaglie cmaglie deleted the daemon-startup-error branch November 6, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: add some specific exit error-codes for daemon startup
3 participants