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

Fix bug in grafana admin password reset script #360

Merged
merged 1 commit into from
Nov 25, 2019

Conversation

peterellisjones
Copy link
Contributor

Grafana CLI global options must come before command and command options. Currently we are seeing the following error in less /var/vcap/sys/log/grafana/post-start.stdout.log:

[Wed Nov 20 14:30:12 UTC 2019] Resetting grafana admin password ...
Waiting for grafana to listen on port 3000 (0/60)
Grafana is ready
Incorrect Usage: flag provided but not defined: -homepath

NAME:
   Grafana cli admin reset-admin-password - reset-admin-password <new password>

USAGE:
   Grafana cli admin reset-admin-password [arguments...]

This is because the grafana-admin-password script was passing the -homepath and -config global options after the admin reset-admin-password command, which is not supported. I have verified this fix works by manually updating /var/vcap/jobs/grafana/bin/grafana-admin-password to fix the argument ordering on a running prometheus deployment and verifying that the script no longer fails.

I assume that the argument ordering requirement was introduced into the grafana CLI at some point after this script was made.

Grafana CLI global options _must_ come before command and command options. Currently we are seeing the following error in `less /var/vcap/sys/log/grafana/post-start.stdout.log`:

```
[Wed Nov 20 14:30:12 UTC 2019] Resetting grafana admin password ...
Waiting for grafana to listen on port 3000 (0/60)
Grafana is ready
Incorrect Usage: flag provided but not defined: -homepath

NAME:
   Grafana cli admin reset-admin-password - reset-admin-password <new password>

USAGE:
   Grafana cli admin reset-admin-password [arguments...]
```

This is because the `grafana-admin-password` script was passing the `-homepath` and `-config` global options _after_ the `admin reset-admin-password` command, which is not supported. I have verified this fix works by manually updating `/var/vcap/jobs/grafana/bin/grafana-admin-password` to fix the argument ordering on a running prometheus deployment and verifying that the script no longer fails.
@peterellisjones
Copy link
Contributor Author

Easy test to verify CLI requires argument ordering:

grafana/175f14a4-8180-4553-807a-7f431f733119:/var/vcap/jobs/grafana/bin# /var/vcap/packages/grafana/bin/grafana-cli admin reset-admin-password -homepath foo
Incorrect Usage: flag provided but not defined: -homepath

NAME:
   Grafana cli admin reset-admin-password - reset-admin-password <new password>

USAGE:
   Grafana cli admin reset-admin-password [arguments...]

@frodenas frodenas merged commit 29fd793 into cloudfoundry:master Nov 25, 2019
@frodenas
Copy link
Contributor

Thanks @peterellisjones!

@peterellisjones
Copy link
Contributor Author

Hi @frodenas — any chance you could cut this into a new release? We rotate our passwords regularly so we see this bug quite a lot.

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.

2 participants