Bug 2107046

Summary: Can not change password using grafana-cli
Product: [Fedora] Fedora Reporter: Jan Kurik <jkurik>
Component: grafanaAssignee: Andreas Gerstmayr <agerstmayr>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: agerstmayr, jkurik, mgoodwin, nathans
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: grafana-9.0.2-3.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-14 13:18:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Kurik 2022-07-14 08:23:14 UTC
Description of problem:
Changing grafana admin password using grafana-cli fails with a permission error.

Version-Release number of selected component (if applicable):
* grafana-9.0.2-1.fc37 and/or grafana-9.0.2-2.fc37

How reproducible:
Always

Steps to Reproduce:
1. On F37 Install grafana-9.0.2-2.fc37
2. Try to change admin password using the grafana-cli tool
grafana-cli --homepath /usr/share/grafana admin reset-admin-password NeWpAsSwOrD

Actual results:
# grafana-cli --homepath /usr/share/grafana admin reset-admin-password NeWpAsSwOrD
INFO [07-14|04:10:01] Starting Grafana                         logger=settings version= commit= branch= compiled=1969-12-31T19:00:00-05:00
INFO [07-14|04:10:01] Config loaded from                       logger=settings file=/usr/share/grafana/conf/defaults.ini
INFO [07-14|04:10:01] Path Home                                logger=settings path=/usr/share/grafana
INFO [07-14|04:10:01] Path Data                                logger=settings path=/usr/share/grafana/data
INFO [07-14|04:10:01] Path Logs                                logger=settings path=/usr/share/grafana/data/log
INFO [07-14|04:10:01] Path Plugins                             logger=settings path=/usr/share/grafana/data/plugins
INFO [07-14|04:10:01] Path Provisioning                        logger=settings path=/usr/share/grafana/conf/provisioning
INFO [07-14|04:10:01] App mode production                      logger=settings
Error: ✗ failed to initialize SQL store: failed to connect to database: mkdir /usr/share/grafana/data: permission denied


Expected results:
The password is successfully changed.

Additional info:
* This is a regression, as with grafana v7.x this worked just fine.

* The issue IMO is in invalid parsing of config data by the grafana-cli tool. As can be seen in the log (see the 'Actual results:' section above) the Data path is set to '/usr/share/grafana/data'. However in '/etc/sysconfig/grafana-server' as well as in the wrapper '/usr/sbin/grafana-cli' the "DATA_DIR" env. variable is set to "/var/lib/grafana". The wrapper '/usr/sbin/grafana-cli' is passing down DATA_DIR to the '/usr/libexec/grafana/grafana-cli' executable via "--configOverrides='cfg:default.paths.data=${DATA_DIR}'" command line. However this "configOverrides" seems to be ignored by the '/usr/libexec/grafana/grafana-cli' executable.

Comment 1 Fedora Update System 2022-07-14 13:06:35 UTC
FEDORA-2022-6480e61dad has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-6480e61dad

Comment 2 Fedora Update System 2022-07-14 13:18:16 UTC
FEDORA-2022-6480e61dad has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.