Comment 6 for bug 1529084

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.messaging (master)

Reviewed: https://review.opendev.org/683600
Committed: https://git.openstack.org/cgit/openstack/oslo.messaging/commit/?id=d8980bfed8621eadce36c6a56944ca23245187a6
Submitter: Zuul
Branch: master

commit d8980bfed8621eadce36c6a56944ca23245187a6
Author: Balazs Gibizer <email address hidden>
Date: Fri Sep 20 19:33:27 2019 +0200

    Align message serialization between drivers

    Every in tree driver that implements RPC send uses jsonutils.dumps to
    serialize the message, except FakeDriver. FakeDriver uses json.dumps.
    However json.dumps is a lot more strict than jsonutils. This caused
    nova to introduce test specific changes in the rpc handling [1].

    This patch makes sure that each driver uses the same json serialization.

    I've tried to dig in to the history of the strictness of the
    FakeDriver. That driver with the json.dumps() call was added back in
    2013 with e2b74cc9e6605156dfd6e36cdfd1b5136161d526. (I cannot link to
    that commit in any online way but it is in my local git clone.)
    Checking out that commit I don't see any other drivers present in the
    repo but the code does mention drivers like RabbitDriver and ZmqDriver
    in oslo.messaging/openstack/common/messaging/drivers.py but only there.

    Today the oslo_messaging._drivers.common.serialize_msg() call is used
    to do the final serialization of the message. It uses jsonutils.dumps
    since Icd54ee8e3f5c976dfd50b4b62c7f51288649e112 which is a revert of
    I0e0f6b715ffc4a9ad82be52e55696d032b6d0976 that changed from
    jsonutils.dumps to jsonutils.dump_as_bytes by mistake. And before this
    back and forth it was jsonutils.dumps since the code was imported from
    oslo-incubator by I38507382b1ce68c7f8f697522f9a1bf00e76532d. Here
    I lost the trail. Honestly I don't know the reason why the fake driver
    was made stricter than the real drivers. Still I think today the
    strictness is unnecessary as every driver uses jsonutils and even
    counterproductive as in [1].

    [1] https://github.com/openstack/nova/blob/09bf71407f4c0d1ddbef89c489ec87c3bca0b7b2/nova/compute/rpcapi.py#L820

    Change-Id: I186305b7897a2a4ce033c11ab9e6bc028854381b
    Closes-Bug: #1529084