Bug 1262275

Summary: Unable to add slave to bond using slave id or modify existing slave using name
Product: [oVirt] ovirt-engine Reporter: Marcin Mirecki <mmirecki>
Component: RestAPIAssignee: Marcin Mirecki <mmirecki>
Status: CLOSED CURRENTRELEASE QA Contact: Michael Burman <mburman>
Severity: low Docs Contact:
Priority: unspecified    
Version: 3.6.0CC: bugs, danken, juan.hernandez, mburman, mmucha, myakove, ylavi
Target Milestone: ovirt-3.6.1Flags: rule-engine: ovirt-3.6.z+
ylavi: Triaged+
danken: testing_plan_complete?
ylavi: planning_ack+
rule-engine: devel_ack+
rule-engine: testing_ack+
Target Release: 3.6.1   
Hardware: noarch   
OS: Unspecified   
Whiteboard: network
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-16 12:18:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Network RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marcin Mirecki 2015-09-11 10:29:28 UTC
Description of problem:

Adding a new slave to a bond fails when the slave is specified by the nic id.
The same operation works correctly when slave is specified by name.

For example:
The following rest requests specyfing nics by id will fail:

POST: http://localhost:8080/ovirt-engine/api/hosts/<host id>setupnetworks
<action>
  <modified_bonds>
    <host_nic id="c5fb3db6-44f3-42a0-bb18-6e7905a79400">
    <bonding>
        <slaves>
            <host_nic id="db31f40e-671a-4cff-8a14-9784116e44b8"/>
            <host_nic id="ea0216b9-2b39-4c9f-b70d-0462e7fa674a"/>
            <host_nic id="f572972c-cca8-4ed4-9907-aa39eaca14d1"/>
        </slaves>
    </bonding>
  </host_nic>
 </modified_bonds>
</action>

The following rest request will work fine:
<action>
    <modified_bonds>
      <host_nic id="c5fb3db6-44f3-42a0-bb18-6e7905a79400">
            <bonding>
                <slaves>
                    <host_nic>
                        <name>ens13</name>
                    </host_nic>
                    <host_nic >
                        <name>ens14</name>
                    </host_nic>
                </slaves>
            </bonding>
        </host_nic>
    </modified_bonds>
</action>

The opposite happens when an existing slave is specified by name. In that case the follwing error message is recieved:
Cannot setup Networks. Network interface 'ens13' is used multiple times in new or modified bonds in this request. Slave can be neither shared by multiple bonds nor used multiple times in one bond.

Cause of problem:

The problem lies in the code which creates HostSetupNetworksParameters.
HostNICMapper maps the rest request data to a Bond instance. The bond object is created based on the existing bond object, with existing slaves. After that the following code adds the new bonds from the request data.
HostNICMapper:112
                for (HostNIC slave : model.getBonding().getSlaves().getSlaves()) {
                    if (slave.isSetName()) {
                        entity.getSlaves().add(slave.getName());
                    }
So only the hosts with a name set are added.

When modyfing an existing slave, the code above will add the slave to the bond a second time, so the Bond object in HostSetupNetworksParameters will have this specific slave listed twice.


How reproducible:
Execute the following rest request:
The following rest requests specyfing nics by id will fail:

POST: http://localhost:8080/ovirt-engine/api/hosts/<host id>setupnetworks
<action>
  <modified_bonds>
    <host_nic id="c5fb3db6-44f3-42a0-bb18-6e7905a79400">
    <bonding>
        <slaves>
            <host_nic id="<slave nic id>"/>
            <host_nic id="<slave nic id>"/>

        </slaves>
    </bonding>
  </host_nic>
 </modified_bonds>
</action>


Actual results:
Host is not added to bond

Expected results:
Host is added to bond

Additional info:

Comment 1 Marcin Mirecki 2015-09-11 10:34:40 UTC
An additional problem is the removing of slave nics from a bond.
The same code only handles adding nics to a bond (by name), but does not check if any of the slaves have been removed.

Comment 2 Martin Mucha 2015-09-11 12:43:20 UTC
note: provided change 46054 changes only the way in which is bonds slaves collection interpreted: relative-->absolute.

Comment 3 Red Hat Bugzilla Rules Engine 2015-10-19 10:53:23 UTC
Target release should be placed once a package build is known to fix a issue. Since this bug is not modified, the target version has been reset. Please use target milestone to plan a fix for a oVirt release.

Comment 4 Yaniv Lavi 2015-10-29 12:33:52 UTC
In oVirt testing is done on single release by default. Therefore I'm removing the 4.0 flag. If you think this bug must be tested in 4.0 as well, please re-add the flag. Please note we might not have testing resources to handle the 4.0 clone.

Comment 5 Michael Burman 2015-12-08 08:48:16 UTC
Verified on - 3.6.1.1-0.1.el6

Comment 6 Sandro Bonazzola 2015-12-16 12:18:08 UTC
According to verification status and target milestone this issue should be fixed in oVirt 3.6.1. Closing current release.