Fix zaqar container

This PS is part of a rework on zaqar container.
In it's current state is not working in kolla.
Will be adding/fixing issues under this PS.

- Remove bootstrap zaqar:
  At this point zaqar-manage command does not exist.
  Boostraping is not needed while starting zaqar container.

- Add pymongo package in source install.

- Create /var/log/kolla folder.

- Change zaqar homedir to /var/lib/zaqar and unify creation.

- Zaqar's source default have config files as *.sample.
  Policy.json need to be present if keystone auth
  is going to be used.

- Zaqar uses wsgi to the API, heka decoder need to be added

Change-Id: I9c6716b64345d9e846902ffbfbf033135e3eabd9
Closes-Bug: #1647831
This commit is contained in:
Eduardo Gonzalez 2016-12-06 19:51:11 +00:00
parent 1ad6f4a761
commit 69e2e9fff1
3 changed files with 82 additions and 11 deletions

View File

@ -0,0 +1,72 @@
-- Copyright 2015 Mirantis, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
local l = require 'lpeg'
l.locale(l)
local common_log_format = require 'common_log_format'
local patt = require 'os_patterns'
local utils = require 'os_utils'
local msg = {
Timestamp = nil,
Type = 'log',
Hostname = nil,
Payload = nil,
Pid = nil,
Fields = nil,
Severity = 6,
}
local severity_label = utils.severity_to_label_map[msg.Severity]
local apache_log_pattern = read_config("apache_log_pattern") or error(
"apache_log_pattern configuration must be specificed")
local apache_grammar = common_log_format.build_apache_grammar(apache_log_pattern)
local request_grammar = l.Ct(patt.http_request)
function process_message ()
-- logger is either "zaqar-apache-public" or "zaqar-apache-admin"
local logger = read_message("Logger")
local log = read_message("Payload")
local m
m = apache_grammar:match(log)
if m then
msg.Logger = 'openstack.zaqar'
msg.Payload = log
msg.Timestamp = m.time
msg.Fields = {}
msg.Fields.http_status = m.status
msg.Fields.http_response_time = m.request_time.value / 1e6 -- us to sec
msg.Fields.programname = logger
msg.Fields.severity_label = severity_label
local request = m.request
m = request_grammar:match(request)
if m then
msg.Fields.http_method = m.http_method
msg.Fields.http_url = m.http_url
msg.Fields.http_version = m.http_version
end
return utils.safe_inject_message(msg)
end
return -1, string.format("Failed to parse %s log: %s", logger, string.sub(log, 1, 64))
end

11
docker/zaqar/Dockerfile.j2 Normal file → Executable file
View File

@ -18,14 +18,14 @@ MAINTAINER {{ maintainer }}
{{ macros.install_packages(zaqar_packages | customizable("packages")) }}
{% elif install_type == 'source' %}
ADD zaqar-archive /zaqar-source
RUN ln -s zaqar-source/* zaqar \
&& useradd --user-group zaqar \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /zaqar \
&& mkdir -p /etc/zaqar /var/log/zaqar /home/zaqar \
&& useradd --user-group --create-home --home-dir /var/lib/zaqar zaqar \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt pymongo /zaqar \
&& mkdir -p /etc/zaqar \
&& cp -r /zaqar/etc/* /etc/zaqar/ \
&& chown -R zaqar: /etc/zaqar /var/log/zaqar /home/zaqar
&& mv /etc/zaqar/policy.json.sample /etc/zaqar/policy.json \
&& chown -R zaqar: /etc/zaqar
{% endif %}
@ -35,6 +35,5 @@ RUN chmod 755 /usr/local/bin/kolla_extend_start \
{% block zaqar_footer %}{% endblock %}
{% block footer %}{% endblock %}
{{ include_footer }}
USER zaqar

10
docker/zaqar/extend_start.sh Normal file → Executable file
View File

@ -1,8 +1,8 @@
#!/bin/bash
# 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
zaqar zaqar-manage db_sync
exit 0
if [[ ! -d "/var/log/kolla/zaqar" ]]; then
mkdir -p /var/log/kolla/zaqar
fi
if [[ $(stat -c %a /var/log/kolla/zaqar) != "755" ]]; then
chmod 755 /var/log/kolla/zaqar
fi