← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1513825] [NEW] code duplication : tenant checked twice for resource creation

 

Public bug reported:

The check of the tenant done in neutron/db/common_db_mixin._get_tenant_id_for_create() is already did by the
Neutron Controller in prepare_request_body(), with a call to attibutes.populate_tenant_id().
Moreover, when the Controller processes a "create" requests, it will add the 'tenant_id' to the resource dict.

So instead of calling the _get_tenant_id_for_create(), modules can
directly get the tenant_id in the resource dict.

A firsts patch has been submitted to avoid duplicated code [1], but it
requires a bigger effort to add the tenant_id in requests used during
UTs. Indeed, UT framework seems to bypass the controller. Thus, the
tenant_id is not automatically added by the controller during UTs. The
_get_tenant_id_for_create() was convenient for UTs, since it retrieves
the tenant_id from the context, if it is not in the resource dict.

[1]https://review.openstack.org/#/c/241984/

** Affects: neutron
     Importance: Undecided
         Status: New


** Tags: low-hanging-fruit

** Tags added: low-hanging-fruit

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

Title:
  code duplication : tenant checked twice for resource creation

Status in neutron:
  New

Bug description:
  The check of the tenant done in neutron/db/common_db_mixin._get_tenant_id_for_create() is already did by the
  Neutron Controller in prepare_request_body(), with a call to attibutes.populate_tenant_id().
  Moreover, when the Controller processes a "create" requests, it will add the 'tenant_id' to the resource dict.

  So instead of calling the _get_tenant_id_for_create(), modules can
  directly get the tenant_id in the resource dict.

  A firsts patch has been submitted to avoid duplicated code [1], but it
  requires a bigger effort to add the tenant_id in requests used during
  UTs. Indeed, UT framework seems to bypass the controller. Thus, the
  tenant_id is not automatically added by the controller during UTs. The
  _get_tenant_id_for_create() was convenient for UTs, since it retrieves
  the tenant_id from the context, if it is not in the resource dict.

  [1]https://review.openstack.org/#/c/241984/

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


Follow ups