Bug 1952017

Summary: [OSP16.1] UseTLSTransportForNbd check can fail with TypeError: 'NoneType' object is not subscriptable
Product: Red Hat OpenStack Reporter: Ollie Walsh <owalsh>
Component: python-tripleoclientAssignee: David Vallee Delisle <dvd>
Status: CLOSED ERRATA QA Contact: David Rosenfeld <drosenfe>
Severity: medium Docs Contact:
Priority: medium    
Version: 16.1 (Train)CC: dvd, elicohen, giridhar.ramaraju, hbrock, jeterril, jslagle, mburns, mschuppe, ykaul
Target Milestone: z7Keywords: Patch, Triaged
Target Release: 16.1 (Train on RHEL 8.2)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-tripleoclient-12.3.2-1.20210503153259.ae58329.el8ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1953425 (view as bug list) Environment:
Last Closed: 2021-12-09 20:18:39 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: Train
Embargoed:
Bug Depends On:    
Bug Blocks: 1953425    

Description Ollie Walsh 2021-04-21 10:55:41 UTC
If the initial deployment fails in heat the next run fails with:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 32, in run
    super(Command, self).run(parsed_args)
  File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/lib/python3.6/site-packages/cliff/command.py", line 185, in run
    return_code = self.take_action(parsed_args) or 0
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 1022, in take_action
    self._update_parameters(parsed_args, stack)
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 123, in _update_parameters                                                                                                     
    if nbd_tls_key in roledata[key]['config_settings']:
TypeError: 'NoneType' object is not subscriptable
'NoneType' object is not subscriptable

Deleting the stack and redeploying works.

Comment 2 Jeffrey Terrill 2021-05-20 17:47:47 UTC
(In reply to Ollie Walsh from comment #0)
> If the initial deployment fails in heat the next run fails with:
> 
> Traceback (most recent call last):
>   File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 32,
> in run
>     super(Command, self).run(parsed_args)
>   File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line
> 41, in run
>     return super(Command, self).run(parsed_args)
>   File "/usr/lib/python3.6/site-packages/cliff/command.py", line 185, in run
>     return_code = self.take_action(parsed_args) or 0
>   File
> "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py",
> line 1022, in take_action
>     self._update_parameters(parsed_args, stack)
>   File
> "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py",
> line 123, in _update_parameters                                             
> 
>     if nbd_tls_key in roledata[key]['config_settings']:
> TypeError: 'NoneType' object is not subscriptable
> 'NoneType' object is not subscriptable
> 
> Deleting the stack and redeploying works.

I hit this bug in a recent deployment but deleting the stack ("openstack stack delete" on director) and redeploying resulted in the same error.

Comment 3 Ollie Walsh 2021-05-20 20:44:57 UTC
(In reply to Jeffrey Terrill from comment #2)
> (In reply to Ollie Walsh from comment #0)
> > If the initial deployment fails in heat the next run fails with:
> > 
> > Traceback (most recent call last):
> >   File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 32,
> > in run
> >     super(Command, self).run(parsed_args)
> >   File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line
> > 41, in run
> >     return super(Command, self).run(parsed_args)
> >   File "/usr/lib/python3.6/site-packages/cliff/command.py", line 185, in run
> >     return_code = self.take_action(parsed_args) or 0
> >   File
> > "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py",
> > line 1022, in take_action
> >     self._update_parameters(parsed_args, stack)
> >   File
> > "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py",
> > line 123, in _update_parameters                                             
> > 
> >     if nbd_tls_key in roledata[key]['config_settings']:
> > TypeError: 'NoneType' object is not subscriptable
> > 'NoneType' object is not subscriptable
> > 
> > Deleting the stack and redeploying works.
> 
> I hit this bug in a recent deployment but deleting the stack ("openstack
> stack delete" on director) and redeploying resulted in the same error.

I meant deleting the overcloud works ("openstack overcloud delete overcloud")

Comment 4 Ollie Walsh 2021-05-20 20:52:24 UTC
(In reply to Ollie Walsh from comment #3)
> (In reply to Jeffrey Terrill from comment #2)
> > (In reply to Ollie Walsh from comment #0)
> > > If the initial deployment fails in heat the next run fails with:
> > > 
> > > Traceback (most recent call last):
> > >   File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 32,
> > > in run
> > >     super(Command, self).run(parsed_args)
> > >   File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line
> > > 41, in run
> > >     return super(Command, self).run(parsed_args)
> > >   File "/usr/lib/python3.6/site-packages/cliff/command.py", line 185, in run
> > >     return_code = self.take_action(parsed_args) or 0
> > >   File
> > > "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py",
> > > line 1022, in take_action
> > >     self._update_parameters(parsed_args, stack)
> > >   File
> > > "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py",
> > > line 123, in _update_parameters                                             
> > > 
> > >     if nbd_tls_key in roledata[key]['config_settings']:
> > > TypeError: 'NoneType' object is not subscriptable
> > > 'NoneType' object is not subscriptable
> > > 
> > > Deleting the stack and redeploying works.
> > 
> > I hit this bug in a recent deployment but deleting the stack ("openstack
> > stack delete" on director) and redeploying resulted in the same error.
> 
> I meant deleting the overcloud works ("openstack overcloud delete overcloud")

Although deleting the heat stack should be sufficient.

When you you hit this bug did you compare the traceback? It's only the same bug if the it failed at /usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py line 123.

Comment 5 Jeffrey Terrill 2021-05-24 19:11:20 UTC
Re-tried today and this was the traceback:

    Exception occured while running the command
    Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 32, in run
        super(Command, self).run(parsed_args)
      File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
        return super(Command, self).run(parsed_args)
      File "/usr/lib/python3.6/site-packages/cliff/command.py", line 185, in run
        return_code = self.take_action(parsed_args) or 0
      File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 1022, in take_action
        self._update_parameters(parsed_args, stack)
      File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 123, in _update_parameters
        if nbd_tls_key in roledata[key]['config_settings']:
    TypeError: 'NoneType' object is not subscriptable
    'NoneType' object is not subscriptable
    END return value: 1

Comment 6 Ollie Walsh 2021-05-24 20:41:20 UTC
What exactly did you do to reproduce this?

If the overcloud stack does not exist then that code block should not be reachable:

 103         if stack_is_new:
 104             new_stack_args = (
 105                 ('NovaComputeLibvirtType', 'libvirt_type'),
 106             )
 107             param_args = param_args + new_stack_args
 108         else:
 109             globalcfg = utils.get_stack_output_item(stack, 'GlobalConfig')
 110 
 111             # verif if tls was enabled in previous deploy run
 112             if globalcfg and 'use_tls_for_nbd' in globalcfg:
 113                 nbd_tls = globalcfg['use_tls_for_nbd']
 114                 self.log.debug("use_tls_for_nbd=%s" % nbd_tls)
 115                 parameters['UseTLSTransportForNbd'] = nbd_tls
 116             else:
 117                 # in case of an update use_tls_for_nbd global config key
 118                 # won't exist, check the nbd_tls hiera key from the roledata.
 119                 roledata = utils.get_stack_output_item(stack, 'RoleData')
 120                 if roledata:
 121                     nbd_tls_key = 'nova::compute::libvirt::qemu::nbd_tls'
 122                     for key in roledata:
 123                         if nbd_tls_key in roledata[key]['config_settings']:

Comment 7 Jeffrey Terrill 2021-05-25 14:01:19 UTC
Deleted the overcloud stack:

(undercloud) [stack@c0-stage-director ~]$ openstack overcloud delete c0-stage
Are you sure you want to delete this overcloud [y/N]? y
Undeploying stack c0-stage...
/usr/lib/python3.6/site-packages/websocket/_http.py:161: ResourceWarning: unclosed <socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 51230)>
  sock = socket.socket(family, socktype, proto)
Waiting for messages on queue 'tripleo' with no timeout.

Deleting plan c0-stage...
/usr/lib/python3.6/site-packages/websocket/_http.py:161: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 54050)>
  sock = socket.socket(family, socktype, proto)
Success.




Then re-ran the overcloud deployment:

    START with options: overcloud deploy --stack c0-stage --timeout 100 --deployed-server --disable-validations --overcloud-ssh-user stack --overcloud-ssh-key ~/.ssh/id_rsa --verbose --answers-file answers.yaml -n
 network_data.yaml -r roles_data.yaml --stack-only
    command: overcloud deploy -> tripleoclient.v1.overcloud_deploy.DeployOvercloud (auth=True)
    Using auth plugin: password
    Exception occured while running the command
    Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 32, in run
        super(Command, self).run(parsed_args)
      File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
        return super(Command, self).run(parsed_args)
      File "/usr/lib/python3.6/site-packages/cliff/command.py", line 185, in run
        return_code = self.take_action(parsed_args) or 0
      File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 1022, in take_action
        self._update_parameters(parsed_args, stack)
      File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 123, in _update_parameters
        if nbd_tls_key in roledata[key]['config_settings']:
    TypeError: 'NoneType' object is not subscriptable
    'NoneType' object is not subscriptable

Comment 34 errata-xmlrpc 2021-12-09 20:18:39 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 (Red Hat OpenStack Platform 16.1.7 (Train) bug fix and enhancement 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-2021:3762