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

"microk8s status" exits with zero return code when server is down #3974

Closed
rsalinas opened this issue May 17, 2023 · 2 comments · May be fixed by #3975
Closed

"microk8s status" exits with zero return code when server is down #3974

rsalinas opened this issue May 17, 2023 · 2 comments · May be fixed by #3975
Labels

Comments

@rsalinas
Copy link

rsalinas commented May 17, 2023

Summary

microk8s status returns 0 when the server is down.

$ microk8s status --yaml ; echo $?
microk8s is not running, try microk8s start
0

What Should Happen Instead?

I would expect it to return non-zero, so that I don't need to search for text in the output.

This also complicates my life when trying to directly parse its output as yaml.

Reproduction Steps

  1. It happens always, both and without --yaml. Retval is always zero.

Introspection Report

Probably not relevant.

Can you suggest a fix?

Yes, simply return non-zero when the server is down.
Fix scripts/wrappers/common/utils.py:

def exit_if_stopped():
    stoppedLockFile = os.path.expandvars("${SNAP_DATA}/var/lock/stopped.lock")
    if os.path.isfile(stoppedLockFile):
        print("microk8s is not running, try microk8s start")
        **exit(0)**

Are you interested in contributing with a fix?

Yes, it's about changing that zero by a one.
I can make a PR if you wish.

@sachinkumarsingh092
Copy link
Contributor

Hey @rsalinas, thanks for opening the issue and the PR. I'll try to look into it soon.

Copy link

stale bot commented Apr 12, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Apr 12, 2024
@stale stale bot closed this as completed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants