From 76d637eef3df4b8671f513703098bf7614bb85fc Mon Sep 17 00:00:00 2001 From: rbikar <31000668+rbikar@users.noreply.github.com> Date: Wed, 22 Mar 2023 09:55:07 +0100 Subject: [PATCH] UD cache flush for Erratum in CVE fix task [RHELDST-16262] (#201) Added UD cache flush of Erratum object in CVE fix task. With this fix Erratum related to given CVE should be available on Customer portal pages without delay. --- CHANGELOG.md | 2 +- pubtools/_pulp/tasks/fix_cves.py | 2 +- tests/fix_cves/test_fix_cves.py | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d4064a1..31adbc2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- n/a +- Added UD cache flush of Erratum object in CVE fix task ## [1.22.0] - 2023-03-01 diff --git a/pubtools/_pulp/tasks/fix_cves.py b/pubtools/_pulp/tasks/fix_cves.py index 16505a72..c7359775 100644 --- a/pubtools/_pulp/tasks/fix_cves.py +++ b/pubtools/_pulp/tasks/fix_cves.py @@ -163,7 +163,7 @@ def run(self): self.upload_erratum(erratum, repos) # Publish repos - self.publish_with_cache_flush(repos) + self.publish_with_cache_flush(repos, errata=[erratum]) def entry_point(cls=FixCves): diff --git a/tests/fix_cves/test_fix_cves.py b/tests/fix_cves/test_fix_cves.py index 0db078c1..71110fd7 100644 --- a/tests/fix_cves/test_fix_cves.py +++ b/tests/fix_cves/test_fix_cves.py @@ -21,6 +21,7 @@ class FakeUdCache(object): def __init__(self): self.flushed_repos = [] self.flushed_products = [] + self.flushed_errata = [] def flush_repo(self, repo_id): self.flushed_repos.append(repo_id) @@ -30,6 +31,10 @@ def flush_product(self, product_id): self.flushed_products.append(product_id) return f_return() + def flush_erratum(self, erratum_id): + self.flushed_errata.append(erratum_id) + return f_return() + class FakeFastPurge(object): def __init__(self): @@ -199,6 +204,21 @@ def test_fix_cves_with_cache_cleanup(command_tester): ], ) + ud_client = fake_fix_cves.udcache_client + + assert ud_client.flushed_repos == ["all-rpm-content", "repo"] + assert ud_client.flushed_products == [] + assert ud_client.flushed_errata == ["RHSA-1234:56"] + + fastpurge_client = fake_fix_cves.fastpurge_client + + assert fastpurge_client.purged_urls == [ + "https://cdn.example.com/content/unit/1/all-rpm/mutable1", + "https://cdn.example.com/content/unit/1/all-rpm/mutable2", + "https://cdn.example.com/content/unit/1/client/mutable1", + "https://cdn.example.com/content/unit/1/client/mutable2", + ] + def test_no_erratum_found_error(command_tester): with FakeFixCves() as fake_fix_cves: