Fix fluentd multifile problem.

There is a problem on the current implementation.
Currently the new_source variable is an Array of hashes,
not a hash of hashes. The current impletation is wrong,
as it can be seen for the following error at the log gate:
http://logs.openstack.org/09/563009/7/check/tripleo-ci-centos-7-containers-multinode/aa4faf9/logs/undercloud/home/zuul/overcloud_deploy.log.txt.gz#_2018-09-03_15_17_39
[search for fluentd_service.pp] as there are too many lines at the same timestamp.

Error: Evaluation Error: Error while evaluating a Resource
Statement, Evaluation Error: Error while evaluating a Function
Call, comparison of Hash with Hash failed at
/etc/puppet/modules/fluentd/manifests/config.pp:6:16  at
/etc/puppet/modules/tripleo/manifests/profile/base/logging/fluentd/fluentd_service.pp:47
on node centos-7-rax-iad-0001722758.localdomain

(cherry picked from commit bfba3ad7ac)

Change-Id: If3c7043103c5b3c93fc5a684449498c7bbece1c3
This commit is contained in:
Juan Badia Payno 2018-09-11 18:18:12 +02:00
parent a6eaab1406
commit 0070ba9106
2 changed files with 31 additions and 2 deletions

View File

@ -38,10 +38,10 @@ define tripleo::profile::base::logging::fluentd::fluentd_service (
$values.filter|$index,$value|
{$index == 'path'}.reduce({})|$memo,$x| {$memo + {'path' => regsubst($x[1], $fluentd_transform[0], $fluentd_transform[1]) } } }
} else{
$new_source = {} + $all
$new_source = any2array($all)
}
} else {
$new_source = {} + $sources
$new_source = any2array($sources)
}
::fluentd::config { "100-openstack-${title}.conf":

View File

@ -223,6 +223,35 @@ describe 'tripleo::profile::base::logging::fluentd' do
end
context 'Multifiles -- horizon no transformation' do
let(:params) { {
:step => 4,
:fluentd_default_format => '/(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/',
:fluentd_manage_groups => false,
:fluentd_pos_file_path => '/var/cache/fluentd/',
:service_names => [ 'horizon' ],
} }
it { is_expected.to contain_file('/etc/fluentd/config.d/100-openstack-horizon.conf').with_content (
"# This file is managed by Puppet, do not edit manually.
<source>
format /(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/
path /var/log/horizon/test.log
pos_file /var/cache/fluentd/horizon-test.pos
tag openstack.horizon.test
@type tail
</source>
<source>
format /(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/
path /var/log/horizon/access.log
pos_file /var/cache/fluentd//openstack.horizon.access.pos
tag openstack.horizon.access
@type tail
</source>
"
) }
end
context 'Groups by service -- ceilometer_agent_central added ceilometer' do
let(:params) { {
:step => 4,