Javascript error: Module 'horizon.auth' is not available!

Bug #1494171 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
High
Eric Peterson

Bug Description

When trying Horizon from Liberty b3, I can login into Horizon, but then I get the below error all the time in the JS console of Iceweasel:

Error: [$injector:modulerr] Failed to instantiate module horizon.app due to:
[$injector:modulerr] Failed to instantiate module horizon.auth due to:
[$injector:nomod] Module 'horizon.auth' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.3.17/$injector/nomod?p0=horizon.auth
minErr/<@http://sid.gplhost.com/static/dashboard/js/2d60d97176f3.js:691:8
module/<@http://sid.gplhost.com/static/dashboard/js/2d60d97176f3.js:796:1
ensure@http://sid.gplhost.com/static/dashboard/js/2d60d97176f3.js:794:320
module@http://sid.gplhost.com/static/dashboard/js/2d60d97176f3.js:796:1
loadModules/<@http://sid.gplhost.com/static/dashboard/js/2d60d97176f3.js:895:35
forEach@http://sid.gplhost.com/static/dashboard/js/2d60d97176f3.js:697:391
loadModules@http://sid.gplhost.com/static/dashboard/js/2d60d97176f3.js:894:63
loadModules/<@http://sid.gplhost.com/static/dashboa

Then I can't click on the top left or top right "admin" drop-down button. Note that the above console dump is complete, and I haven't truncated it myself, maybe Iceweasel does (I'm not sure who truncates it...).

Matthias Runge (mrunge)
Changed in horizon:
importance: Undecided → High
milestone: none → liberty-rc1
Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :

Some part of the packaging is incorrect I think, and it's failing to find the angular modules, causing the JS to error (which in turn is breaking the dropdown menus). I can't reproduce this :/

Revision history for this message
Timur Sufiev (tsufiev-x) wrote :

That's the downside of neglecting the aid of 'collectstatic' :).

Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

collectstatic does a copy of all static files, which is *not* what one wants to do in a distributions.

What angular module is it missing? How can I trace it? It may be a packaging issue then...

Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :
Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :

That should be covered by the MANIFEST recursive-include on horizon with .js files.

Matthias Runge (mrunge)
Changed in horizon:
status: New → Confirmed
Revision history for this message
Alan Pevec (apevec) wrote :

MANIFEST.in does have recursive-include horizon *.html *.scss *.js *.csv *.template *.tmpl *.mo *.po
so is that not working?

Revision history for this message
Matthias Runge (mrunge) wrote :

Thesame report has been made against delorean packages.
The comment there was:
I've narrowed part of it down. Its related to not having a horizon/ directory in the file structure.
The following patch makes it get closer to working, but not 100% yet

--- /usr/share/openstack-dashboard/openstack_dashboard/static_settings.py.orig 2015-09-15 19:29:40.941775339 +0000
+++ /usr/share/openstack-dashboard/openstack_dashboard/static_settings.py 2015-09-15 19:56:13.714211497 +0000
@@ -144,7 +144,7 @@
     # leading "/"
     file_discovery.populate_horizon_config(
         HORIZON_CONFIG,
- os.path.join(ROOT_PATH, '..', 'horizon', 'static/')
+ os.path.join(ROOT_PATH, '..', 'static/')
     )

     # filter out non-angular javascript code and lib

After patching, the compressed js files seems to have the right bits compiled in, but for some reason, the second javascript file isn't being loaded into the website, causing horizon.app not to be loadable.

Revision history for this message
Matthias Runge (mrunge) wrote :

looks like auto_discovery is to blame?

bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1263761

Revision history for this message
Kevin Fox (kevpn) wrote :

At least for the RDO version, I think its a difference between how RDO packages it and how it is in GIT.

In GIT, the code looks starts at horizon/openstack-dashboard and then backs up to horizon/horizon/static and looks for js files there. That is correct code for git.

RDO lays out their files in a different way, it puts the files rooted at /usr/share/openstack-dashboard
with static directly under it, so the patch fixes the issue in RDO, but would break the GIT version.

 So I think either it needs to be patched in the distro's, or else it needs a new setting specifying where they reside needs to be added to git, which then is set in a patch in the distro's.

Revision history for this message
Kevin Fox (kevpn) wrote :

As for the other part of problem, the script compressed by:
https://github.com/openstack/horizon/blob/master/openstack_dashboard/templates/horizon/_scripts.html

isn't being included by https://github.com/openstack/horizon/blob/master/openstack_dashboard/templates/base.html.
The generated html looks like:

    <div id="footer">

    </div>

    <div id="modal_wrapper"></div>
  </body>

There should be a script tag between the footer and modal_wrapper. Not sure why yet.

Revision history for this message
Kevin Fox (kevpn) wrote :

Ok. We've narrowed it down further. _scripts.html is not getting loaded by base.html. Looks like because of a parse error. If i remove these three lines:
{% for file in HORIZON_CONFIG.js_files %}
    <script src='{{ STATIC_URL }}{{ file }}'></script>
{% endfor %}

The content then show up in the html page ok. Though it doesn't work since its missing code now.

Something about HORIZON_CONFIG.js_files is broken when run in the apache environment but not within the compress side, since its properly generating the compressed file.

Very strange.

Revision history for this message
Thai Tran (tqtran) wrote :

I have a feeling it could be related to auto-discovery searching the file system and failing at some point. As Eric suggested, maybe put import openstack_dashboard; find_static_files(openstack_dashboard.__path__[0], HORIZON_CONFIG) line and see what the paths are. Would also be good to do a print out of the STATIC_URL and files path.

Revision history for this message
Kevin Fox (kevpn) wrote :
Download full text (9.8 KiB)

For both compress and the base.html cases, the following fields from HORIZON_CONFIG are identical:
['angular_modules', 'js_files', 'js_spec_files', 'external_templates']

js_files is:

['app/app.module.js', 'app/core/cloud-services/cloud-services.module.js', 'app/core/core.module.js', 'app/core/images/images.module.js', 'app/core/metadata/metadata.module.js', 'app/core/metadata/modal/modal.module.js', 'app/core/openstack-service-api/openstack-service-api.module.js', 'app/core/workflow/workflow.module.js', 'app/tech-debt/tech-debt.module.js', 'auth/auth.module.js', 'auth/login/login.module.js', 'dashboard/identity/identity.module.js', 'dashboard/identity/projects/projects.module.js', 'dashboard/identity/users/users.module.js', 'dashboard/project/images/images.module.js', 'dashboard/project/project.module.js', 'dashboard/project/workflow/launch-instance/launch-instance.module.js', 'dashboard/project/workflow/workflow.module.js', 'framework/framework.module.js', 'framework/util/bind-scope/bind-scope.module.js', 'framework/util/filters/filters.module.js', 'framework/util/promise-toggle/promise-toggle.module.js', 'framework/util/tech-debt/tech-debt.module.js', 'framework/util/util.module.js', 'framework/util/validators/validators.module.js', 'framework/widgets/action-list/action-list.module.js', 'framework/widgets/charts/charts.module.js', 'framework/widgets/headers/headers.module.js', 'framework/widgets/help-panel/help-panel.module.js', 'framework/widgets/magic-search/magic-search.module.js', 'framework/widgets/metadata/display/display.module.js', 'framework/widgets/metadata/metadata.module.js', 'framework/widgets/metadata/tree/tree.module.js', 'framework/widgets/modal-wait-spinner/modal-wait-spinner.module.js', 'framework/widgets/modal/modal.module.js', 'framework/widgets/table/table.module.js', 'framework/widgets/toast/toast.module.js', 'framework/widgets/transfer-table/transfer-table.module.js', 'framework/widgets/widgets.module.js', 'framework/widgets/wizard/wizard.module.js', 'app/core/cloud-services/hz-if-nova-extensions.directive.js', 'app/core/cloud-services/hz-if-services.directive.js', 'app/core/cloud-services/hz-if-settings.directive.js', 'app/core/images/filters/image-status.filter.js', 'app/core/images/filters/image-type.filter.js', 'app/core/images/table/images-table.controller.js', 'app/core/metadata/metadata.service.js', 'app/core/metadata/modal/modal-helper.controller.js', 'app/core/metadata/modal/modal.controller.js', 'app/core/metadata/modal/modal.service.js', 'app/core/openstack-service-api/cinder.service.js', 'app/core/openstack-service-api/glance.service.js', 'app/core/openstack-service-api/heat.service.js', 'app/core/openstack-service-api/keystone.service.js', 'app/core/openstack-service-api/neutron.service.js', 'app/core/openstack-service-api/nova-extensions.service.js', 'app/core/openstack-service-api/nova.service.js', 'app/core/openstack-service-api/policy.service.js', 'app/core/openstack-service-api/security-group.service.js', 'app/core/openstack-service-api/service-catalog.service.js', 'app/core/openstack-service-api/settings.service.js', 'app/core/openstack-service-api/user-session.service.js', 'app/core/workflow/dec...

Changed in horizon:
assignee: nobody → Eric Peterson (ericpeterson-l)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/224328
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=515374d43148864fbdb27f9e26dac6679c0d93ed
Submitter: Jenkins
Branch: master

commit 515374d43148864fbdb27f9e26dac6679c0d93ed
Author: eric <email address hidden>
Date: Wed Sep 16 16:19:07 2015 -0600

    Improving find static robustness

    The find static utility method assumes a filesystem layout
    that may or may not be present on certain distros. This fixes
    this by using the python install path.

    Closes-bug: #1494171

    Change-Id: Iab72b4b872849d2496cc634677e5bfe478aa03be

Changed in horizon:
status: In Progress → Fix Committed
Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

After applying this patch, I still have the same issue. :(

Could someone give me a clue about where the auth.module.js should be installed, relative to the webroot, or next to what file? Because it doesn't seem available at all in /usr/share/openstack-dashboard for me.

Changed in horizon:
status: Fix Committed → Confirmed
Revision history for this message
Eric Peterson (ericpeterson-l) wrote :

Thomas Goirand - Please let me know if you are still seeing this. There are a few ways in which this problem might still "seem" to be there.

You will want to rerun collect static, and the compress commands from django. In addition, you will want to make sure your browser cache is cleared before testing this.

If you still have this, please look for ducttape_ on irc and maybe we can try to work through this some more. (US timezone for me)

Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

Hi! Thanks everyone. Using the above patch, plus doing lots of clean-ups of the remaining things from Wheezy (which was using /usr/share/pyshared instead of /usr/lib/python2.7/dist-packages), it's looking like I've fixed my problem.

Thanks again to everyone who helped.

Changed in horizon:
status: Confirmed → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: liberty-rc1 → 8.0.0
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.