fix: task ID of image blobs for dragonfly's issue #4418 #1495
+170
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Calculate task ID based on blob SHA256 for registry downloads
Description
This PR implements a feature to calculate task IDs based on the blob's SHA256 digest for OCI registry blob downloads, rather than using the full download URL. This allows identical blobs from different registry domains to share the same task ID, avoiding redundant downloads and storage.
Key Changes:
Configuration Addition (
dragonfly-client-config/src/dfdaemon.rs):enable_blob_based_task_idfield toRegistryMirrorconfigurationtrueas specified in the issueCore Implementation (
dragonfly-client/src/proxy/mod.rs):extract_blob_digest_from_url()function to detect and extract SHA256 digest from registry blob URLs (format:/v2/<name>/blobs/sha256:<digest>)make_download_task_request()to use blob digest for task ID calculation when the feature is enabledX-Dragonfly-Content-For-Calculating-Task-IDheader (highest priority)enable_blob_based_task_idis true)Testing:
extract_blob_digest_from_url()functionExample:
Before this change:
https://registry1.io/v2/nginx/blobs/sha256:abc123...→ Task ID 1https://registry2.io/v2/nginx/blobs/sha256:abc123...→ Task ID 2 (duplicate download)After this change:
sha256:abc123...)Related Issue
Closes dragonflyoss/dragonfly#4418
Motivation and Context
When pulling container images, different registry mirrors (e.g., Docker Hub, Harbor, custom registries) may serve the same image blobs with identical content but different URLs. Currently, Dragonfly computes task IDs based on the download URL, which leads to:
This change solves the problem by:
The feature is enabled by default but can be disabled via configuration if needed for compatibility reasons.
Screenshots (if appropriate)
N/A - Backend functionality only