Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache: skip non-kickstart treeinfo [RHELDST-24308] #710

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion exodus_gw/worker/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
LOG = logging.getLogger("exodus-gw")


def exclude_path(path: str) -> bool:
# Returns True for certain paths which should be excluded from cache flushing.
if path.endswith("/treeinfo") and not path.endswith("/kickstart/treeinfo"):
# RHELDST-24308: paths matching these conditions get a forced 404 response
# without going to the CDN origin. This has the side-effect of breaking
# cache flushing for those paths - if we request flush for these paths
# we'll get an error.
LOG.debug("Skipping %s: treeinfo fast-404 case", path)
return True
return False


class Flusher:
def __init__(
self,
Expand All @@ -26,7 +38,7 @@ def __init__(
env: str,
aliases: list[tuple[str, str]],
):
self.paths = paths
self.paths = [p for p in paths if not exclude_path(p)]
self.settings = settings
self.aliases = aliases

Expand Down
8 changes: 8 additions & 0 deletions tests/worker/test_cdn_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ def test_flush_cdn_cache_typical(
# - different TTL values for different types of file
# - leading "/" vs no leading "/" - both should be tolerated
# - alias resolution
# - treeinfo special case
"/path/one/repodata/repomd.xml",
"path/two/listing",
"third/path",
"/some/misc/treeinfo",
"/some/kickstart/treeinfo",
],
env="cachetest",
settings=settings,
Expand Down Expand Up @@ -242,11 +245,14 @@ def test_flush_cdn_cache_typical(
# after alias resolution are flushed.
"S/=/123/4567/10m/cdn1.example.com/path/two-dest/listing cid=///",
"S/=/123/4567/10m/cdn1.example.com/path/two/listing cid=///",
# note only the kickstart treeinfo appears, the other is filtered.
"S/=/123/4567/30d/cdn1.example.com/some/kickstart/treeinfo cid=///",
"S/=/123/4567/30d/cdn1.example.com/third/path cid=///",
"S/=/123/4567/4h/cdn1.example.com/path/one-dest/repodata/repomd.xml cid=///",
"S/=/123/4567/4h/cdn1.example.com/path/one/repodata/repomd.xml cid=///",
"S/=/234/6677/10m/cdn2.example.com/other/path/two-dest/listing x/y/z",
"S/=/234/6677/10m/cdn2.example.com/other/path/two/listing x/y/z",
"S/=/234/6677/30d/cdn2.example.com/other/some/kickstart/treeinfo x/y/z",
"S/=/234/6677/30d/cdn2.example.com/other/third/path x/y/z",
"S/=/234/6677/4h/cdn2.example.com/other/path/one-dest/repodata/repomd.xml x/y/z",
"S/=/234/6677/4h/cdn2.example.com/other/path/one/repodata/repomd.xml x/y/z",
Expand All @@ -255,11 +261,13 @@ def test_flush_cdn_cache_typical(
"https://cdn1.example.com/path/one/repodata/repomd.xml",
"https://cdn1.example.com/path/two-dest/listing",
"https://cdn1.example.com/path/two/listing",
"https://cdn1.example.com/some/kickstart/treeinfo",
"https://cdn1.example.com/third/path",
# Used the CDN URL which had a leading path.
"https://cdn2.example.com/root/path/one-dest/repodata/repomd.xml",
"https://cdn2.example.com/root/path/one/repodata/repomd.xml",
"https://cdn2.example.com/root/path/two-dest/listing",
"https://cdn2.example.com/root/path/two/listing",
"https://cdn2.example.com/root/some/kickstart/treeinfo",
"https://cdn2.example.com/root/third/path",
]