Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1109894

Summary: Error: Could not set 'present' on ensure: undefined method `[]' for nil:NilClass at 7:/etc/puppet/environments/production/modules/neutron/manifests/plugins/ovs/port.pp
Product: Red Hat OpenStack Reporter: Miguel Angel Ajo <majopela>
Component: openstack-puppet-modulesAssignee: Ivan Chavero <ichavero>
Status: CLOSED ERRATA QA Contact: Omri Hochman <ohochman>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.0 (RHEL 7)CC: apevec, augol, gdubreui, hbrock, ichavero, jguiditt, lars, lpeer, majopela, mburns, morazi, nyechiel, ohochman, rhos-maint, yeylon
Target Milestone: rc   
Target Release: 5.0 (RHEL 7)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openstack-puppet-modules-2014.1-16.2.el7ost Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1109857 Environment:
Last Closed: 2014-07-08 15:39:33 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:
Bug Depends On: 1109857    
Bug Blocks:    

Description Miguel Angel Ajo 2014-06-16 15:02:56 UTC
+++ This bug was initially created as a clone of Bug #1109857 +++


Description of problem:

After workarounding #1109857: https://bugzilla.redhat.com/show_bug.cgi?id=1109857#c6

When trying to deploy with staypuft / foreman, deployment of network node fails with: 

Error: Could not set 'present' on ensure: undefined method `[]' for nil:NilClass at 7:/etc/puppet/environments/production/modules/neutron/manifests/plugins/ovs/port.pp
Error: Could not set 'present' on ensure: undefined method `[]' for nil:NilClass at 7:/etc/puppet/environments/production/modules/neutron/manifests/plugins/ovs/port.pp
Wrapped exception:
undefined method `[]' for nil:NilClass
Error: /Stage[main]/Neutron::Agents::Ovs/Neutron::Plugins::Ovs::Port[br-ex:eth1]/Vs_port[eth1]/ensure: change from absent to present failed: Could not set 'present' on ensure: undefined method `[]' for nil:NilClass at 7:/etc/puppet/environments/production/modules/neutron/manifests/plugins/ovs/port.pp


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


openstack-puppet-modules-2014.1-14.3.el6ost.noarch
foreman-installer-staypuft-0.0.17-1.el6ost.noarch
foreman-installer-1.5.0-0.4.RC2.el6ost.noarch

foreman-proxy-1.6.0.6-1.el6sat.noarch
openstack-foreman-installer-2.0.6-1.el6ost.noarch
ruby193-rubygem-foreman_discovery-1.3.0-0.1.rc2.el6sat.noarch
foreman-discovery-image-6.5-20140424.0.1.el6sat.noarch
ruby193-rubygem-foreman_openstack_simplify-0.0.6-7.el6ost.noarch
foreman-1.6.0.15-1.el6sat.noarch
foreman-selinux-1.6.0-2.el6sat.noarch
ruby193-rubygem-foreman-tasks-0.5.7-2.el6sat.noarch
rubygem-foreman_api-0.1.11-4.el6sat.noarch

foreman-installer-staypuft-0.0.17-1.el6ost.noarch
ruby193-rubygem-staypuft-0.1.1-1.el6ost.noarch


How reproducible:

100%


Steps to Reproduce:
1. setup a deployment with staypuft or foreman alone
2. fix with https://bugzilla.redhat.com/show_bug.cgi?id=1109857#c6
3.
   Set:
      Ovs bridge mappings to ["physnet1:br-ex"]
      Ovs bridge uplinks to ["br-ex:eth1"]
   for the network nodes

Actual results:

Error in puppet scripts.

Expected results:

Correct deployment.


Additional info:

Comment 2 Ivan Chavero 2014-06-17 11:11:14 UTC
Miguel, do you have a puppet manifest that i can check directly. I'm testing with packstack and can't reproduce it.

Comment 3 Miguel Angel Ajo 2014-06-17 12:33:02 UTC
Ivan, I'm deploying from foreman,

Where should I get the manifests from?

Thanks.

Comment 4 Ivan Chavero 2014-06-17 14:37:28 UTC
Miguel,

I'm not very familiar with foreman so i don't know where the manifests go. 
I'll ask in #rhos-dev for help with that

Comment 5 Ivan Chavero 2014-06-18 13:40:48 UTC
Currently checking the environment in which this problem happened, it seems that the problem does not appear anymore.
I recommend try a fresh install and check if the problem appears again.

Comment 6 Ivan Chavero 2014-06-18 14:57:51 UTC
it seems to be a mismatch in the execution order of the manifest that creates br-ex and the one that uses it, checking the neutron puppet module

Comment 7 Ivan Chavero 2014-06-19 14:14:32 UTC
i'm testing some code in the neutron puppet module in order to control this but i haven't been able to control this properly.

Comment 8 Lars Kellogg-Stedman 2014-06-19 16:20:40 UTC
So this is interesting.  On ajo's system, the following manifest will reproduce the problem:

    vs_bridge { 'br-ex': 
            ensure => present,
    }
    vs_port { 'eth1':
            ensure => present,
            bridge => 'br-ex',
    }

Like this:

    # puppet apply this_fails.pp
    Notice: Compiled catalog for networknode.rhel6-staypuft.com in environment production in 0.07 seconds
    Notice: /Stage[main]/Main/Vs_bridge[br-ex]/ensure: created
    Error: Could not set 'present' on ensure: undefined method `[]' for nil:NilClass at 7:/root/this_fails.pp
    Error: Could not set 'present' on ensure: undefined method `[]' for nil:NilClass at 7:/root/this_fails.pp
    Wrapped exception:
    undefined method `[]' for nil:NilClass
    Error: /Stage[main]/Main/Vs_port[eth1]/ensure: change from absent to present failed: Could not set 'present' on ensure: undefined method `[]' for nil:NilClass at 7:/root/this_fails.pp
    Notice: Finished catalog run in 0.13 seconds


But, if you first add an ip address to eth1:

    # ip addr add 10.12.13.14/24 dev eth1

And then run the manifest:

    # puppet apply this_fails.pp 
    Notice: Compiled catalog for networknode.rhel6-staypuft.com in environment production in 0.07 seconds
    Notice: /Stage[main]/Main/Vs_bridge[br-ex]/ensure: created
    Notice: /Stage[main]/Main/Vs_port[eth1]/ensure: created
    Notice: Finished catalog run in 4.15 seconds

It completes without errors.

Comment 9 Lars Kellogg-Stedman 2014-06-19 16:22:45 UTC
I've confirmed this behavior on my own system...if the interface you are trying to add does not have an ip address, this fails reliably.

Comment 10 Lars Kellogg-Stedman 2014-06-19 17:03:29 UTC
The problem is in lib/puppet/provider/ovs_port/ovs_redhat.rb, which does this:

        device = ip('addr', 'show', @resource[:interface])
        cidr = device.to_s.match(/inet (\d*\.\d*\.\d*\.\d*\/\d*)/)[1]
        IFCFG::BridgeStatic.new(@resource[:bridge], cidr).save

If the device has no ip adDress, "cidr" will be nil and the attempt to use "[1]" on it raises an exception.

Comment 11 Ivan Chavero 2014-06-19 18:16:06 UTC
nice catch Lars!!

This leaves us with this options to solve this problem:


- make <put your installer here> ask the user to set the ip address or set it to get it via dhcp and then add it to the respective manifest (this is my preference since gives the user explicit choices)

- make the puppet module try to get a ip address via dhcp if the interface does not have one.

- make the puppet module show an error if the interface does not have an ip address and ask the user to configure it.

Comment 12 Lars Kellogg-Stedman 2014-06-19 18:53:42 UTC
I don't think there is any reason to require an address on this interface.  It is perfectly valid for there to be no ip address on the bridge and for the external network gateway to be elsewhere on the network.

I have submitted a simple change upstream to permit this module to work when the interface has no address:

  https://review.openstack.org/#/c/94504/

Comment 13 Ivan Chavero 2014-06-19 19:27:28 UTC
Testing patch on Miguel's environment

Comment 14 Ivan Chavero 2014-06-19 20:55:29 UTC
Tested patch in Miguel's environment and it works

Comment 15 Lars Kellogg-Stedman 2014-06-19 20:56:42 UTC
Ivan confirms that this change fixes the behavior.

Note that my patch is a very small change to an existing review, which stems from https://bugzilla.redhat.com/show_bug.cgi?id=1095279.  Comments on that bz indicate that they are waiting for the upstream maintainer to return from PTO in order to merge these changes.

Comment 19 Omri Hochman 2014-07-01 16:44:17 UTC
Verified : openstack-puppet-modules-2014.1-18.el6ost.noarch

Unable to reproduce the bug. I had successful neutron deployment with : 
   ovs_bridge_mappings = ["inter-vlan:br-eth3","ext-vlan:br-ex"]
   ovs_bridge_uplinks = ["br-eth3:eth3","br-ex:eth3.195"]


Checked also that the fix is in the Code :
 /var/lib/puppet/lib/puppet/provider/vs_port/ovs_redhat.rb
-------------------------------------
        device = ip('addr', 'show', @resource[:interface])
        cidr = device.to_s.match(/inet (\d*\.\d*\.\d*\.\d*\/\d*)/)
        cidr = cidr ? cidr[1] : ""
        IFCFG::BridgeStatic.new(@resource[:bridge], cidr).save



  def dynamic?
    device = ''
    device = ip('addr', 'show', @resource[:interface])
    return device =~ /dynamic/ ? true : false
  end

Comment 20 Gilles Dubreuil 2014-07-03 12:24:39 UTC
Current patch is also creating ifcfg files for bridge/port when not using physical interfaces, that breaking neutron

Latest upstream patch set https://review.openstack.org/#/c/94504/7/ addresses it.

Comment 25 errata-xmlrpc 2014-07-08 15:39:33 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.

http://rhn.redhat.com/errata/RHEA-2014-0846.html

Comment 26 Amit Ugol 2018-05-02 10:52:44 UTC
closed, no need for needinfo.