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

Confusing error message from "ipfs key export" #7814

Closed
teknomunk opened this issue Dec 9, 2020 · 2 comments
Closed

Confusing error message from "ipfs key export" #7814

teknomunk opened this issue Dec 9, 2020 · 2 comments
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization

Comments

@teknomunk
Copy link

teknomunk commented Dec 9, 2020

Version information:

go-ipfs version: 0.8.0-dev-42d3f541d
Repo version: 11
System version: amd64/linux
Golang version: go1.15.6

Installed from a package I built today from https://aur.archlinux.org/packages/go-ipfs-git/

Description:

I reproduced the issue reported on the forums at ERROR with ipfs key export on my local machine.

When you run the command "ipfs key export $KEY_NAME" (where $KEY_NAME is not "self") while the ipfs daemon is running, it responds with the message:

Error: lock /home/teknomunk/.ipfs/repo.lock: someone else has the lock

When you stop the ipfs daemon, the command completes without issue.

If the requirement for key export to be an offline command cannot be removed, I think the error message should let the operator know that the command can only be run while the daemon is not.

@teknomunk teknomunk added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Dec 9, 2020
@welcome
Copy link

welcome bot commented Dec 9, 2020

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@gammazero
Copy link
Contributor

gammazero commented Dec 11, 2020

@teknomunk Thank you for bringing this to our attention. It probably makes sense to provide the same error that is given when trying to run ipfs key rotate:

Error: ipfs daemon is running. please stop it to run this command

gammazero added a commit that referenced this issue Dec 11, 2020
Fixes Issue #7814

ipfs key commands that open the repo directly will not work when another process has the repo open and locked.  For this reason these commands cannot run when the ipfs daemon is running, and an informative error message should be given to the user.

This is already done for the `ipfs key rotate` command, and should be done for other commands that directly open and lock the repo.  This PR applies the same PreRun check to these commands as is used for `ipfs key rotate`.

While unlikely, it is possible to see the error reported if another process opens the repo at the same moment.  In that case the "someone else has the lock" error is shown.
aschmahmann pushed a commit that referenced this issue Jan 28, 2021
* Improve error message when running key commands that must be run when the daemon is not already running

Fixes Issue #7814

`ipfs key export` now does a PreRun check like `ipfs key rotate` was to give a better error to the user then "someone else has the lock" in the event that the daemon is running while trying to execute these offline-only commands.

While unlikely the "someone else has the lock" error can still be shown if two processes try and grab the repo lock at the same time.

This PreRun function is also exported so it can be used by `ipfs init` where it was originally copied from.

* Added more `ipfs key` command tests

When daemon is running:
- Test that import works
- Test that export fails
- Test that rotate fails
kingwel-xie pushed a commit to kingwel-xie/go-ipfs that referenced this issue Feb 5, 2021
…7821)

* Improve error message when running key commands that must be run when the daemon is not already running

Fixes Issue ipfs#7814

`ipfs key export` now does a PreRun check like `ipfs key rotate` was to give a better error to the user then "someone else has the lock" in the event that the daemon is running while trying to execute these offline-only commands.

While unlikely the "someone else has the lock" error can still be shown if two processes try and grab the repo lock at the same time.

This PreRun function is also exported so it can be used by `ipfs init` where it was originally copied from.

* Added more `ipfs key` command tests

When daemon is running:
- Test that import works
- Test that export fails
- Test that rotate fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

3 participants