From c9d085729f62dfcfeeaecccf36c3c0161414afb7 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Thu, 6 Sep 2018 10:35:38 +1200 Subject: [PATCH] Remove compare_host_packages strategy Now that the undercloud is containerized, there will be very few host packages to compare to, so there is a high risk that required package updates will be skipped. This is a strategy inherited from container-update.py that was intended to avoid unnecessary calls to yum update, however we now have a better approach using the repoquery, so host package comparison is no longer required, and probably causing some of the instances of bug Change-Id: Iab7b9d6377494001d904bb84b058ea293d73110c Partial-Bug: #1786764 --- README.md | 1 - defaults/main.yml | 1 - files/compare-package-json.py | 33 --------------------------------- files/yum_update.sh | 7 ------- tasks/yum_update.yml | 20 -------------------- templates/Dockerfile-yum.j2 | 5 ----- 6 files changed, 67 deletions(-) delete mode 100755 files/compare-package-json.py diff --git a/README.md b/README.md index 90f0cd5..8571321 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ A role to allow modification to container images built for the TripleO project. | `target_image` | `''` | See modify image variables | | `update_repo` | `''` | If set, packages from this repo will be updated. Other repos will only be used for dependencies of these updates.| | `yum_repos_dir_path` | `None` | Optional path of directory to be used as `/etc/yum.repos.d` during the update | -| `compare_host_packages` | `False` | If `True`, skip yum update when package versions match host package versions | | `container_build_tool` | `docker` | See modify image variables | ## Requirements ## diff --git a/defaults/main.yml b/defaults/main.yml index 99ca16e..805ad27 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,2 @@ -compare_host_packages: false update_repo: '' container_build_tool: 'docker' diff --git a/files/compare-package-json.py b/files/compare-package-json.py deleted file mode 100755 index b1b2731..0000000 --- a/files/compare-package-json.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# Copyright 2018 Red Hat, 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. - -import json -import subprocess -import sys - -host_packages = json.load(sys.stdin) -rpm_output = subprocess.check_output( - ['rpm', '-qa', '--qf', '%{NAME} %{VERSION}-%{RELEASE}\n']).split('\n') - -image_packages = dict(i.split(' ') for i in rpm_output if i) - -for pkg, version in image_packages.items(): - host_version = host_packages.get(pkg) - if host_version and version != host_version: - print('%s-%s does not match host version %s' % ( - pkg, version, host_version)) - sys.exit(1) - -print('No package version differences found') diff --git a/files/yum_update.sh b/files/yum_update.sh index 1ea99a1..f2ea8eb 100755 --- a/files/yum_update.sh +++ b/files/yum_update.sh @@ -2,13 +2,6 @@ set -eux -if [ -f /tmp/host_packages.json ]; then - if /tmp/compare-package-json.py < /tmp/host_packages.json ; then - echo "Host package versions match, no update required" - exit - fi -fi - packages_for_update= if [ -n "$1" ] && command -v repoquery >/dev/null 2>&1; then installed=$(rpm -qa --qf "%{NAME}\n" | sort) diff --git a/tasks/yum_update.yml b/tasks/yum_update.yml index 47a8c33..13e27b0 100644 --- a/tasks/yum_update.yml +++ b/tasks/yum_update.yml @@ -37,20 +37,6 @@ chdir: "{{ modify_dir_path }}" when: yum_repos_dir_path is defined - -- name: Generate host package json file - block: - - - command: | - rpm -qa --qf '"%{NAME}": "%{VERSION}-%{RELEASE}"\n' - register: rpm_query_output - - - copy: - content: "{{ rpm_query_output.stdout | from_yaml | to_nice_json }}" - dest: "{{ modify_dir_path }}/host_packages.json" - - when: compare_host_packages - - name: Write Dockerfile to {{ modify_dir_path }} template: src: Dockerfile-yum.j2 @@ -62,12 +48,6 @@ dest: "{{ modify_dir_path }}/yum_update.sh" mode: '0555' -- name: Write compare-package-json.py - copy: - src: compare-package-json.py - dest: "{{ modify_dir_path }}/compare-package-json.py" - mode: '0555' - - include_tasks: modify_image.yml - name: Clean modify directory diff --git a/templates/Dockerfile-yum.j2 b/templates/Dockerfile-yum.j2 index ca61564..a9b3b0f 100644 --- a/templates/Dockerfile-yum.j2 +++ b/templates/Dockerfile-yum.j2 @@ -4,7 +4,6 @@ LABEL modified_append_tag={{ modified_append_tag }} USER root COPY yum_update.sh /tmp/ -COPY compare-package-json.py /tmp/ {% if yum_repos_dir_path is defined %} RUN rm -rf /etc/yum.repos.d/ @@ -12,10 +11,6 @@ COPY yum.repos.d /etc/yum.repos.d COPY repos / {% endif %} -{% if compare_host_packages %} -COPY host_packages.json /tmp/ -{% endif %} - RUN /tmp/yum_update.sh "{{ update_repo }}" USER "{{ original_user }}"