Created_At parameter returned in response for create segment and get segment APIs differ

Bug #1788883 reported by Pooja Jadhav
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
masakari
Fix Released
High
Tushar Patil

Bug Description

While writing functional tests in openstacksdk for masakari, raising mismatch error due to timestamp in created_at field. Created_at field does not store timestamp in DB but while getting any resources its appends 000000 as timestamp.

Steps to reproduce :

Created_at field while creating host :

curl -g -i -X POST http://10.232.48.206/instance-ha/v1/94b00ac2b4284ad8b04811e9a5c61733/segments/bcd7c815-2eb2-45eb-8310-51d97ccf4bc2/hosts -H "Content-Type: application/json" -H "User-Agent: masakari keystoneauth1/3.10.0 python-requests/2.19.1 CPython/2.7.12" -H "X-Auth-Token: gAAAAABbf8VLscSYP6Xwdg9nDd6nNP1stsR1mbN6mZuwhn0XRGyeEt2XuYQXsio1Ztd5Ikm9kL6EVPdzgHgboMVu15KXrs_M1-KqRzIE3lH9C1hSUjDMOvn2JXs3SLbNLZNdQFczCv-osTgOqNM4phj5OeOsCpDGAIbSGK_cCbEOZCqZqjUa6TY" -d '{"host": {"control_attributes": "test", "type": "COMPUTE", "name": "h2"}}'
HTTP/1.1 201 Created
Date: Fri, 24 Aug 2018 08:44:44 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 613
Content-Type: application/json
OpenStack-API-Version: masakari 1.0
Vary: OpenStack-API-Version
x-openstack-request-id: req-51c6aa21-8b12-416e-b058-c05d56e95de5
Connection: close

{"host": {"reserved": false, "uuid": "ffef6d6f-cd33-47a3-b210-245e8a4436ef", "deleted": false, "on_maintenance": false, "created_at": "2018-08-24T08:44:44.184175", "control_attributes": "test", "updated_at": null, "name": "h2", "failover_segment": {"uuid": "bcd7c815-2eb2-45eb-8310-51d97ccf4bc2", "deleted": false, "created_at": "2018-08-24T06:49:30.000000", "description": null, "recovery_method": "auto", "updated_at": null, "service_type": "test", "deleted_at": null, "id": 319, "name": "test1"}, "deleted_at": null, "type": "COMPUTE", "id": 187, "failover_segment_id": "bcd7c815-2eb2-45eb-8310-51d97ccf4bc2"}}

Created_at field while getting the host which is created above :

curl -g -i -X GET http://10.232.48.206/instance-ha/v1/94b00ac2b4284ad8b04811e9a5c61733/segments/bcd7c815-2eb2-45eb-8310-51d97ccf4bc2/hosts/ffef6d6f-cd33-47a3-b210-245e8a4436ef -H "User-Agent: masakari keystoneauth1/3.10.0 python-requests/2.19.1 CPython/2.7.12" -H "X-Auth-Token: gAAAAABbf8VLscSYP6Xwdg9nDd6nNP1stsR1mbN6mZuwhn0XRGyeEt2XuYQXsio1Ztd5Ikm9kL6EVPdzgHgboMVu15KXrs_M1-KqRzIE3lH9C1hSUjDMOvn2JXs3SLbNLZNdQFczCv-osTgOqNM4phj5OeOsCpDGAIbSGK_cCbEOZCqZqjUa6TY"
HTTP/1.1 200 OK
Date: Fri, 24 Aug 2018 08:45:26 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 613
Content-Type: application/json
OpenStack-API-Version: masakari 1.0
Vary: OpenStack-API-Version
x-openstack-request-id: req-68f58a63-91fd-41ac-9707-15ab9e0d56da
Connection: close

{"host": {"reserved": false, "uuid": "ffef6d6f-cd33-47a3-b210-245e8a4436ef", "deleted": false, "on_maintenance": false, "created_at": "2018-08-24T08:44:44.000000", "control_attributes": "test", "updated_at": null, "name": "h2", "failover_segment": {"uuid": "bcd7c815-2eb2-45eb-8310-51d97ccf4bc2", "deleted": false, "created_at": "2018-08-24T06:49:30.000000", "description": null, "recovery_method": "auto", "updated_at": null, "service_type": "test", "deleted_at": null, "id": 319, "name": "test1"}, "deleted_at": null, "type": "COMPUTE", "id": 187, "failover_segment_id": "bcd7c815-2eb2-45eb-8310-51d97ccf4bc2"}}

Actual result :

created_at field during POST call is : 2018-08-24T08:44:44.184175
created_at field during GET call is : 2018-08-24T08:44:44.000000

Here miliseconds are differ, issue is for SEGMENT as well as for HOST.

Expected result :

created_at field during POST call is : 2018-08-24T08:44:44
created_at field during GET call is : 2018-08-24T08:44:44

Not expecting milliseconds since DB is not storing the same.

Changed in masakari:
assignee: nobody → Pooja Jadhav (poojajadhav)
Tushar Patil (tpatil)
summary: - Timestamp (miliseconds) in created_at field raising issue while
- asserting objects in functional tests
+ Created_At parameter returned in response for create segment and get
+ segment APIs differ
Tushar Patil (tpatil)
Changed in masakari:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to masakari (master)

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

Changed in masakari:
assignee: Pooja Jadhav (poojajadhav) → Tushar Patil (tpatil)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to masakari (master)

Reviewed: https://review.openstack.org/616068
Committed: https://git.openstack.org/cgit/openstack/masakari/commit/?id=0f8b8c938a6c334ff95d12399f152a25f52f69cc
Submitter: Zuul
Branch: master

commit 0f8b8c938a6c334ff95d12399f152a25f52f69cc
Author: tpatil <email address hidden>
Date: Wed Nov 7 13:31:12 2018 +0900

    Fix datetime microsecond discrepancy issue

    All ``POST/PUT`` restFul APIs which returns datetime parameters in the
    response contains microseconds whereas `GET` APIs ignores microseconds
    part. After a db object is created, it creates the datetime with
    microseconds and the subsequent get db calls using the same session
    object returns microseconds for the datetime fields.

    This patch fixes this issue by overriding `TimestampMixin` to exclude
    microseconds part from the datetime fields so that the subsequence get
    db calls using the same db session object return datetime fields without
    microseconds.

    Change-Id: Iff6367757c7c2832bf0c99e09f9c7a97c428d1cc
    Closes-Bug: #1788883

Changed in masakari:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/masakari 7.0.0.0b1

This issue was fixed in the openstack/masakari 7.0.0.0b1 development milestone.

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.