Skip to content

docker: fix container build tag selection lag#778

Open
Meshwa428 wants to merge 2 commits into
mostlygeek:mainfrom
Meshwa428:fix/tag-selection-sorting
Open

docker: fix container build tag selection lag#778
Meshwa428 wants to merge 2 commits into
mostlygeek:mainfrom
Meshwa428:fix/tag-selection-sorting

Conversation

@Meshwa428

Copy link
Copy Markdown

Ensure fetch_llama_tag matches build tags precisely and sorts them numerically to select the newest bNNNN build.

  • Restrict tag matches to ^$prefix-b[0-9]+$ to avoid matching static tags and other backend architectures.
  • Sort matching tags numerically using version sort (sort -V) instead of lexicographical sort to correctly prioritize newer builds.

fixes #777

Ensure fetch_llama_tag matches build tags precisely and sorts them numerically to select the newest bNNNN build.

- Restrict tag matches to ^-b[0-9]+$ to avoid matching static tags and other backend architectures.
- Sort matching tags numerically using version sort (sort -V) instead of lexicographical sort to correctly prioritize newer builds.

fixes mostlygeek#777
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 02239aaf-0a49-4dda-8c70-3235ec8bda0b

📥 Commits

Reviewing files that changed from the base of the PR and between 7dad356 and 8be21e1.

📒 Files selected for processing (1)
  • docker/build-container.sh

Walkthrough

fetch_llama_tag() in docker/build-container.sh now regex-filters container tags matching <prefix>-b<digits>, sorts matches with sort -V, and selects the latest via tail -n1 instead of previous startswith/string-sort logic.

Changes

Container tag selection refinement

Layer / File(s) Summary
fetch_llama_tag() regex matching and semantic version sort
docker/build-container.sh
Tag filtering now uses a regex ^<prefix>-b[0-9]+$ against metadata.container.tags[]?, then applies sort -V and tail -n1 to choose the numerically newest build tag, replacing startswith-based filtering and the prior sort/head selection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • mostlygeek/llama-swap#391: Also modifies docker/build-container.sh's llama.cpp tag selection logic, including how GitHub Container/Packages tags are filtered and the latest version is chosen.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: fixing container build tag selection logic to properly prioritize the newest build.
Description check ✅ Passed The description is directly related to the changeset, explaining the regex restriction and numeric sorting approach to fix tag selection.
Linked Issues check ✅ Passed The PR addresses issue #777 by implementing both proposed solutions: restricting tag matches via regex and using version sort for numerically correct ordering.
Out of Scope Changes check ✅ Passed All changes are scoped to the fetch_llama_tag function in docker/build-container.sh and directly address the tag selection and sorting objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Meshwa428

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docker/build-container.sh`:
- Around line 104-106: The pipeline populating found_tag (using jq and sort -V)
is masking failures because declaring and assigning with local in one statement
hides the pipeline exit status; split the declaration and assignment (e.g.,
first declare local found_tag, then assign found_tag=$(...) ), and ensure the
function or script has set -o pipefail (or explicitly check the pipeline's exit
status) so jq/sort errors cause an immediate failure instead of being treated as
"no tag found" and continuing pagination.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0e8c5c9f-f61e-40af-b42b-cce32538c064

📥 Commits

Reviewing files that changed from the base of the PR and between 59cd3b6 and 7dad356.

📒 Files selected for processing (1)
  • docker/build-container.sh

Comment thread docker/build-container.sh Outdated
Line 104 declares and assigns `found_tag` in one statement. In bash, that masks the pipeline's exit status, so a broken `jq` expression or unsupported `sort -V` gets treated as "no tag found" and the loop keeps paginating instead of failing with the real error.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Meshwa428

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mostlygeek

Copy link
Copy Markdown
Owner

I don't think there is a bug here.

The current scripts find the latest containers correctly. I manually dispatched the container job and it picked up the latest container. The lag comes from when the cronjob to build containers runs and when the llama.cpp project finishes publishing new containers.

If the llama-swap job runs before llama.cpp's container scripts are finished we get the lag. One tweak we can do is to move the cronjob to about 10hrs after the llama.cpp's nightly container build scripts. This gives them enough time to finish and reduces the likelihood of running before the new containers are published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Container builds can lag behind latest llama.cpp (tag selection in docker/build-container.sh is not reliably picking newest server-* build)

2 participants