summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-07-13 11:40:03 +0000
committerGerrit Code Review <review@openstack.org>2018-07-13 11:40:03 +0000
commitbd5302f0ee917aaa354950ec26d96b79ef857395 (patch)
tree37279cd70d2507d9eec6b12ae2b54483a1b0b2ab
parent9f481aba248c92c91ffa945164e37a34bc0dbee6 (diff)
parent3a644f7764670b347d20caf680b35dfa0fdf2f03 (diff)
Merge "Add CI script to retrieve info from build logs"
-rwxr-xr-xtests/files/process_build_logs.py80
-rw-r--r--tests/playbooks/post.yml3
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/files/process_build_logs.py b/tests/files/process_build_logs.py
new file mode 100755
index 0000000..f2d6817
--- /dev/null
+++ b/tests/files/process_build_logs.py
@@ -0,0 +1,80 @@
1#!/usr/bin/python
2
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import argparse
16import collections
17import glob
18import os
19import re
20import sys
21
22parser = argparse.ArgumentParser(
23 description='Parse kolla build logs and extract useful information about '
24 'the installed packages.')
25parser.add_argument('-l', '--logdir',
26 help='Path to the build log files',
27 required=True)
28parser.add_argument('-b', '--base',
29 help='The kolla base_distro',
30 required=True)
31args = vars(parser.parse_args())
32
33if args['base'] not in ['centos', 'rhel', 'oraclelinux']:
34 print("Non rpm-based distros are not yet supported.")
35 sys.exit()
36
37obsolete = {}
38pkg_installs = collections.defaultdict(set)
39
40for filename in glob.glob(os.path.join(args['logdir'], '*.log')):
41 image = os.path.splitext(os.path.basename(filename))[0]
42 with open(filename) as f:
43 for line in f:
44 m = re.search(r"Package (.+) is obsoleted by (.+),", line)
45 if m:
46 if not m.group(1) in obsolete:
47 obsolete[m.group(1)] = {'obsoleted_by': m.group(2),
48 'images': [image]}
49 else:
50 obsolete[m.group(1)]['images'].append(image)
51
52 m = re.search(r"Package (.+)\..+ .+ will be installed", line)
53 if m:
54 pkg_installs[m.group(1)].add(image)
55
56 m = re.search(r"Processing Dependency: (.+)\(", line)
57 if m:
58 pkg_installs[m.group(1)].add(image)
59
60if obsolete:
61 print("Found %s obsolete(s) package(s):" % len(obsolete))
62 for pkg in obsolete:
63 print("%s is obsoleted by %s (%s)" %
64 (pkg,
65 obsolete[pkg]['obsoleted_by'],
66 ', '.join(obsolete[pkg]['images'])))
67 print('')
68
69move_to_base_candidates = [
70 pkg for pkg in pkg_installs if len(pkg_installs[pkg]) > 10
71 and not ('base' in pkg_installs[pkg]
72 or 'openstack-base' in pkg_installs[pkg])
73 ]
74
75if move_to_base_candidates:
76 print("Consider moving the following packages to a base image:")
77 for pkg in move_to_base_candidates:
78 print("%s (%s)" %
79 (pkg,
80 ', '.join(pkg_installs[pkg])))
diff --git a/tests/playbooks/post.yml b/tests/playbooks/post.yml
index 574917e..577b12b 100644
--- a/tests/playbooks/post.yml
+++ b/tests/playbooks/post.yml
@@ -55,6 +55,9 @@
55 # fix the permissions for logs folder 55 # fix the permissions for logs folder
56 sudo chmod -R 777 logs 56 sudo chmod -R 777 logs
57 57
58 # Parse build logs and extract pkg install info
59 tests/files/process_build_logs.py -l logs/build -b {{ base_distro }} > logs/packages-info.txt
60
58 # rename files to .txt; this is so that when displayed via 61 # rename files to .txt; this is so that when displayed via
59 # logs.openstack.org clicking results in the browser shows the 62 # logs.openstack.org clicking results in the browser shows the
60 # files, rather than trying to send it to another app or make you 63 # files, rather than trying to send it to another app or make you