Importing neutron.common.config module registers config options

Bug #1968606 reported by Jakub Libosvar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Jakub Libosvar

Bug Description

In case neutron.common.config is imported some config options are registered as a side effect without calling any function. This is causing errors for projects that import also other modules that end up importing neutron.common.config - such as neutorn.db.models_v2. If a project needs Neutron basic DB models and uses same config options then there is no way how to make it work. Performing any action on imports is an anti-pattern in Python.

Changed in neutron:
assignee: nobody → Jakub Libosvar (libosvar)
Changed in neutron:
status: New → In Progress
Changed in neutron:
importance: Undecided → Medium
Revision history for this message
Jakub Libosvar (libosvar) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/837392
Committed: https://opendev.org/openstack/neutron/commit/4d3a274765a364f6f7b6bff163d6f7110bdbdbbe
Submitter: "Zuul (22348)"
Branch: master

commit 4d3a274765a364f6f7b6bff163d6f7110bdbdbbe
Author: Jakub Libosvar <email address hidden>
Date: Mon Apr 11 21:45:49 2022 +0000

    Don't register config options on imports

    Importing some modules lead to registering config options that may
    collide with config options from a project that calls the import. This
    patch wraps the side effect that registers config options into a
    function that needs to be called in case the caller wants to register
    the options.

    This solution is also not perfect as it guards the common options to be
    registered only once even if the function is called multiple times. This
    is to solve problems in unittests, ideally we should always call the
    function just once even in our testing suites.

    Resolves-Bug: #1968606
    Change-Id: Ic1532eb8de887ff1b1085206df11f53e22f7f524
    Signed-off-by: Jakub Libosvar <email address hidden>

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron-dynamic-routing (master)

Reviewed: https://review.opendev.org/c/openstack/neutron-dynamic-routing/+/838780
Committed: https://opendev.org/openstack/neutron-dynamic-routing/commit/180396b18c6f011d69bd3b2d4bea2549ab5e3038
Submitter: "Zuul (22348)"
Branch: master

commit 180396b18c6f011d69bd3b2d4bea2549ab5e3038
Author: silvacarloss <email address hidden>
Date: Wed Apr 20 16:32:01 2022 -0300

    Register common config options by default

    The [1] change modified the behavior Neutron had, which used to
    force the default config options to be automatically set.

    Neutron-dynamic-routing expects some of the default config options
    to be set while initializing some services. If they are not set
    the initialization will fail [2].

    This change invokes the method that sets such config options to
    fix this initialization issue.

    [1] https://review.opendev.org/c/openstack/neutron/+/837392
    [2] https://paste.opendev.org/show/b8DReLeBPl9xTGooN8wu/

    Releated-Bug: #1968606
    Change-Id: Ib3bdf9b19feb68647460814cc973699622d0a6e8

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/neutron/+/842068

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (master)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/842068
Committed: https://opendev.org/openstack/neutron/commit/44c03ca8e10a11f13583ba924868b4f331d3072a
Submitter: "Zuul (22348)"
Branch: master

commit 44c03ca8e10a11f13583ba924868b4f331d3072a
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu May 12 18:05:20 2022 +0000

    Register common config options in ``MechDriverSetupBase``

    When manually testing any ``MechDriverSetupBase`` child testing class,
    the following error is shown:
      oslo_config.cfg.NoSuchOptError: no such option service_plugins in
      group [DEFAULT]

    To avoid this, this patch registers the common config options during the
    ``MechDriverSetupBase`` setup method. The
    ``register_common_config_options`` will not register the options if are
    alredy registered.

    Related-Bug: #1968606
    Change-Id: Ie324b8489e2826a9f82fc9b45ee9684a680c6a8b

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to neutron (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/neutron/+/843461

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to neutron (master)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/843461
Committed: https://opendev.org/openstack/neutron/commit/384ff4485ff0111c801e442168c518b2b5211c91
Submitter: "Zuul (22348)"
Branch: master

commit 384ff4485ff0111c801e442168c518b2b5211c91
Author: yatinkarel <email address hidden>
Date: Thu May 26 18:46:25 2022 +0530

    [UT][ovn] Access config options after they are registered

    It is a follow up of [1]. There were still some tests
    which were accessing config optons before they were registered
    and failing when tested manually just those tests, this
    patch fixes it.

    [1] https://review.opendev.org/c/openstack/neutron/+/842068

    Related-Bug: #1968606
    Change-Id: I9aec0ba1f5c723e6f5a9146e9af41707e8014db2

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers