Bad port request: can not delete DHCP port

Bug #1776168 reported by xiaoting
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Rally
In Progress
Undecided
xiaoting

Bug Description

Rally benchmark for below scenario failed to clearup network ( at step delete port)
Root cause is for port device type which is network:dhcp port can not be deleted directly. You can delete subnet then its associated dhcp port will be deleted.

---
  VMTasks.boot_runcommand_delete:
    -
      args:
        flavor:
            name: "m1.small"
        image:
            name: "ubuntu-14.04-server-amd64"
        floating_network: "public-tempest"
        force_delete: false
        command:
            local_path: "/home/rally/.rally/tasks/vmtask.sh"
            remote_path: "/tmp/vmtask.sh"
        username: "ubuntu"
        boot_server_kwargs: {key-name: "vioKey"}
      runner:
        type: "constant"
        times: {{ 1 * 1 }}
        concurrency: 1
      context:
        network: {}
      sla:
         failure_rate:
           max: 0

Error log:
2018-05-24 16:34:04.073 278 RALLYDEBUG rally.plugins.openstack.context.network.networks [-] Bad port request: Can not delete DHCP port 0d446c18-28fd-4872-a1ac-2bc726bdf1dc.
Neutron server returns request_ids: ['req-13d648d3-268c-4a8f-8544-416c2ec3e4f9']
2018-05-24 16:34:04.090 278 WARNING /usr/local/lib/python2.7/dist-packages/rally/common/logging.py:160 [-] [self.logger.exception(value)] Do not transmit an exception objects to logging. It will be included automagically. Transmit a user-friendly explanation instead.: BadRequest: Bad port request: Can not delete DHCP port 0d446c18-28fd-4872-a1ac-2bc726bdf1dc.
Neutron server returns request_ids: ['req-13d648d3-268c-4a8f-8544-416c2ec3e4f9']
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks [-] Bad port request: Can not delete DHCP port 0d446c18-28fd-4872-a1ac-2bc726bdf1dc.
Neutron server returns request_ids: ['req-13d648d3-268c-4a8f-8544-416c2ec3e4f9']: BadRequest: Bad port request: Can not delete DHCP port 0d446c18-28fd-4872-a1ac-2bc726bdf1dc.
Neutron server returns request_ids: ['req-13d648d3-268c-4a8f-8544-416c2ec3e4f9']
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks Traceback (most recent call last):
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/rally/plugins/openstack/context/network/networks.py", line 110, in cleanup
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks net_wrapper.delete_network(network)
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/rally/plugins/openstack/wrappers/network.py", line 286, in delete_network
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks self.client.delete_port(port["id"])
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 789, in delete_port
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks return self.delete(self.port_path % (port))
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 348, in delete
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks headers=headers, params=params)
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 329, in retry_request
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks headers=headers, params=params)
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 292, in do_request
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks self._handle_fault_response(status_code, replybody, resp)
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 268, in _handle_fault_response
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks exception_handler_v20(status_code, error_body)
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks File "/usr/local/lib/python2.7/dist-packages/neutronclient/v2_0/client.py", line 92, in exception_handler_v20
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks request_ids=request_ids)
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks BadRequest: Bad port request: Can not delete DHCP port 0d446c18-28fd-4872-a1ac-2bc726bdf1dc.
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks Neutron server returns request_ids: ['req-13d648d3-268c-4a8f-8544-416c2ec3e4f9']
2018-05-24 16:34:04.091 278 ERROR rally.plugins.openstack.context.network.networks
2018-05-24 16:34:08.712 278 WARNING rally.plugins.openstack.context.network.networks [-] Failed to delete network for tenant d2aae753f8ed4609ad040d9aba187547: BadRequest: Bad port request: Can not delete DHCP port e7b86a1b-6523-4b08-a71e-3d00f540e688.

Propose fix:
    def delete_network(self, network):
        if self.supports_extension("dhcp_agent_scheduler")[0]:
            net_dhcps = self.client.list_dhcp_agent_hosting_networks(
                network["id"])["agents"]
            for net_dhcp in net_dhcps:
                self.client.remove_network_from_dhcp_agent(net_dhcp["id"],
                                                           network["id"])

        if network["router_id"]:
            self.client.remove_gateway_router(network["router_id"])

        for port in self.client.list_ports(network_id=network["id"])["ports"]:
            if port["device_owner"] in (
                    "network:router_interface",
                    "network:router_interface_distributed",
                    "network:ha_router_replicated_interface",
                    "network:dhcp",-----------------exclude device type for dhcp port
                    "network:router_gateway"):
                try:
                    self.client.remove_interface_router(
                        port["device_id"], {"port_id": port["id"]})
                except (neutron_exceptions.BadRequest,
                        neutron_exceptions.NotFound):
                    # Some neutron plugins don't use router as
                    # the device ID. Also, some plugin doesn't allow
                    # to update the ha rotuer interface as there is
                    # an internal logic to update the interface/data model
                    # instead.
                    pass
            else:
                try:
                    self.client.delete_port(port["id"])
                except neutron_exceptions.PortNotFoundClient:
                    # port is auto-removed
                    pass

Tags: test
xiaoting (83948980-t)
Changed in rally:
assignee: nobody → xiaoting (83948980-t)
xiaoting (83948980-t)
Changed in rally:
status: New → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.