Bug 1529344 - Printing vdsm configuration by running config.py fail with "AttributeError: 'module' object has no attribute 'glob'"
Summary: Printing vdsm configuration by running config.py fail with "AttributeError: '...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: vdsm
Classification: oVirt
Component: Core
Version: 4.20.15
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ovirt-4.4.0
: ---
Assignee: Marcin Sobczyk
QA Contact: Petr Matyáš
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-27 17:26 UTC by Nir Soffer
Modified: 2020-05-20 20:03 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-20 20:03:05 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-4.4+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 105268 0 master MERGED tool: Add 'show-default-config' command 2020-03-26 14:55:33 UTC

Description Nir Soffer 2017-12-27 17:26:02 UTC
Description of problem:

Before 4.2, it was possible to the documentation for vdsm configuration file
by running vdsm/config.py as a script:

    python /usr/lib/python2.7/site-packages/vdsm/common/config.py

This fails now with this error:

# python /usr/lib/python2.7/site-packages/vdsm/common/config.py
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/vdsm/common/config.py", line 739, in <module>
    config = load('vdsm')
  File "/usr/lib/python2.7/site-packages/vdsm/common/config.py", line 711, in load
    read_configs(cfg, name)
  File "/usr/lib/python2.7/site-packages/vdsm/common/config.py", line 733, in read_configs
    dropins.extend(glob.glob(pattern))
AttributeError: 'module' object has no attribute 'glob'

The issue is the new vdsm/common/glob.py module, added in:

commit fd13ee1e55d61f06516ad10c890470a2c822b9c8
Author: Idan Shaby <ishaby>
Date:   Thu Jan 12 18:43:56 2017 +0200

    compat: add glob.escape from Python 3.6
    
    glob.escape was added in Python 3.6.
    Since we need it for escaping values that are passed to glob.glob,
    this patch adds it to glob.py.
    
    Change-Id: Id2989a9edcc87ec671d8c29ec7900e01b537b3f1
    Related-To: https://bugzilla.redhat.com/1302358
    Signed-off-by: Idan Shaby <ishaby>

But having a glob.py module in vdsm is correct; we use absolute
imports, so this module does not hide the python stdlib glob module.
In vdsm, we import our private glob with:

   from vdsm.common import glob

So the real issue is running config.py as a script - this is not a reliable
way to print configuration, since running a script change PYTHONPATH
to include the directory where the script is located, and this hides
the python builtin glob module.

The right way to print the configuration is:

# python -c "from vdsm.common import config; config.print_config()"

# VDSM Sample Configuration

[vars]

# Enable core dump.
# core_dump_enable = true

# Reserves memory for the host to prevent VMs from using all the
# physical pages. The values are in Mbytes.
# host_mem_reserve = 256
...


Version-Release number of selected component (if applicable):
vdsm > 4.19.10

How reproducible:
Always

Steps to Reproduce:
1. Run:

    python /usr/lib/python2.7/site-packages/vdsm/common/config.py


I think the best way to resolve this would be to convert config.py to regular
module, so it is not possible to run it as a script.

If the feature of printing the configuration is important enough, it should be
provided by "vdsm-tool show-default-config".

Comment 1 Nir Soffer 2017-12-27 17:26:51 UTC
This is a regression introduced in 4.1.

Comment 2 Red Hat Bugzilla Rules Engine 2017-12-28 15:03:20 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 3 Red Hat Bugzilla Rules Engine 2018-01-02 14:25:05 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 4 Irit Goihman 2018-01-02 14:27:24 UTC
Removing regression keyword to avoid automatic assignment of blocker flag.

Comment 6 Petr Matyáš 2020-01-21 14:19:58 UTC
Verified on vdsm-4.40.0-180.giteba0b75.el8ev.x86_64

Now you can do 'vdsm-tool show-default-config'

Comment 7 Sandro Bonazzola 2020-05-20 20:03:05 UTC
This bugzilla is included in oVirt 4.4.0 release, published on May 20th 2020.

Since the problem described in this bug report should be
resolved in oVirt 4.4.0 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.