Skip to content

Conversation

@timmilesdw
Copy link
Contributor

Description:

Problem

When running d8 mirror pull from a local registry with a port (e.g., localhost:443/deckhouse-etalon), the command fails with:

could not parse reference: localhost:443/deckhouse-etalon/localhost:443/deckhouse-etalon:sha256-xxx.att

The same command works correctly with remote registry.deckhouse.ru.

Root Cause

The FindVexImage function uses strings.SplitN(url, ":", 2) to split the URL into path and tag. For URLs containing a port, this splits at the first colon (the port separator) instead of the last colon (the tag separator):

Input:  localhost:443/deckhouse-etalon:sha256-xxx.att

SplitN(":", 2) result:
  imagePath = "localhost"                        ❌ (cut at port)
  tag = "443/deckhouse-etalon:sha256-xxx.att"    ❌

This incorrect parsing led to path duplication when constructing the final reference.

Solution

  • Replace strings.SplitN with strings.LastIndex to find the last colon (before the tag)
  • Remove unused segment manipulation code that was causing path duplication
  • Add proper error handling for CheckImageExists — previously, errors other than ErrImageNotFound were silently ignored

Files Changed

  • pkg/libmirror/images/digests.go
  • pkg/libmirror/layouts/layouts.go

Notes

  • Bug was introduced during registry client refactoring
  • The new pull implementation (NEW_PULL=true in internal/mirror/platform/platform.go) already uses strings.LastIndex and doesn't have this issue

Signed-off-by: Timur Tuktamyshev <[email protected]>
@timmilesdw timmilesdw self-assigned this Dec 25, 2025
@timmilesdw timmilesdw added the enhancement New feature or request label Dec 25, 2025
Signed-off-by: Timur Tuktamyshev <[email protected]>
Signed-off-by: Timur Tuktamyshev <[email protected]>
@ldmonster ldmonster self-requested a review December 29, 2025 07:30
ldmonster
ldmonster previously approved these changes Dec 29, 2025
Signed-off-by: Timur Tuktamyshev <[email protected]>
@ldmonster ldmonster merged commit da83be6 into main Dec 29, 2025
4 checks passed
@ldmonster ldmonster changed the title fix: correct URL parsing for VEX images with port in registry address [deckhouse-cli] fix: mirror: correct URL parsing for VEX images with port in registry address Dec 29, 2025
@ldmonster ldmonster deleted the fix/splitn-bug branch December 29, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants