error 500 when responsible user is selected when updating object

Bug #1576160 reported by Pawel Brzozowski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
High
Alexander Lomski

Bug Description

Detailed bug description:

Error 500 when responsible user is selected when updating object.

Steps to reproduce:

Update object when responsible user is created.

Expected results:

Update works.

Actual result:

It fails with 500 error:

Internal Server Error: /56/edit
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 112, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py", line 29, in _wrapper
    return bound_func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py", line 25, in bound_func
    return func(self, *args2, **kwargs2)
  File "./inventory/views/crud.py", line 37, in dispatch
    return super(CRUDMixin, self).dispatch(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "./inventory/views/crud.py", line 254, in post
    obj = form.save()
  File "/usr/lib/python2.7/dist-packages/django/forms/models.py", line 446, in save
    construct=False)
  File "/usr/lib/python2.7/dist-packages/django/forms/models.py", line 100, in save_instance
    save_m2m()
  File "/usr/lib/python2.7/dist-packages/django/forms/models.py", line 96, in save_m2m
    f.save_form_data(instance, cleaned_data[f.name])
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 1527, in save_form_da$
a
    setattr(instance, self.attname, data)
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 840, in __set__
    manager.add(*value)
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 581, in add
    self._add_items(self.source_field_name, self.target_field_name, *objs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 670, in _add_items
    for obj_id in new_ids
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 356, in bulk_create
    self._batched_insert(objs_without_pk, fields, batch_size)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 835, in _batched_insert
    using=self.db)
 File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 232, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 1511, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 898, in execute_sql
    cursor.execute(sql, params)
  File "/usr/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 124, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`racks`.`invent
ory_inventoryobject_responsible`, CONSTRAINT `racksuser_id_refs_id_1f3b0e6e8e82e9a4` FOREIGN KEY (`racksu
ser_id`) REFERENCES `auth_user` (`id`))')

Reproducibility:

Always.

Workaround:

Not adding responsible user.

Impact:

It hurts.

Description of the environment:
https://inventory.infra.mirantis.net/
python-django-racks 0.1+git123-gc88afb1

Tags: area-pxetool
tags: added: area-pxetool
information type: Private → Public
Changed in fuel:
importance: Undecided → High
assignee: Fuel Infra Apps (fuel-infra-apps) → Alexander Lomski (aliaksandr-lomski)
status: New → Incomplete
Revision history for this message
Alexander Charykov (acharykov) wrote :

Sorry I can't reproduce this bug, can you provide more detailed steps.

What I have done:
- open editing object
- select user
- press save

Works fine.

Revision history for this message
Fuel Devops McRobotson (fuel-devops-robot) wrote : Fix proposed to fuel-infra/packages/python-django-racks (master)

Fix proposed to branch: master
Change author: Alexander Lomski <email address hidden>
Review: https://review.fuel-infra.org/20212

Changed in fuel:
status: Incomplete → In Progress
Revision history for this message
Fuel Devops McRobotson (fuel-devops-robot) wrote : Fix merged to fuel-infra/packages/python-django-racks (master)

Reviewed: https://review.fuel-infra.org/20212
Submitter: Alexander Charykov <email address hidden>
Branch: master

Commit: 351a1cb43d45060c1a7eae3fdc5635dcf1bb6a46
Author: Alexander Lomski <email address hidden>
Date: Thu Apr 28 13:12:06 2016

Fix for bug in many2many constraints.

Tables for many2many connections between InventoryObject/RacksUser and
Lab/RacksUser had constraints for auth.User instead of inventory.RacksUser,
resulting in fatal errors when trying to assign responsible users.

Added custom migration to inventory app to fix the issue.

Closes-Bug: #1576160
Change-Id: I35a9c74835e949f5f090f94acf5609eeb84c2b4a

Changed in fuel:
status: In Progress → Fix Committed
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.