Post

Stop Harbor Replication from Flattening Native Repository Paths

Stop Harbor Replication from Flattening Native Repository Paths

Exported images arriving through Harbor replication were at risk of losing their nested source paths, so I changed the bootstrap to pin the destination namespace replace count and made CI prove that a drifted policy gets repaired rather than left alone.

Pinning the Harbor bootstrap replication policy to no-replace

desired_replication_policy in the Harbor bootstrap now sets the destination namespace replace count to its no-replace value alongside the rest of the rule definition. Harbor treats that field as the switch that controls whether incoming artifacts collapse into the destination root, so leaving it unset meant the policy depended on Harbor’s own defaults instead of on what the bootstrap intended. With the field declared explicitly, native imports keep their full homelab/chainguard/ repository paths when the Chainguard rule pulls them into the registry.

Turning a flatten assertion into a drift-repair test

The previous test only checked that the first filter entry did not carry flatten, which confirmed the shape of the request body but nothing about what Harbor stored. The test now asserts the destination namespace replace count is the no-replace value, then deliberately mutates the recorded policy, clears the call log, and re-runs reconcile_replication against the same fake client. It then compares the resulting write set against a single update to the policy endpoint identified by its existing ID. To make that comparison possible the fake client gained handling for policy updates keyed by identifier, so the test distinguishes an idempotent no-op from a corrective update.

Evidence scope and the next runtime check

Everything above is test-level evidence: the fake client and the assertions changed, not the cluster. Nothing in this push shows a live Harbor instance repairing a real policy, so the remaining check is a reconcile against the homelab registry that follows a deliberately drifted rule and confirms accepted artifacts still land under their original nested paths. The operations note in openwiki/operations/harbor-oci.md now records that bootstrap disables destination flattening for native imports, which gives that check a documented expectation to fail against. A platform team running a registry mirror in front of an upstream like Chainguard can copy the same pattern: declare the flattening behaviour explicitly in the reconciler and let CI prove it corrects drift rather than trusting vendor defaults.

This post is licensed under CC BY 4.0 by the author.