Legacy Images Dashboard's "Create Image" form fields are in random order in python 3 with HORIZON_IMAGES_UPLOAD_MODE = 'direct'

Bug #1835724 reported by Yves-Gwenael Bourhis
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Undecided
Yves-Gwenael Bourhis

Bug Description

Some users still need the legacy images panel( `ANGULAR_FEATURES['images_panel'] = False` ) because of the category tabs.

When using this panel, if the server runs in python 3 the field orders are at a fixed random order
(see screenshot in attachment).
What I mean by "fixed" random order is that the order changes when restarting the server (but the order stays the same after each refresh).

This issue happens only with Python 3. The order is correct in Python 2

Revision history for this message
Yves-Gwenael Bourhis (yves-gwenael-bourhis) wrote :
summary: - Legacy Images "Create Image" form fields are in random order in python
- 3K
+ Legacy Images "Create Image" form fields are in random order in python 3
description: updated
summary: - Legacy Images "Create Image" form fields are in random order in python 3
+ Legacy Images Dashboard "Create Image" form fields are in random order
+ in python 3
summary: - Legacy Images Dashboard "Create Image" form fields are in random order
+ Legacy Images Dashboard's "Create Image" form fields are in random order
in python 3
Revision history for this message
Akihiro Motoki (amotoki) wrote : Re: Legacy Images Dashboard's "Create Image" form fields are in random order in python 3

I deployed horizon with libapache2-mod-wsgi-py3 package on Ubuntu 18.04. I tried five apache2 restart but I saw the fields of "Create Image" in the same order defined in the source code....

Revision history for this message
Yves-Gwenael Bourhis (yves-gwenael-bourhis) wrote :

I have the issue even without apache2, even with `python manage.py runserver`.
So apache will not be responsible for this (even though I reproduce it with apache).
Have you tried with the development server? because sometimes by luck the fields are in the correct order and apache is not a requirement to reproduce the issue.

Revision history for this message
Akihiro Motoki (amotoki) wrote :

The only reason I mentioned libapache2-mod-wsgi-py3 package is to mention I use python3 but it is not reproduced in my env. I will try runserver env when I have time to test it. Input from others would be really appreacited.

Revision history for this message
Yves-Gwenael Bourhis (yves-gwenael-bourhis) wrote :

I have more info, the issue reproduces ONLY with this setting:

    HORIZON_IMAGES_UPLOAD_MODE = 'direct'

Revision history for this message
Yves-Gwenael Bourhis (yves-gwenael-bourhis) wrote :

So to sum up, to reproduce the issue we need:

python 3

in local_settings.py:

    ANGULAR_FEATURES['images_panel'] = False
    HORIZON_IMAGES_UPLOAD_MODE = 'direct'

The issue does not reproduce with python 2.

apache is not required to reproduce the issue (the issue is reproducible with the test server) :

   python manage.py runserver

Or if you have `DEBUG = False` and want tu use the test server:

   python manage.py runserver --insecure

But the issue reproduces well also with apache.

summary: Legacy Images Dashboard's "Create Image" form fields are in random order
- in python 3
+ in python 3 with HORIZON_IMAGES_UPLOAD_MODE = 'direct'
Changed in horizon:
assignee: nobody → Yves-Gwenael Bourhis (yves-gwenael-bourhis)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.opendev.org/670517

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

Reviewed: https://review.opendev.org/670517
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=9c30ca9c13f59267c1045d9faaca1eac1259fd41
Submitter: Zuul
Branch: master

commit 9c30ca9c13f59267c1045d9faaca1eac1259fd41
Author: Yves-Gwenael Bourhis <email address hidden>
Date: Fri Jul 12 14:37:44 2019 +0200

    Preserve form field order in python 3

    In python 3, the ExternalUploadMeta metaclass does not preserve the
    order of the fields of the class it is modifying.
    First we add a __prepare__() method which returns an empty
    collections.OrderedDict.
    That mapping records the methods and attributes of the class it is
    metaclassing as they are defined within the body of the class statement.
    Then we send a collections.OrderedDict to create the new class.

    Change-Id: I7223ae5bd931202c95602ec9674ae86b4708368d
    Closes-Bug: #1835724

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

This issue was fixed in the openstack/horizon 16.0.0.0b2 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.