Skip to content

Commit 1f08ceb

Browse files
gerrod3dralley
authored andcommitted
Fix numerous flatpak issues
https://redhat.atlassian.net/browse/PULP-1633 - Fix flatpak index cache serialization on pulpcore>=3.85 - Add domain prefix to flatpak index Name field via get_full_path - Fix FlatpakIndexStaticCache key to include host, preventing cross-domain cache collisions - Fix OS/architecture filters being silently dropped in recurse_through_manifest_lists - Make test_flatpak_install domain-aware using the full_path fixture - Fix host generation in index response when CONTENT_ORIGIN=None - Fix CI TLS setup to use cp cert to the anchor location so flatpak/OSTree trusts the Pulp CA Made-with: Cursor
1 parent 343b4cc commit 1f08ceb

9 files changed

Lines changed: 31 additions & 20 deletions

File tree

.github/workflows/scripts/post_before_script.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ SCENARIOS=("pulp" "performance" "azure" "gcp" "s3" "generate-bindings" "lowerbou
22
if [[ " ${SCENARIOS[*]} " =~ " ${TEST} " ]]; then
33
# Needed by pulp_container/tests/functional/api/test_flatpak.py:
44
cmd_prefix dnf install -yq dbus-daemon flatpak
5-
fi
65

7-
# This allows flatpak to trust Pulp, but currently it breaks the trust for bindings
8-
# TODO: Figure out another command to fix this
9-
# add the copied certificates from install.sh to the container's trusted certificates list
10-
# if [[ "$TEST" = "azure" ]]; then
11-
# cmd_prefix trust anchor /etc/pki/tls/cert.pem
12-
# else
13-
# cmd_prefix trust anchor /etc/pulp/certs/pulp_webserver.crt
14-
# fi
6+
# DO NOT CALL update-ca-trust, it will break the bindings TLS
7+
# This copy is for the flatpak tests, flatpak uses pk11-kit which checks the source anchors
8+
# to build the trust chain, it doesn't actually use the output of update-ca-trust
9+
cmd_prefix cp /etc/pulp/certs/pulp_webserver.crt /etc/pki/ca-trust/source/anchors/pulp_webserver.crt
10+
fi

CHANGES/+flatpak-cache-key.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a cache key collision in the flatpak static index that could serve incorrect results across domains.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed flatpak index response to include the domain prefix in image names when domains are enabled.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a serialization issue with the FlatpakIndex cache.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed OS and architecture filters being silently ignored when filtering manifest lists in the flatpak index.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the registry host in the flatpak index response when `CONTENT_ORIGIN=None`.

pulp_container/app/cache.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ def find_base_path_cached(request, cached):
9797

9898
class FlatpakIndexStaticCache(SyncContentCache):
9999
def __init__(self, expires_ttl=None, auth=None):
100-
updated_keys = (QUERY_KEY,)
100+
updated_keys = (CacheKeys.host, QUERY_KEY)
101101
super().__init__(
102102
base_key="/index/static", expires_ttl=expires_ttl, keys=updated_keys, auth=auth
103103
)
104104

105105
def make_key(self, request):
106-
"""Make a key composed of the request's query."""
106+
"""Make a key composed of the request's host and query."""
107107
all_keys = {
108+
CacheKeys.host: request.get_host(),
108109
QUERY_KEY: request.query_params.urlencode(),
109110
}
110111
key = ":".join(all_keys[k] for k in self.keys)

pulp_container/app/registry_api.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,9 @@ def recurse_through_manifest_lists(self, tag, manifest, oss, architectures, mani
593593
elif manifest.media_type in (models.MEDIA_TYPE.MANIFEST_LIST, models.MEDIA_TYPE.INDEX_OCI):
594594
mlms = manifest.listed_manifests.through.objects.filter(image_manifest__pk=manifest.pk)
595595
if oss:
596-
mlms.filter(os__in=oss)
596+
mlms = mlms.filter(os__in=oss)
597597
if architectures:
598-
mlms.filter(architecture__in=architectures)
598+
mlms = mlms.filter(architecture__in=architectures)
599599
for mlm in mlms:
600600
self.recurse_through_manifest_lists(
601601
tag, mlm.manifest_list, oss, architectures, manifests
@@ -705,7 +705,7 @@ def get(self, request):
705705
continue
706706
images.append(
707707
{
708-
"Tags": tagged,
708+
"Tags": list(tagged),
709709
"Digest": manifest.digest,
710710
"MediaType": manifest.media_type,
711711
"OS": os,
@@ -714,9 +714,14 @@ def get(self, request):
714714
}
715715
)
716716
if images:
717-
results.append({"Name": distribution.base_path, "Images": images})
717+
results.append(
718+
{
719+
"Name": get_full_path(distribution.base_path, distribution.pulp_domain),
720+
"Images": images,
721+
}
722+
)
718723

719-
host = settings.CONTENT_ORIGIN or request.get_host()
724+
host = settings.CONTENT_ORIGIN or request.build_absolute_uri("/")
720725
return Response(data={"Registry": host, "Results": results})
721726

722727

pulp_container/tests/functional/api/test_flatpak.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
from pulp_container.tests.functional.constants import REGISTRY_V2
88

9-
pytestmark = pytest.mark.skip(reason="TLS is broken currently. TODO: Fix")
10-
119

1210
def run_flatpak_commands(host):
1311
# Install flatpak:
@@ -16,6 +14,7 @@ def run_flatpak_commands(host):
1614
"flatpak",
1715
"--user",
1816
"remote-add",
17+
"--if-not-exists",
1918
"pulptest",
2019
"oci+" + host,
2120
]
@@ -67,16 +66,21 @@ def test_flatpak_install(
6766
container_manifest_api,
6867
pulp_settings,
6968
bindings_cfg,
69+
full_path,
7070
):
7171
if not pulp_settings.FLATPAK_INDEX:
7272
pytest.skip("This test requires FLATPAK_INDEX to be enabled")
7373

7474
image_path1 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.busyboxplatform:latest"
7575
registry_client.pull(image_path1)
76-
local_registry.tag_and_push(image_path1, "pulptest/oci-net.fishsoup.busyboxplatform:latest")
76+
local_registry.tag_and_push(
77+
image_path1, full_path("pulptest/oci-net.fishsoup.busyboxplatform") + ":latest"
78+
)
7779
image_path2 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.hello:latest"
7880
registry_client.pull(image_path2)
79-
local_registry.tag_and_push(image_path2, "pulptest/oci-net.fishsoup.hello:latest")
81+
local_registry.tag_and_push(
82+
image_path2, full_path("pulptest/oci-net.fishsoup.hello") + ":latest"
83+
)
8084
namespace = container_namespace_api.list(name="pulptest").results[0]
8185
add_to_cleanup(container_namespace_api, namespace.pulp_href)
8286

0 commit comments

Comments
 (0)