Horizon is not generating CSS correctly

Bug #1423783 reported by Bjoern
26
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
Juno
Fix Released
Low
Steve Lewis
Trunk
Fix Released
Low
Evan Callicoat

Bug Description

Horizon is not generating CSS correctly when it runs in a load balanced environment.

We need to configure the following settings to do it right :

COMPRESS_OFFLINE = True
COMPRESS_CSS_HASHING_METHOD = 'content'

and then run the compress:

sudo -u www-data horizon-manage.py collectstatic
sudo -u www-data horizon-manage.py compress

I have this problem pretty often in a 10.x deployment and here the log of an issue. After I did configure the local_settings.py with the settings above, the problem went away consistently

# ansible horizon_container -m shell -a 'service apache2 restart'
infra01_horizon_container-46069b23 | success | rc=0 >>
 * Restarting web server apache2
   ...done.

infra02_horizon_container-2e3a02dd | success | rc=0 >>
 * Restarting web server apache2
   ...done.

infra03_horizon_container-7d46d7f7 | success | rc=0 >>
 * Restarting web server apache2
   ...done.

# ansible horizon_container -m shell -a 'curl -k https://localhost |grep screen'
infra01_horizon_container-46069b23 | success | rc=0 >>
<link rel="stylesheet" href="/static/dashboard/css/0e35198fb8e0.css" type="text/css" media="screen" /> % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 1920 0 1920 0 0 48605 0 --:--:-- --:--:-- --:--:-- 49230

infra03_horizon_container-7d46d7f7 | success | rc=0 >>
<link rel="stylesheet" href="/static/dashboard/css/0e35198fb8e0.css" type="text/css" media="screen" /> % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 1920 0 1920 0 0 50517 0 --:--:-- --:--:-- --:--:-- 51891

infra02_horizon_container-2e3a02dd | success | rc=0 >>
<link rel="stylesheet" href="/static/dashboard/css/0e35198fb8e0.css" type="text/css" media="screen" /> % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 1920 0 1920 0 0 51111 0 --:--:-- --:--:-- --:--:-- 51891

# https://localhost/static/dashboard/css/6c6ddb7aa3b5.css/static/dashboard/css/0e35198fb8e0.css |head'
infra03_horizon_container-7d46d7f7 | success | rc=0 >>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /static/dashboard/css/0e35198fb8e0.css was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 443</address>
</body></html> % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 310 100 310 0 0 33659 0 --:--:-- --:--:-- --:--:-- 34444

infra02_horizon_container-2e3a02dd | success | rc=0 >>
.btn {
  display: inline-block;
  margin-bottom: 0;
  font-weight: normal;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  background-image: none;
  border: 1px solid transparent;
  white-space: nowrap; % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
  6 1178k 6 81920 0 0 4551k 0 --:--:-- --:--:-- --:--:-- 4705k
curl: (23) Failed writing body (4096 != 16384)

infra01_horizon_container-46069b23 | success | rc=0 >>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /static/dashboard/css/0e35198fb8e0.css was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 443</address>
</body></html> % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 310 100 310 0 0 34148 0 --:--:-- --:--:-- --:--:-- 38750

Revision history for this message
Kevin Carter (kevin-carter) wrote :

@Bjoern Teipel couple of questions:

is the deployment on 10.1.[1-2rc1]?
Have you seen this on other deployments IE Icehouse?
Do you have a way to consistently reproduce this issue?

Thanks for all the data you've already provided. Im looking into this now, but if you have anything else it would be much appreciated.

summary: - Horizion is not generating CSS correctly
+ Horizon is not generating CSS correctly
description: updated
Revision history for this message
Bjoern (bjoern-t) wrote :

is the deployment on 10.1.[1-2rc1]?
- Yes it was a 10.1.2rc1 deployment and I had it on all of them sofar

is the deployment on 10.1.[1-2rc1]?
- I did not see this, this bad on Icehouse

is the deployment on 10.1.[1-2rc1]?
- It happened to me on every fresh 10.1.2x deployment, so somewhat reproducible

Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

FYI: this is a duplicate of https://bugs.launchpad.net/openstack-ansible/+bug/1402890 which also has another duplicate - I won't mark it formally as a duplicate yet so that further investigation can be done within this bug.

os-ansible-deployment currently uses django-compressor v1.4, and in v1.4 and later the value of 'hash' and 'content' are treated equally as per:
https://github.com/django-compressor/django-compressor/blob/1.4/compressor/filters/css_default.py#L71

Also confirmed is that the horizon playbook does the apache setup role last, and the final task in that role is to restart apache - so apache is most definitely restarted after horizon is appropriately configured.

Changed in openstack-ansible:
assignee: nobody → Evan Callicoat (apsu-2)
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to os-ansible-deployment (master)

Reviewed: https://review.openstack.org/163183
Committed: https://git.openstack.org/cgit/stackforge/os-ansible-deployment/commit/?id=e6a9bc34ac76fced9c3faa3652691c16aa63d735
Submitter: Jenkins
Branch: master

commit e6a9bc34ac76fced9c3faa3652691c16aa63d735
Author: Evan Callicoat <email address hidden>
Date: Tue Mar 10 16:00:05 2015 -0500

    Enable offline compression for resource files

    The default value for OFFLINE_COMPRESS is False, as per the Django
    compressor docs. When using offline compression, it seems that different
    request contexts may generate different CSS files with different names
    by way of the SCSS generator. When the HTML is returned to the browser,
    the CSS filename referenced will only exist on the node that received
    the initial request and generated the CSS file locally, however in a
    load-balanced scenario with multiple Horizon instances, the actual HTTP
    request for the CSS file has a n-1/n chance of hitting another node that
    may be lacking that file, resulting in an unstyled page.

    Changing the OFFLINE_COMPRESS value to True enables Django to use the
    pre-generated list of resources -- created via the manage.py compress
    command -- which is stored in a manifest.json file and should be the
    same name/content across the instances since it's not varying by request
    context like during online compression.

    Change-Id: Iccb9b8cd30b7a61435f9ccc813c4032a24cbe52a
    Closes-Bug: #1423783

Changed in openstack-ansible:
status: New → Fix Committed
tags: added: juno-backport-potential
no longer affects: openstack-ansible
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.