Bug 1657700

Summary: Cannot change default basepath while working with file backend: permission denied
Product: Red Hat OpenStack Reporter: Sasha Smolyak <ssmolyak>
Component: openstack-gnocchiAssignee: Mehdi ABAAKOUK <mabaakou>
Status: CLOSED NOTABUG QA Contact: Sasha Smolyak <ssmolyak>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 14.0 (Rocky)CC: apevec, jschluet, lhh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-12 07:25:05 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 Sasha Smolyak 2018-12-10 10:05:57 UTC
Description of problem:
Deployed 1 controller, 1 compute, 1 ceph configuration with GnocchiBackend: file. Changed default backend dir from /var/lib/gnocchi to /var/lib/test, in gnocchi_metricd tried to create new dir /var/lib/test: permission denied.

Version-Release number of selected component (if applicable):
gnocchi-common-4.3.3-0.20181005084758.54bae4e.el7ost.noarch
python-gnocchi-4.3.3-0.20181005084758.54bae4e.el7ost.noarch
puppet-gnocchi-13.3.1-0.20181013121920.4b95b4b.el7ost.noarch
gnocchi-metricd-4.3.3-0.20181005084758.54bae4e.el7ost.noarch
python2-gnocchiclient-7.0.4-0.20180823073245.64814b9.el7ost.noarch

How reproducible:
100%

Steps to Reproduce:
1. Deploy 1 controller, 1 compute, 1 ceph with an additional parameter GnocchiBackend: file.

2. Test that the measures are shown after deployment: create a new instance, watch cpu measures, observe that the directories are created on /var/lib/gnocchi in gnocchi_api container.

3. In /var/lib/config-data/puppet-generated/gnocchi/etc/gnocchi/gnocchi.conf change file_basepath=/var/lib/test. Restart gnocchi_metricd container. Verify that the config /etc/gnocchi/gnocchi.conf is changed in gnocchi_metricd container.

4. In gnocchi_metricd container try to add a folder test under /var/log. Get error "permission denied". Cannot create the folder.

Note: when trying to add "test" folder under /var/lib/ in gnocchi_api container, everything works ok - the folder is created, the permissions can be changed.

Actual results:
Permission is denied

Expected results:
New folder is created

Additional info:
[heat-admin@controller-0 ~]$ tail /var/log/containers/gnocchi/gnocchi-metricd.log
    self._build_metric_path(metric, aggregation),
  File "/usr/lib/python2.7/site-packages/gnocchi/storage/file.py", line 136, in _build_metric_path
    return os.path.join(self._build_metric_dir(metric),
  File "/usr/lib/python2.7/site-packages/gnocchi/storage/file.py", line 121, in _build_metric_dir
    if self.SUBDIR_LEN > 0:
  File "/usr/lib/python2.7/site-packages/gnocchi/storage/file.py", line 76, in SUBDIR_LEN
    elif self.is_old_directory_structure():
  File "/usr/lib/python2.7/site-packages/gnocchi/storage/file.py", line 98, in is_old_directory_structure
    for p in os.listdir(self.basepath):
OSError: [Errno 2] No such file or directory: '/var/lib/test'

Comment 1 Sasha Smolyak 2018-12-10 10:13:25 UTC
I think that in Release notes, in "Telemetry" section, Section of working with file backend, need to add that it's forbidden for client to change default file basepath for Gnocchi backend from /var/lib/gnocchi

Comment 2 Mehdi ABAAKOUK 2018-12-12 07:25:05 UTC
To change the file directory you must do it with tripleo with the parameter GnocchiFileBasePath instead of changing /var/lib/config-data/puppet-generated/gnocchi/etc/gnocchi/gnocchi.conf.

Tripleo will take care of creating all needed directory.