Public bug reported:

When exist a port which used by loadbalancer vip, and now as my env didn't 
setup the lb-agent,so I just want to delete the port.
The server showed "cannot be deleted directly via the port API: has device 
owner neutron:LOADBALANCER".But user can update this port's device_owner to 
anything.And rerun port-delete,server showed "Request Failed: internal server 
error while processing your request".

And the err log from (neutron)server.log is :
 from (pid=4719) _http_log_response 
/usr/local/lib/python2.7/dist-packages/keystoneclient/session.py:224
2015-07-31 11:20:50.238 DEBUG neutron.plugins.ml2.managers 
[req-9f8e0ef0-14b8-418f-9213-c5fd1df46cdb admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
2015-07-31 11:20:50.239 INFO neutron.wsgi 
[req-9f8e0ef0-14b8-418f-9213-c5fd1df46cdb admin 
e921522145ec4c4082844237991d5d01] 10.250.10.88 - - [31/Jul/2015 11:20:50] "GET 
/v2.0/ports.json?fields=id&id=d7c270ef-2a37-413f-99a3-8299aa96dc01 HTTP/1.1" 
200 272 0.094210
2015-07-31 11:20:50.262 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
2015-07-31 11:20:50.263 DEBUG neutron.plugins.ml2.plugin 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Deleting port 
d7c270ef-2a37-413f-99a3-8299aa96dc01 from (pid=4719) _pre_delete_port 
/opt/stack/neutron/neutron/plugins/ml2/plugin.py:1253
2015-07-31 11:20:50.263 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Notify callbacks for port, before_delete from 
(pid=4719) _notify_loop /opt/stack/neutron/neutron/callbacks/manager.py:135
2015-07-31 11:20:50.264 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling callback 
neutron_lbaas.db.loadbalancer.loadbalancer_db._prevent_lbaas_port_delete_callback
 from (pid=4719) _notify_loop 
/opt/stack/neutron/neutron/callbacks/manager.py:141
2015-07-31 11:20:50.280 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling callback 
neutron.db.l3_db._prevent_l3_port_delete_callback from (pid=4719) _notify_loop 
/opt/stack/neutron/neutron/callbacks/manager.py:141
2015-07-31 11:20:50.307 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
2015-07-31 11:20:50.324 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended network dict for driver 
'port_security' from (pid=4719) extend_network_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:807
2015-07-31 11:20:50.328 DEBUG neutron.plugins.ml2.db 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] For port 
d7c270ef-2a37-413f-99a3-8299aa96dc01, host allinone, got binding levels [] from 
(pid=4719) get_binding_levels /opt/stack/neutron/neutron/plugins/ml2/db.py:177
2015-07-31 11:20:50.333 DEBUG neutron.plugins.ml2.plugin 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling delete_port for 
d7c270ef-2a37-413f-99a3-8299aa96dc01 owned by bzhao from (pid=4719) delete_port 
/opt/stack/neutron/neutron/plugins/ml2/plugin.py:1317
2015-07-31 11:20:50.337 ERROR neutron.api.v2.resource 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] delete failed
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource Traceback (most recent 
call last):
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/api/v2/resource.py", line 83, in resource
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result = 
method(request=request, **args)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     ectxt.value = 
e.inner_exc
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in 
__exit__
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
six.reraise(self.type_, self.value, self.tb)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return f(*args, 
**kwargs)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/api/v2/base.py", line 499, in delete
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
obj_deleter(request.context, id, **kwargs)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     ectxt.value = 
e.inner_exc
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in 
__exit__
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
six.reraise(self.type_, self.value, self.tb)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return f(*args, 
**kwargs)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1318, in delete_port
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     super(Ml2Plugin, 
self).delete_port(context, id)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 909, in delete_port
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
self.ipam.delete_port(context, id)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/db/ipam_backend_mixin.py", line 412, in delete_port
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     query.delete()
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2827, in 
delete
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     delete_op.exec_()
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 
1086, in exec_
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     self._do_exec()
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 
1264, in _do_exec
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     mapper=self.mapper)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1023, 
in execute
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     bind, 
close_with_result=True).execute(clause, params or {})
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, 
in execute
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return meth(self, 
multiparams, params)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, 
in _execute_on_connection
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return 
connection._execute_clauseelement(self, multiparams, params)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, 
in _execute_clauseelement
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     compiled_sql, 
distilled_params
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, 
in _execute_context
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     context)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1337, 
in _handle_dbapi_exception
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
util.raise_from_cause(newraise, exc_info)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 199, 
in raise_from_cause
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
reraise(type(exception), exception, tb=exc_tb)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, 
in _execute_context
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     context)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 
450, in do_execute
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
cursor.execute(statement, parameters)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 134, in 
execute
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result = 
self._query(query)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 282, in _query
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     conn.query(q)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 768, in 
query
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     self._affected_rows = 
self._read_query_result(unbuffered=unbuffered)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 929, in 
_read_query_result
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result.read()
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1125, in 
read
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     first_packet = 
self.connection._read_packet()
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 893, in 
_read_packet
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     packet.check_error()
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 369, in 
check_error
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
err.raise_mysql_exception(self._data)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 120, in 
raise_mysql_exception
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
_check_mysql_exception(errinfo)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 112, in 
_check_mysql_exception
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     raise 
errorclass(errno, errorvalue)
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource DBReferenceError: 
(pymysql.err.IntegrityError) (1451, u'Cannot delete or update a parent row: a 
foreign key constraint fails (`neutron`.`vips`, CONSTRAINT `vips_ibfk_1` 
FOREIGN KEY (`port_id`) REFERENCES `ports` (`id`))') [SQL: u'DELETE FROM ports 
WHERE ports.id = %s'] [parameters: (u'd7c270ef-2a37-413f-99a3-8299aa96dc01',)]
2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource

** Affects: neutron
     Importance: Undecided
     Assignee: zhaobo (zhaobo6)
         Status: New

** Description changed:

  When exist a port which used by loadbalancer vip, and now as my env didn't 
setup the lb-agent,so I just want to delete the port.
- The server showed "cannot be deleted directly via the port API: has device 
owner neutron:LOADBALANCER".But user can update this port's device_owner to 
anything.And return port-delete,server showed "Request Failed: internal server 
error while processing your request".
+ The server showed "cannot be deleted directly via the port API: has device 
owner neutron:LOADBALANCER".But user can update this port's device_owner to 
anything.And rerun port-delete,server showed "Request Failed: internal server 
error while processing your request".
  
  And the err log from (neutron)server.log is :
-  from (pid=4719) _http_log_response 
/usr/local/lib/python2.7/dist-packages/keystoneclient/session.py:224
+  from (pid=4719) _http_log_response 
/usr/local/lib/python2.7/dist-packages/keystoneclient/session.py:224
  2015-07-31 11:20:50.238 DEBUG neutron.plugins.ml2.managers 
[req-9f8e0ef0-14b8-418f-9213-c5fd1df46cdb admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
  2015-07-31 11:20:50.239 INFO neutron.wsgi 
[req-9f8e0ef0-14b8-418f-9213-c5fd1df46cdb admin 
e921522145ec4c4082844237991d5d01] 10.250.10.88 - - [31/Jul/2015 11:20:50] "GET 
/v2.0/ports.json?fields=id&id=d7c270ef-2a37-413f-99a3-8299aa96dc01 HTTP/1.1" 
200 272 0.094210
  2015-07-31 11:20:50.262 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
  2015-07-31 11:20:50.263 DEBUG neutron.plugins.ml2.plugin 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Deleting port 
d7c270ef-2a37-413f-99a3-8299aa96dc01 from (pid=4719) _pre_delete_port 
/opt/stack/neutron/neutron/plugins/ml2/plugin.py:1253
  2015-07-31 11:20:50.263 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Notify callbacks for port, before_delete from 
(pid=4719) _notify_loop /opt/stack/neutron/neutron/callbacks/manager.py:135
  2015-07-31 11:20:50.264 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling callback 
neutron_lbaas.db.loadbalancer.loadbalancer_db._prevent_lbaas_port_delete_callback
 from (pid=4719) _notify_loop 
/opt/stack/neutron/neutron/callbacks/manager.py:141
  2015-07-31 11:20:50.280 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling callback 
neutron.db.l3_db._prevent_l3_port_delete_callback from (pid=4719) _notify_loop 
/opt/stack/neutron/neutron/callbacks/manager.py:141
  2015-07-31 11:20:50.307 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
  2015-07-31 11:20:50.324 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended network dict for driver 
'port_security' from (pid=4719) extend_network_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:807
  2015-07-31 11:20:50.328 DEBUG neutron.plugins.ml2.db 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] For port 
d7c270ef-2a37-413f-99a3-8299aa96dc01, host allinone, got binding levels [] from 
(pid=4719) get_binding_levels /opt/stack/neutron/neutron/plugins/ml2/db.py:177
  2015-07-31 11:20:50.333 DEBUG neutron.plugins.ml2.plugin 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling delete_port for 
d7c270ef-2a37-413f-99a3-8299aa96dc01 owned by bzhao from (pid=4719) delete_port 
/opt/stack/neutron/neutron/plugins/ml2/plugin.py:1317
  2015-07-31 11:20:50.337 ERROR neutron.api.v2.resource 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] delete failed
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource Traceback (most recent 
call last):
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/api/v2/resource.py", line 83, in resource
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result = 
method(request=request, **args)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     ectxt.value = 
e.inner_exc
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in 
__exit__
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
six.reraise(self.type_, self.value, self.tb)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return f(*args, 
**kwargs)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/api/v2/base.py", line 499, in delete
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
obj_deleter(request.context, id, **kwargs)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     ectxt.value = 
e.inner_exc
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in 
__exit__
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
six.reraise(self.type_, self.value, self.tb)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return f(*args, 
**kwargs)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1318, in delete_port
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     super(Ml2Plugin, 
self).delete_port(context, id)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 909, in delete_port
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
self.ipam.delete_port(context, id)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/db/ipam_backend_mixin.py", line 412, in delete_port
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     query.delete()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2827, in 
delete
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     delete_op.exec_()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 
1086, in exec_
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     self._do_exec()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 
1264, in _do_exec
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     mapper=self.mapper)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1023, 
in execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     bind, 
close_with_result=True).execute(clause, params or {})
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, 
in execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return meth(self, 
multiparams, params)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, 
in _execute_on_connection
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return 
connection._execute_clauseelement(self, multiparams, params)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, 
in _execute_clauseelement
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     compiled_sql, 
distilled_params
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, 
in _execute_context
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     context)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1337, 
in _handle_dbapi_exception
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
util.raise_from_cause(newraise, exc_info)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 199, 
in raise_from_cause
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
reraise(type(exception), exception, tb=exc_tb)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, 
in _execute_context
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     context)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 
450, in do_execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
cursor.execute(statement, parameters)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 134, in 
execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result = 
self._query(query)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 282, in _query
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     conn.query(q)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 768, in 
query
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     self._affected_rows 
= self._read_query_result(unbuffered=unbuffered)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 929, in 
_read_query_result
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result.read()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1125, in 
read
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     first_packet = 
self.connection._read_packet()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 893, in 
_read_packet
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     packet.check_error()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 369, in 
check_error
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
err.raise_mysql_exception(self._data)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 120, in 
raise_mysql_exception
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
_check_mysql_exception(errinfo)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 112, in 
_check_mysql_exception
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     raise 
errorclass(errno, errorvalue)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource DBReferenceError: 
(pymysql.err.IntegrityError) (1451, u'Cannot delete or update a parent row: a 
foreign key constraint fails (`neutron`.`vips`, CONSTRAINT `vips_ibfk_1` 
FOREIGN KEY (`port_id`) REFERENCES `ports` (`id`))') [SQL: u'DELETE FROM ports 
WHERE ports.id = %s'] [parameters: (u'd7c270ef-2a37-413f-99a3-8299aa96dc01',)]
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource

** Changed in: neutron
     Assignee: (unassigned) => zhaobo (zhaobo6)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1480039

Title:
  User cannot delete the port which is used by lb vip,but user can
  update it device_owner field

Status in neutron:
  New

Bug description:
  When exist a port which used by loadbalancer vip, and now as my env didn't 
setup the lb-agent,so I just want to delete the port.
  The server showed "cannot be deleted directly via the port API: has device 
owner neutron:LOADBALANCER".But user can update this port's device_owner to 
anything.And rerun port-delete,server showed "Request Failed: internal server 
error while processing your request".

  And the err log from (neutron)server.log is :
   from (pid=4719) _http_log_response 
/usr/local/lib/python2.7/dist-packages/keystoneclient/session.py:224
  2015-07-31 11:20:50.238 DEBUG neutron.plugins.ml2.managers 
[req-9f8e0ef0-14b8-418f-9213-c5fd1df46cdb admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
  2015-07-31 11:20:50.239 INFO neutron.wsgi 
[req-9f8e0ef0-14b8-418f-9213-c5fd1df46cdb admin 
e921522145ec4c4082844237991d5d01] 10.250.10.88 - - [31/Jul/2015 11:20:50] "GET 
/v2.0/ports.json?fields=id&id=d7c270ef-2a37-413f-99a3-8299aa96dc01 HTTP/1.1" 
200 272 0.094210
  2015-07-31 11:20:50.262 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
  2015-07-31 11:20:50.263 DEBUG neutron.plugins.ml2.plugin 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Deleting port 
d7c270ef-2a37-413f-99a3-8299aa96dc01 from (pid=4719) _pre_delete_port 
/opt/stack/neutron/neutron/plugins/ml2/plugin.py:1253
  2015-07-31 11:20:50.263 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Notify callbacks for port, before_delete from 
(pid=4719) _notify_loop /opt/stack/neutron/neutron/callbacks/manager.py:135
  2015-07-31 11:20:50.264 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling callback 
neutron_lbaas.db.loadbalancer.loadbalancer_db._prevent_lbaas_port_delete_callback
 from (pid=4719) _notify_loop 
/opt/stack/neutron/neutron/callbacks/manager.py:141
  2015-07-31 11:20:50.280 DEBUG neutron.callbacks.manager 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling callback 
neutron.db.l3_db._prevent_l3_port_delete_callback from (pid=4719) _notify_loop 
/opt/stack/neutron/neutron/callbacks/manager.py:141
  2015-07-31 11:20:50.307 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended port dict for driver 'port_security' 
from (pid=4719) extend_port_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:821
  2015-07-31 11:20:50.324 DEBUG neutron.plugins.ml2.managers 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Extended network dict for driver 
'port_security' from (pid=4719) extend_network_dict 
/opt/stack/neutron/neutron/plugins/ml2/managers.py:807
  2015-07-31 11:20:50.328 DEBUG neutron.plugins.ml2.db 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] For port 
d7c270ef-2a37-413f-99a3-8299aa96dc01, host allinone, got binding levels [] from 
(pid=4719) get_binding_levels /opt/stack/neutron/neutron/plugins/ml2/db.py:177
  2015-07-31 11:20:50.333 DEBUG neutron.plugins.ml2.plugin 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] Calling delete_port for 
d7c270ef-2a37-413f-99a3-8299aa96dc01 owned by bzhao from (pid=4719) delete_port 
/opt/stack/neutron/neutron/plugins/ml2/plugin.py:1317
  2015-07-31 11:20:50.337 ERROR neutron.api.v2.resource 
[req-fdb7d324-b110-4123-b48f-d390071a21fd admin 
e921522145ec4c4082844237991d5d01] delete failed
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource Traceback (most recent 
call last):
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/api/v2/resource.py", line 83, in resource
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result = 
method(request=request, **args)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     ectxt.value = 
e.inner_exc
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in 
__exit__
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
six.reraise(self.type_, self.value, self.tb)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return f(*args, 
**kwargs)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/api/v2/base.py", line 499, in delete
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
obj_deleter(request.context, id, **kwargs)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     ectxt.value = 
e.inner_exc
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in 
__exit__
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
six.reraise(self.type_, self.value, self.tb)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return f(*args, 
**kwargs)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1318, in delete_port
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     super(Ml2Plugin, 
self).delete_port(context, id)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 909, in delete_port
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
self.ipam.delete_port(context, id)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/opt/stack/neutron/neutron/db/ipam_backend_mixin.py", line 412, in delete_port
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     query.delete()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2827, in 
delete
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     delete_op.exec_()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 
1086, in exec_
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     self._do_exec()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 
1264, in _do_exec
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     mapper=self.mapper)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1023, 
in execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     bind, 
close_with_result=True).execute(clause, params or {})
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, 
in execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return meth(self, 
multiparams, params)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, 
in _execute_on_connection
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     return 
connection._execute_clauseelement(self, multiparams, params)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, 
in _execute_clauseelement
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     compiled_sql, 
distilled_params
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, 
in _execute_context
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     context)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1337, 
in _handle_dbapi_exception
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
util.raise_from_cause(newraise, exc_info)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 199, 
in raise_from_cause
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
reraise(type(exception), exception, tb=exc_tb)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, 
in _execute_context
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     context)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 
450, in do_execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
cursor.execute(statement, parameters)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 134, in 
execute
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result = 
self._query(query)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 282, in _query
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     conn.query(q)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 768, in 
query
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     self._affected_rows 
= self._read_query_result(unbuffered=unbuffered)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 929, in 
_read_query_result
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     result.read()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1125, in 
read
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     first_packet = 
self.connection._read_packet()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 893, in 
_read_packet
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     packet.check_error()
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 369, in 
check_error
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
err.raise_mysql_exception(self._data)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 120, in 
raise_mysql_exception
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     
_check_mysql_exception(errinfo)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource   File 
"/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 112, in 
_check_mysql_exception
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource     raise 
errorclass(errno, errorvalue)
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource DBReferenceError: 
(pymysql.err.IntegrityError) (1451, u'Cannot delete or update a parent row: a 
foreign key constraint fails (`neutron`.`vips`, CONSTRAINT `vips_ibfk_1` 
FOREIGN KEY (`port_id`) REFERENCES `ports` (`id`))') [SQL: u'DELETE FROM ports 
WHERE ports.id = %s'] [parameters: (u'd7c270ef-2a37-413f-99a3-8299aa96dc01',)]
  2015-07-31 11:20:50.337 TRACE neutron.api.v2.resource

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1480039/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to