Fix the failure of ceilometer-api container

* ceilometer-api script is removed and run ceilometer-api by using apache
* fix connection url in ceilometer.conf

Closes-Bug: #1624905
Change-Id: Iffb00ca418bab6521d61b16de4f5760aa1ae1ac7
This commit is contained in:
Jeffrey Zhang 2016-09-19 02:44:27 +08:00 committed by Jeffrey Zhang
parent 898d438051
commit 7555054e72
9 changed files with 116 additions and 13 deletions

View File

@ -7,7 +7,10 @@ project_name: "ceilometer"
####################
ceilometer_database_name: "ceilometer"
ceilometer_database_user: "ceilometer"
ceilometer_database_address: "{% for host in groups['mongodb'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mongodb_port }}{% if not loop.last %},{% endif %}{% endfor %}"
ceilometer_database_address_mappings:
mongodb: "{% for host in groups['mongodb'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ mongodb_port }}{% if not loop.last %},{% endif %}{% endfor %}"
mysql: "{{ kolla_internal_fqdn }}:{{ database_port }}"
ceilometer_database_address: "{{ ceilometer_database_address_mappings[ceilometer_database_type] }}"
####################

View File

@ -49,3 +49,6 @@
- ceilometer_database_type == "mysql"
- include: bootstrap_service.yml
when:
- ceilometer_database_type == "mysql"
- database.created

View File

@ -22,6 +22,15 @@
- "ceilometer-central"
- "ceilometer-compute"
- name: Copying over ceilometer-api.conf
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/ceilometer-api/wsgi-ceilometer-api.conf"
with_first_found:
- "{{ node_custom_config }}/ceilometer/{{ inventory_hostname }}/wsgi-ceilometer-api.conf"
- "{{ node_custom_config }}/ceilometer/wsgi-ceilometer-api.conf"
- "wsgi-ceilometer-api.conf.j2"
- name: Copying over ceilometer.conf
merge_configs:
vars:

View File

@ -1,11 +1,20 @@
{% set apache_cmd = 'apache2' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd' %}
{% set apache_dir = 'apache2/conf-enabled' if kolla_base_distro in ['ubuntu', 'debian'] else 'httpd/conf.d' %}
{% set apache_file = '000-default.conf' if kolla_base_distro in ['ubuntu', 'debian'] else 'ceilometer-api.conf' %}
{
"command": "ceilometer-api",
"command": "/usr/sbin/{{ apache_cmd }} -DFOREGROUND",
"config_files": [
{
"source": "{{ container_config_directory }}/ceilometer.conf",
"dest": "/etc/ceilometer/ceilometer.conf",
"owner": "ceilometer",
"perm": "0600"
},
{
"source": "{{ container_config_directory }}/wsgi-ceilometer-api.conf",
"dest": "/etc/{{ apache_dir }}/{{ apache_file }}",
"owner": "ceilometer",
"perm": "0644"
}
]
}

View File

@ -13,9 +13,11 @@ host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['addr
[database]
{% if ceilometer_database_type == "mongodb" %}
connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
event_connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
metering_connection = mongodb://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
{% elif ceilometer_database_type == "mysql" %}
connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
event_connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
metering_connection = mysql+pymysql://{{ ceilometer_database_user }}:{{ ceilometer_database_password }}@{{ ceilometer_database_address }}/{{ ceilometer_database_name }}
{% endif %}
[keystone_authtoken]

View File

@ -0,0 +1,24 @@
{% set python_path = '/usr/lib/python2.7/site-packages' if kolla_install_type == 'binary' else '/var/lib/kolla/venv/lib/python2.7/site-packages' %}
Listen {{ api_interface_address }}:{{ ceilometer_api_port }}
<VirtualHost *:{{ ceilometer_api_port }}>
LogLevel info
ErrorLog /var/log/kolla/ceilometer/ceilometer-api.log
CustomLog /var/log/kolla/ceilometer/ceilometer-api-access.log combined
WSGIScriptReloading On
WSGIDaemonProcess ceilometer-api processes=5 threads=1 user=ceilometer group=ceilometer display-name=%{GROUP} python-path={{ python_path }}
WSGIProcessGroup ceilometer-api
WSGIScriptAlias / {{ python_path }}/ceilometer/api/app.wsgi
<Directory "{{ python_path }}/ceilometer/api">
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
</VirtualHost>

View File

@ -7,13 +7,55 @@ MAINTAINER {{ maintainer }}
{% if install_type == 'binary' %}
{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %}
{% set ceilometer_api_packages = ['openstack-ceilometer-api'] %}
{% set ceilometer_api_packages = [
'openstack-ceilometer-api',
'httpd',
'mod_wsgi'
] %}
{{ macros.install_packages(ceilometer_api_packages | customizable("packages")) }}
RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf
{% elif base_distro in ['ubuntu'] %}
{% set ceilometer_api_packages = ['ceilometer-api'] %}
{% set ceilometer_api_packages = [
'ceilometer-api',
'apache2',
'libapache2-mod-wsgi'
] %}
{{ macros.install_packages(ceilometer_api_packages | customizable("packages")) }}
RUN echo > /etc/apache2/ports.conf
{% endif %}
{% elif install_type == 'source' %}
{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %}
{% set ceilometer_api_packages = [
'httpd',
'mod_wsgi',
'gettext'
] %}
{{ macros.install_packages(ceilometer_api_packages | customizable("packages")) }}
{% block ceilometer_api_redhat_source_setup %}
RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf
{% endblock %}
{% elif base_distro in ['ubuntu', 'debian'] %}
{% set ceilometer_api_packages = [
'apache2',
'libapache2-mod-wsgi',
'gettext'
] %}
{{ macros.install_packages(ceilometer_api_packages | customizable("packages")) }}
{% block ceilometer_api_ubuntu_source_setup %}
RUN echo > /etc/apache2/ports.conf
{% endblock %}
{% endif %}
{% endif %}
COPY extend_start.sh /usr/local/bin/kolla_ceilometer_extend_start
@ -22,5 +64,3 @@ RUN chmod 755 /usr/local/bin/kolla_ceilometer_extend_start
{% block ceilometer_api_footer %}{% endblock %}
{% block footer %}{% endblock %}
{{ include_footer }}
USER ceilometer

View File

@ -3,7 +3,15 @@
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
ceilometer-dbsync
sudo -H -u ceilometer ceilometer-upgrade --skip-gnocchi-resource-types
sudo chown -R ceilometer: /var/lib/ceilometer/
exit 0
fi
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi

View File

@ -1,10 +1,15 @@
#!/bin/bash
if [[ ! -d "/var/log/kolla/ceilometer" ]]; then
mkdir -p /var/log/kolla/ceilometer
CEILOMETER_LOG_DIR=/var/log/kolla/ceilometer
if [[ ! -d "${CEILOMETER_LOG_DIR}" ]]; then
mkdir -p "${CEILOMETER_LOG_DIR}"
fi
if [[ $(stat -c %a /var/log/kolla/ceilometer) != "755" ]]; then
chmod 755 /var/log/kolla/ceilometer
if [[ $(stat -c %U:%G "${CEILOMETER_LOG_DIR}") != "ceilometer:kolla" ]]; then
chown ceilometer:kolla "${CEILOMETER_LOG_DIR}"
fi
if [[ $(stat -c %a "${CEILOMETER_LOG_DIR}") != "755" ]]; then
chmod 755 "${CEILOMETER_LOG_DIR}"
fi
. /usr/local/bin/kolla_ceilometer_extend_start