Skip to content

Commit 6f3fd8a

Browse files
committed
Fix flatpak domain compatibility and CI TLS setup
- 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 CI TLS setup to use cp + update-ca-trust extract so flatpak/OSTree trusts the Pulp CA Made-with: Cursor
1 parent e10a31a commit 6f3fd8a

7 files changed

Lines changed: 22 additions & 16 deletions

File tree

.github/workflows/scripts/post_before_script.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ 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+
# Add the Pulp CA cert to the system trust store inside the container so that
7+
# flatpak/OSTree (which uses GLib/GIO) trusts the Pulp registry's TLS certificate.
8+
# Using cp + update-ca-trust extract (the standard RHEL9 approach) rather than
9+
# "trust anchor", which behaved unexpectedly when given the full CA bundle path.
10+
cmd_prefix bash -c "cp /etc/pulp/certs/pulp_webserver.crt /etc/pki/ca-trust/source/anchors/ && update-ca-trust extract"
11+
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 OS and architecture filters being silently ignored when filtering manifest lists in the flatpak index.

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,9 @@ def recurse_through_manifest_lists(self, tag, manifest, oss, architectures, mani
596596
elif manifest.media_type in (models.MEDIA_TYPE.MANIFEST_LIST, models.MEDIA_TYPE.INDEX_OCI):
597597
mlms = manifest.listed_manifests.through.objects.filter(image_manifest__pk=manifest.pk)
598598
if oss:
599-
mlms.filter(os__in=oss)
599+
mlms = mlms.filter(os__in=oss)
600600
if architectures:
601-
mlms.filter(architecture__in=architectures)
601+
mlms = mlms.filter(architecture__in=architectures)
602602
for mlm in mlms:
603603
self.recurse_through_manifest_lists(
604604
tag, mlm.manifest_list, oss, architectures, manifests
@@ -717,7 +717,7 @@ def get(self, request):
717717
}
718718
)
719719
if images:
720-
results.append({"Name": distribution.base_path, "Images": images})
720+
results.append({"Name": get_full_path(distribution.base_path, distribution.pulp_domain), "Images": images})
721721

722722
host = settings.CONTENT_ORIGIN or request.get_host()
723723
return Response(data={"Registry": host, "Results": results})

pulp_container/tests/functional/api/test_flatpak.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,21 @@ def test_flatpak_install(
6464
container_manifest_api,
6565
pulp_settings,
6666
bindings_cfg,
67+
full_path,
6768
):
6869
if not pulp_settings.FLATPAK_INDEX:
6970
pytest.skip("This test requires FLATPAK_INDEX to be enabled")
7071

7172
image_path1 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.busyboxplatform:latest"
7273
registry_client.pull(image_path1)
73-
local_registry.tag_and_push(image_path1, "pulptest/oci-net.fishsoup.busyboxplatform:latest")
74+
local_registry.tag_and_push(
75+
image_path1, full_path("pulptest/oci-net.fishsoup.busyboxplatform") + ":latest"
76+
)
7477
image_path2 = f"{REGISTRY_V2}/pulp/oci-net.fishsoup.hello:latest"
7578
registry_client.pull(image_path2)
76-
local_registry.tag_and_push(image_path2, "pulptest/oci-net.fishsoup.hello:latest")
79+
local_registry.tag_and_push(
80+
image_path2, full_path("pulptest/oci-net.fishsoup.hello") + ":latest"
81+
)
7782
namespace = container_namespace_api.list(name="pulptest").results[0]
7883
add_to_cleanup(container_namespace_api, namespace.pulp_href)
7984

0 commit comments

Comments
 (0)