skip to content

In Harbor, QA labels an image as approved, but an event-based replication rule filtered on that label never pushes it to production; why?

level: seniorimportance: nice to knowfreq 25%

answer

  1. what counts as an event
  2. push, retag, delete
  3. the filter was checked at push time
  4. a label change triggers nothing
  5. make promotion itself an event

basics

~20 s

Harbor's event-based replication fires only on pushing, retagging and deleting artifacts; changing a label triggers nothing. The image was pushed before it had the label, so the filter excluded it then, and labelling it later never re-ran the rule.

solid answer

~40 s

Harbor documents that you can filter replication by label, but changing a label on an artifact does not trigger replication: event-based rules react only to push, retag and delete. At push time the image had no `approved` label, so the filter skipped it, and the later label change produced no event. Fix it by making promotion an event or the rule periodic: copy the approved artifact into a release project whose event-based rule replicates it (a copy counts as a retag), or switch the rule to a scheduled or manual trigger, knowing those triggers do not replicate deletions. Do not carry this limitation to Artifactory, whose event replication does treat a property change as an event.

go deeper

for a junior

Recall that a replication rule has filters and a trigger, and that a filter only matters when the trigger makes the rule run.

for a middle

Explain Harbor's three trigger modes, which events the event-based mode reacts to, and why a label change is not one of them.

for a senior

Diagnose the stall from the rule's execution history and the artifact's state at push time, then fix it by making promotion an event or scheduling the rule.

for a principal

Decide whether metadata should move artifacts between sites at all, given that each product defines replication events differently and labels are weakly guarded.

## The setup **Harbor** is an open-source registry that organises images into **projects** and can **replicate** artifacts to another registry. A **replication rule** has a mode (push-based or pull-based), **source resource filters**, a destination and a **trigger mode**. One of the filters is **Label**: replicate only artifacts carrying a given label, or excluding it. **Labels** are global (managed by system administrators) or project-level, and the **Developer** role and above can attach them to images. The team built a label-based promotion: CI pushes into a staging project, QA adds an `approved` label, and an event-based replication rule filtered on that label should push approved images to the production registry. ## Why nothing arrives Harbor's documentation covers this exactly: you can filter replication on labels, but **changing a label on an artifact does not trigger replication**; **event-based replication is limited to pushing, retagging and deleting artifacts**. So: 1. CI pushed the image. That is an event, and the rule evaluated it. 2. The image had no `approved` label yet, so the label filter excluded it. 3. QA added the label later. That is not a replication event, so the rule never evaluated the image again. The filter worked as configured; the trigger never fired at the moment the filter would have passed. ## Trigger modes and what each means for promotion | Trigger | When it runs | Replicates deletions | Fit for label-based promotion | |---|---|---|---| | Manual | when someone or a job starts it | no | yes, if the promotion job starts it after labelling | | Scheduled | on a cron schedule | no | yes, with a delay up to the schedule interval | | Event Based | on push, retag or delete | only with "Delete remote resources when locally deleted" | no, a label change is not an event | ## Fixes - **Make the promotion an event.** Instead of labelling in place, copy the approved artifact into a `release` project and point an event-based rule at that project. Harbor's copy creates the artifact under a new repository and tag, which is a retag, and retagging is one of the events that triggers replication. - **Use a scheduled trigger** with the label filter. Each run evaluates the filter against current labels, so newly approved images replicate on the next run. The cost is latency, and deletions are not replicated in this mode. - **Trigger the rule manually from the promotion job** right after the label is set. The run evaluates the filter at that moment. - **Check the destination's own rules.** The rule's **Override** option forces replicated resources to replace same-named ones at the destination, but if the production registry is Harbor with a tag immutability rule, an immutable tag there cannot be altered by replication. Whichever fix you choose, remember that a label is a weak gate: anyone with Developer can set it, so the label alone should not be the only thing standing between a candidate and production. ## Do not generalise it to other products This is Harbor's behaviour, not a law of replication. **Artifactory** replication has an **Enable Event Replication** setting under which each event triggers replication of the artifacts it changed, and its documentation lists property change among those events. Its scheduled replication can also **Sync Artifact Properties**. So a property-based promotion that replicates promptly in Artifactory can silently stall when the same design is copied to Harbor labels. Check each product's own definition of an event before relying on metadata to move artifacts between sites. ## How to debug a stalled replication in general - List the rule's executions and see whether any ran after the change you expected to trigger it. - Compare the artifact's state at the time of the last execution with the rule's filters (name, tag, label, resource type). - Confirm the change you made is one the trigger mode reacts to. - Check whether the destination refused the write, for example because an immutable tag already exists there. - Only then look at the network, credentials or the destination's availability. A useful habit when a promotion depends on replication is to make the promotion job verify arrival: after triggering or waiting for the rule, it resolves the promoted digest from the destination registry and fails loudly if it is missing, instead of assuming the rule did its work.

  • If you switch the rule to a scheduled trigger, what new gap appears?
    Deletions stop replicating. Harbor notes that manual and scheduled triggers do not replicate delete operations, so an artifact removed from staging or release stays in the production registry until someone removes it there or an event-based rule with remote deletion enabled handles it.
  • Would the same label-based design stall in Artifactory?
    Not for the same reason. With Enable Event Replication set, Artifactory treats a property change on an artifact as an event and replicates it. The design ports in spirit, but you must check the target product's own event definition rather than assume either behaviour.

  • Adding a label in Harbor triggers event-based replication immediately.
  • The label filter is re-checked whenever the artifact's labels change.
  • Scheduled replication in Harbor also replicates deletions.
  • Every repository manager treats metadata changes as replication events.
  • A label-filtered rule that never fires must have a network problem.