Bug 1557736

Summary: discover-tempest-config failure in discovering api_extensions, and verify-config raised IndexError
Product: Red Hat OpenStack Reporter: Noam Manos <nmanos>
Component: openstack-tempestAssignee: Martin Kopec <mkopec>
Status: CLOSED ERRATA QA Contact: Chandan Kumar <chkumar>
Severity: high Docs Contact:
Priority: high    
Version: 13.0 (Queens)CC: amodi, apevec, astafeye, chkumar, lhh, ltoscano, mariel, mkopec, slinaber, tfreger, udesale, whayutin
Target Milestone: ---Keywords: Triaged, ZStream
Target Release: 14.0 (Rocky)Flags: mkopec: needinfo-
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: openstack-tempest-19.0.0-2.el7ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1554306
: 1562085 (view as bug list) Environment:
Last Closed: 2019-03-18 13:04:08 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:
Bug Depends On: 1622011    
Bug Blocks: 1624906    
Description Flags
tempest.conf created with discover-tempest-config none

Description Noam Manos 2018-03-18 07:59:54 UTC
Created attachment 1409416 [details]
tempest.conf created with discover-tempest-config

+++ This bug was initially created as a clone (related to) Bug #1554306 +++

Description of problem: 
Running "discover-tempest-config" had failure in discovering "api_extensions", and as consequence, "tempest verify-config" (from python-tempestconf) raised IndexError. 

Version-Release number of selected component (if applicable):
OSP: 13   
Puddle: 2018-03-02.2

How reproducible - 

Steps to Reproduce:
1) Install OSP-13 (master branch).

2) Due to Bug #1554306 - Please also install python-tempestconf:
[stack@undercloud-0 ~]$ sudo yum -y install python-tempestconf

3) Run discover-tempest-config:
[stack@undercloud-0 ~]$ source overcloudrc
(overcloud) [stack@undercloud-0 ~]$ tempest init my_workspace
(overcloud) [stack@undercloud-0 ~]$ cd my_workspace
(overcloud) [stack@undercloud-0 my_workspace]$ discover-tempest-config --deployer-input 

4) Run verify-config:
(overcloud) [stack@undercloud-0 my_workspace]$ tempest verify-config -o ./etc/tempest.conf

Running config verification...

Traceback (most recent call last):
  File "/home/stack/tempest/tempest/cmd/verify_tempest_config.py", line 486, in take_action
  File "/home/stack/tempest/tempest/cmd/verify_tempest_config.py", line 458, in main
    results = verify_extensions(os, service, results)
  File "/home/stack/tempest/tempest/cmd/verify_tempest_config.py", line 286, in verify_extensions
    if extensions_opt[0] == 'all':
IndexError: list index out of range


Suggestion - Please fix 2 issues:

1) In "verify_tempest_config.py" (line 286):

Method "verify_extensions" does not check if "get_enabled_extensions(service)" has return an empty list. 

Please handle empty list error - if extensions_opt is empty: Print proper message like "Service {service} has no extensions defined in tempest.conf".

2) In "/usr/lib/python2.7/site-packages/config_tempest/config_tempest.py":

There's a failure in discovering "api_extensions" of "volume-feature-enabled" (cinder ?), which creates an empty value in tempest.conf (attached):

api_extensions =

Comment 2 Noam Manos 2018-03-27 13:17:25 UTC
Using latest verify-config from tempest 18.0.0, I see a fix of:

if not getattr(CONF.service_available,
                    print('Endpoint type %s is available, service %s should be'
                          ' set as available in the config file.' % (
                              catalog_type, codename_match[cfgname]))

However, if dictionary "codename_match" does not have for example "loadbalancer", it will fail on KeyError, and will not print message:

(overcloud) (.venv) [stack@undercloud-0 ~]$ tempest verify-config
Running config verification...
cfgname = compute
cfgname = image
cfgname = loadbalancer

Traceback (most recent call last):
  File "/home/stack/.venv/lib/python2.7/site-packages/tempest/cmd/verify_tempest_config.py", line 488, in take_action
  File "/home/stack/.venv/lib/python2.7/site-packages/tempest/cmd/verify_tempest_config.py", line 454, in main
    services = check_service_availability(os, update)
  File "/home/stack/.venv/lib/python2.7/site-packages/tempest/cmd/verify_tempest_config.py", line 384, in check_service_availability
KeyError: 'loadbalancer'

Comment 3 Noam Manos 2018-04-03 09:41:14 UTC
Please handle key error for non-existing dict key (in my case "loadbalancer"), to use dict.get() that returns None if no key found. So:
if not getattr(CONF.service_available, codename_match[cfgname])'

should rather be:
'cfg_value = codename_match.get(cfgname)'
if not cfg_value or not getattr(CONF.service_available, cfg_value)

Comment 4 Noam Manos 2018-04-09 12:08:48 UTC
In addition to fixing key error for non-existing dict, please also fix in "verify_tempest_config.py" - "check_service_availability":

codename_match dict should include 'loadbalancer': 'loadbalancer'.

(see related bug https://bugzilla.redhat.com/show_bug.cgi?id=1562085#c2:)

Comment 5 Matt Young 2018-04-16 16:31:28 UTC
we suspect this is already fixed

Comment 11 Martin Kopec 2018-08-14 10:38:26 UTC
verify-config issue should be resolved by 591595 (see external trackers). It's waiting for review.

The issue in python-tempestconf regarding volume extensions was resolved and merged to master branch, see 568876 in external trackers.

Comment 12 Martin Kopec 2018-08-30 05:20:49 UTC
python-tempestconf issue will be resolved as soon as python-tempestconf-2.0.0 for RHOS-13 is available, see depends on bug (1621205).

Comment 13 Martin Kopec 2018-09-03 15:24:30 UTC
python-tempestconf-2.0.0, which includes the fix for python-tempestconf's issue, has been released for RHOS-14, see https://bugzilla.redhat.com/show_bug.cgi?id=1622011

As soon as the patch (https://review.openstack.org/#/c/591595/) will be part of openstack-tempest for RHOS-14, the bug can be verified. To make sure that the patch will be backported to RHOS-13 too, I have created a bug - https://bugzilla.redhat.com/show_bug.cgi?id=1624906

Comment 19 Martin Kopec 2019-02-26 08:24:37 UTC
The required patch has been included in openstack-tempest-19.0.0-2.el7ost package, which is available in RHOS-14 repositories also via latest symlink - moving this bug to VERIFIED.

Comment 21 errata-xmlrpc 2019-03-18 13:04:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

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