Bug 1672394 - [Hackfest] OSP14 - 'openstack complete' for bash_completion no longer works
Summary: [Hackfest] OSP14 - 'openstack complete' for bash_completion no longer works
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: python-tripleoclient
Version: 14.0 (Rocky)
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 14.0 (Rocky)
Assignee: Julie Pichon
QA Contact: Udi Kalifon
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-04 20:22 UTC by Chris Janiszewski
Modified: 2019-11-06 18:13 UTC (History)
8 users (show)

Fixed In Version: python-tripleoclient-10.6.1-0.20190303235861.ab72340.el7ost
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-02 20:08:27 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
OpenStack gerrit 636863 0 None MERGED get_parser() should return a parser 2020-11-08 15:03:55 UTC
Red Hat Product Errata RHBA-2019:1672 0 None None None 2019-07-02 20:08:35 UTC

Description Chris Janiszewski 2019-02-04 20:22:22 UTC
Description of problem:
Unable to generate the bash_completion file with openstack complete.

(undercloud) [stack@undercloud-osp14 ~]$ openstack complete
2019-02-04 15:16:22.176 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.221 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.247 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.279 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.342 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.360 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.440 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.441 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.458 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.460 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.543 88243 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-02-04 15:16:22.649 88243 ERROR openstack [-] 'NoneType' object has no attribute '_get_optional_actions'
2019-02-04 15:16:22.649 88243 INFO osc_lib.shell [-] END return value: 1


Version-Release number of selected component (if applicable):
RH OSP14

How reproducible:
Every time

Steps to Reproduce:
1. Install osp14 undercloud
2. Source ~/stackrc
3. execute: openstack complete

Actual results:
2019-02-04 15:16:22.649 88243 ERROR openstack [-] 'NoneType' object has no attribute '_get_optional_actions'

Expected results:
List of openstack commands in bash-completion friendly form

Additional info:

Comment 1 Julie Pichon 2019-02-05 10:22:46 UTC
$ openstack --debug complete
[...]
2019-02-05 10:05:27.754 8964 ERROR openstack AttributeError: 'NoneType' object has no attribute '_get_optional_actions'
2019-02-05 10:05:27.754 8964 ERROR openstack 
2019-02-05 10:05:27.755 8964 ERROR osc_lib.shell [-] Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/osc_lib/shell.py", line 135, in run
    ret_val = super(OpenStackShell, self).run(argv)
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 281, in run
    result = self.run_subcommand(remainder)
  File "/usr/lib/python2.7/site-packages/osc_lib/shell.py", line 175, in run_subcommand
    ret_value = super(OpenStackShell, self).run_subcommand(argv)
  File "/usr/lib/python2.7/site-packages/cliff/app.py", line 402, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/site-packages/cliff/command.py", line 184, in run
    return_code = self.take_action(parsed_args) or 0
  File "/usr/lib/python2.7/site-packages/cliff/complete.py", line 217, in take_action
    dicto.add_command(command, self.get_actions(command))
  File "/usr/lib/python2.7/site-packages/cliff/complete.py", line 202, in get_actions
    return cmd_parser._get_optional_actions()
AttributeError: 'NoneType' object has no attribute '_get_optional_actions'

2019-02-05 10:05:27.755 8964 INFO osc_lib.shell [-] END return value: 1

Comment 2 Julie Pichon 2019-02-05 11:42:21 UTC
This seems to be happening because of a single command in tripleoclient (openstack tripleo config generate ansible), submitted a fix upstream.

Comment 3 Emblem Parade 2019-05-30 16:14:44 UTC
Julie, thank you! Could you provide a link to your upstream fix? This is a painful papercut.

Comment 4 Emblem Parade 2019-05-30 16:25:53 UTC
Nevermind, I found the change here: https://review.opendev.org/gitweb?p=openstack%2Fpython-tripleoclient.git;a=commitdiff;h=e38c775e418c67af4dd2ff8086bb1ea8a6804f94

Unfortunately it seems that I already have your fix in /usr/lib/python2.7/site-packages/tripleoclient/v1/tripleo_config.py. I am using RDO "stein".

And yet I am still getting a similar error. Actually, in my case "openstack complete" *does* emit the completion code but wraps it in logs message emitted to stdout that make it unusable. I can't see any way to suppress these log messages to stdout.

Also note that my final log message has return code 0 rather than 1:

2019-05-30 11:01:09.704 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.724 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.734 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.749 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.779 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.788 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.813 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.814 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.822 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.822 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.844 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.932 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:09.937 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:10.027 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:10.028 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:10.034 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:10.041 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
2019-05-30 11:01:10.080 702813 DEBUG osc_lib.clientmanager [-] No service catalog is_service_available /usr/lib/python2.7/site-packages/osc_lib/clientmanager.py:223
_openstack()
{
  local cur prev words
  COMPREPLY=()

...

  return 0
}
complete -F _openstack openstack
2019-05-30 11:01:10.088 702813 INFO osc_lib.shell [-] END return value: 0

Comment 5 Julie Pichon 2019-05-30 16:50:04 UTC
Hi Emblem. If you don't see the "AttributeError: 'NoneType' object has no attribute '_get_optional_actions'" error then this is a different issue and a separate bug should be opened, upstream since you are using RDO. From the output you post though, it seems like you're getting some extra logging statements around the output, but not within it, so you should be able to use it?

Comment 6 Emblem Parade 2019-05-30 17:08:17 UTC
Thanks, will open a new bug.

The annoyance is that those log messages are sent to stdout, just like the actual output. So I guess I could grep and remove those lines, but obviously that is error-prone and not the right way to do it.

In my opinion this is actually a Cliff issue. Cliff should be able to output the bash completion to a file directly as to avoid any kind of other component outputting to stdout.

Comment 10 errata-xmlrpc 2019-07-02 20:08:27 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.

https://access.redhat.com/errata/RHBA-2019:1672

Comment 11 Emblem Parade 2019-11-05 22:00:16 UTC
It is fixed upstream on the python-openstackclient package in PyPI, but I'm afraid the bug is still present in most recent RPM packages for Stein.

For those interested in a workaround:

openstack complete | sed '/DEBUG osc_lib.clientmanager/d' > bash_completion.sh

Comment 12 Emblem Parade 2019-11-06 18:13:49 UTC
Actually, this is the workaround:

openstack complete | sed '/DEBUG osc_lib./d' > bash_completion.sh


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