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

add non-zero exit code for verdi daemon status #3729

Merged
merged 3 commits into from
Feb 11, 2020

Conversation

ltalirz
Copy link
Member

@ltalirz ltalirz commented Jan 24, 2020

fixes #3728

verdi daemon status was always returning exit code 0, which makes it
difficult to use the command programmatically (e.g. in ansible).
It now returns exit code 1 if the daemon of any of the requested
profiles is not running.

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

I think we should add at least one unit test for this. Are you sure this works as intended? The client.get_status() always returns a dictionary, if daemon is running:

{
    'status': 'active',
    'time': 1580203422.571316,
    'id': '10a66cd1592a44869cd632a059aab974'
}

and if it is not:

{'status': 'daemon-error-not-running'}

So I think this command currently will always exit with 1

@ltalirz
Copy link
Member Author

ltalirz commented Feb 1, 2020

Thanks for paying attention - I actually planned doing what I did now, no idea what I was thinking...
Also added tests now (still a bit indirect, let me know if you want me to test the exit code of the command directly).

`verdi daemon status` was always returning exit code 0, which makes it
difficult to use the command programmatically (e.g. in ansible).
It now returns exit code 1 if the daemon of any of the requested
profiles is not running.
"""Print the status of the current daemon or all daemons."""
"""Print the status of the current daemon or all daemons.

Returns exit code 0 if all daemons are running, else exit code 3.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please clarify that "all daemons" refers to "all daemons whose status is requested" and not "daemons of all profiles", i.e., if one does not specify --all then 0 is returned when the current default daemon/profile is running, even if any other daemon is not running

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, done!

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @ltalirz

@sphuber sphuber merged commit 67ae49f into aiidateam:develop Feb 11, 2020
@sphuber sphuber deleted the issue_3728_daemon_status branch February 11, 2020 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

verdi daemon status should return non-zero exit code, if daemon is not running
2 participants