TypeError: __init__() got an unexpected keyword argument 'project' in Designate

Bug #1721432 reported by Ben Nemec on 2017-10-05
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Designate
Undecided
Ben Nemec
congress
Critical
Unassigned
masakari
Undecided
Shilpa Devharakar
oslo.context
Critical
Ben Nemec

Bug Description

It looks like the addition of 'project' to the to_dict function of the Context class[1] has broken Designate. The problem is that this adds a key to to_dict that isn't accepted by the constructor, and as a result Designate's simple from_dict[2] function fails with an unexpected keyword argument. An example of the error can be seen in [3].

Since oslo.context provides a from_dict function that seems to handle this correctly already, I think the correct thing to do here is just to remove the Designate override. That at least is getting it working for me locally.

1: https://github.com/openstack/oslo.context/commit/936ce1aa54a1034f6c09e2baa588c96416322265#diff-558db8448ff9ee3a533c0425329b6665
2: https://github.com/openstack/designate/blob/46de766e513cfb97cbfc50b001734e02711517e4/designate/context.py#L96
3: http://logs.openstack.org/14/506614/32/check/gate-designate-python27-ubuntu-xenial/2d01a4f/console.html#_2017-10-05_01_05_47_771985

Ben Nemec (bnemec) on 2017-10-05
Changed in designate:
assignee: nobody → Ben Nemec (bnemec)
summary: - Renamed parameters broke designate
+ TypeError: __init__() got an unexpected keyword argument 'project' in
+ Designate

Fix proposed to branch: master
Review: https://review.openstack.org/509685

Changed in designate:
status: New → In Progress
Ben Nemec (bnemec) wrote :

Hmm, removing from_dict got me past the issue I was having locally, but it seems to have broken some of the unit tests. Will have to look deeper.

Eric K (ekcs) on 2017-10-05
Changed in congress:
status: New → Confirmed
importance: Undecided → Critical

Change abandoned by Ben Nemec (<email address hidden>) on branch: master
Review: https://review.openstack.org/509685
Reason: It turns out multiple projects were relying on this behavior, so let's just fix it in oslo.context. See https://review.openstack.org/#/c/509919

Changed in oslo.context:
status: New → In Progress
Ben Nemec (bnemec) wrote :

Not sure why it didn't link the new patch, but here it is: https://review.openstack.org/#/c/509919/

Changed in oslo.context:
importance: Undecided → Critical
Changed in oslo.context:
assignee: Ben Nemec (bnemec) → Juan Antonio Osorio Robles (juan-osorio-robles)

Reviewed: https://review.openstack.org/511026
Committed: https://git.openstack.org/cgit/openstack/oslo.context/commit/?id=e75f4c5ad91962e272d65daa770e00f70f931ecb
Submitter: Zuul
Branch: master

commit e75f4c5ad91962e272d65daa770e00f70f931ecb
Author: Ben Nemec <email address hidden>
Date: Tue Oct 10 20:40:34 2017 +0000

    Make from_dict extensible

    Some of our consumers define additional members on the context class
    that they want included in to_dict and from_dict. While it is
    possible to do this today via overrides of those functions, the
    from_dict implementation in particular is a little non-obvious.
    This has led to bugs when the base class's to_dict behavior changes.

    This change moves the logic around extending the keys recognized by
    from_dict into from_dict itself and allows consumers to simply
    provide a list of those keys by overriding a class member.

    Change-Id: Ib143f8a5c129dbf6711800c4d87c8830a8aa3365
    Related-Bug: 1721432

Change abandoned by Ben Nemec (<email address hidden>) on branch: master
Review: https://review.openstack.org/509919
Reason: Quite right.

Reviewed: https://review.openstack.org/510917
Committed: https://git.openstack.org/cgit/openstack/designate/commit/?id=ef4cc46769e4ba31895a1cda8dc09a10aa6c764f
Submitter: Zuul
Branch: master

commit ef4cc46769e4ba31895a1cda8dc09a10aa6c764f
Author: Ben Nemec <email address hidden>
Date: Tue Oct 10 15:45:50 2017 +0000

    Call base from_dict in DesignateContext

    This changes the from_dict override to call the base class
    implementation with the Designate-specific keys passed as kwargs.
    It should prevent issues where a new key is added to the base to_dict
    function that is not an accepted parameter on the constructor.

    Change-Id: If75b26bf5a95ae1be679d43a939621037311d2dc
    Closes-Bug: 1721432

Changed in designate:
status: In Progress → Fix Released

Fix proposed to branch: master
Review: https://review.openstack.org/513500

Changed in masakari:
assignee: nobody → Ben Nemec (bnemec)
status: New → In Progress

This issue was fixed in the openstack/designate 6.0.0.0b1 development milestone.

Reviewed: https://review.openstack.org/510981
Committed: https://git.openstack.org/cgit/openstack/congress/commit/?id=b40fcbecf4745298d29387bc54a8a9ff72925b6e
Submitter: Zuul
Branch: master

commit b40fcbecf4745298d29387bc54a8a9ff72925b6e
Author: Ben Nemec <email address hidden>
Date: Tue Oct 10 17:33:39 2017 +0000

    Call base from_dict in RequestContext

    This changes the from_dict override to call the base class
    implementation with the Congress-specific keys passed as kwargs.
    It should prevent issues where a new key is added to the base to_dict
    function that is not an accepted parameter on the constructor.

    Change-Id: I271111f1fe2ba0d4350e94f672abd327ac8eeb7a
    Closes-Bug: 1721432

Changed in congress:
status: Confirmed → Fix Released

This issue was fixed in the openstack/congress 7.0.0.0b2 development milestone.

Changed in oslo.context:
status: In Progress → Fix Released
assignee: Juan Antonio Osorio Robles (juan-osorio-robles) → Ben Nemec (bnemec)
Changed in masakari:
assignee: Ben Nemec (bnemec) → Shilpa Devharakar (shilpasd)

Change abandoned by Ben Nemec (<email address hidden>) on branch: master
Review: https://review.openstack.org/513500
Reason: I rebased the followup patch so it no longer depends on this one. It obsoletes this change anyway.

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

Other bug subscribers