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

[Bug]: cosmovisor version command errors under certain conditions #19439

Closed
1 task done
shapeshed opened this issue Feb 14, 2024 · 1 comment
Closed
1 task done

[Bug]: cosmovisor version command errors under certain conditions #19439

shapeshed opened this issue Feb 14, 2024 · 1 comment
Labels

Comments

@shapeshed
Copy link
Contributor

shapeshed commented Feb 14, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

The cosmovisor version command errors in a few scenarios and outputs a non-zero exit status

  • the $DAEMON_NAME environment variable is not set
  • the $DAEMON_HOME environment variable is not set
  • the $DAEMON_NAME binary is not found in $PATH

This is because cosmovisor also returns the version of the binary as well as the version of cosmovisor.

Cosmos SDK Version

main

How to reproduce?

Replication details

git clone [email protected]:cosmos/cosmos-sdk.git
cd cosmos-sdk
cd tools/cosmovisor
make cosmovisor
./cosmovisor version

cosmovisor version: (devel)
Error: failed to run version command: DAEMON_NAME is not set
DAEMON_HOME is not set
DAEMON_DATA_BACKUP_DIR must not be empty
6:18PM ERR error="failed to run version command: DAEMON_NAME is not set\nDAEMON_HOME is not set\nDAEMON_DATA_BACKUP_DIR must not be empty" module=cosmovisor

echo $?
1 # note non-zero exit status 

Expected behaviour

cosmovisor version should print the cosmovisor version and return an exit status of 0.

./cosmovisor version 
cosmovisor version: (devel)
echo $?
0 # note zero exit status 

Rationale

Generally a piece of software should return a version number without erroring. Returning a non-zero exit code is good behaviour and plays nice with CI tools, provisioners and shell scripts.

Specifically as an Ansible user I want to install cosmovisor before I install a node binary. I want to be able to check the version of cosmovisor matches the version specified in my scripts.

Potential resolution

The issue is due to the version command calling run on $DAEMON_NAME within the version command

This is also the case in printVersionJSON

I suggest that the app_version is not relevant to the version command and should be removed or moved to another command. There should be no dependency on $DAEMON_NAME for cosmovisor version to run without a non-zero exit code.

If you agree with the issue I would be happy to submit a PR to remove the app version or move it to a separate command.

If you don't agree it is bearable but the non-zero exit code is not pleasant for playing nice with Unix/Linux standards, leading to issues with build tools, CI, and provisioning.

@julienrbrt
Copy link
Member

Correct, but for backward compatibility we let the behavior of cosmovisor version the same, and you indeed need to set those variables, to get cosmovisor version and the app version.
However, you can get the cosmovisor version with a flag: cosmovisor version --cosmovisor-only, where cosmovisor won't fetch the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants