Skip to content

Conversation

lllamnyp
Copy link
Member

@lllamnyp lllamnyp commented Aug 26, 2025

What this PR does

Some version strings were accidentally hardcoded instead of retrieving them dynamically in the profile generator for the Talos build. This follows up #1351 and fixes these issues.

Release note

[talos] Add LLDP support and improve profile generation logic.

Summary by CodeRabbit

  • Bug Fixes

    • Anchored matching for firmware and extension digests to avoid false positives and incorrect selections during export, improving reliability of installs.
  • Chores

    • Switched to dynamic image tagging based on the detected Talos version, ensuring the correct extension images are exported for each release and reducing version mismatch issues for more consistent builds.

Some version strings were accidentally hardcoded instead of retrieving
them dynamically in the profile generator for the Talos build. This
follows up #1351 and fixes these issues.

```release-note
[talos] Add LLDP support and improve profile generation logic.
```

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@lllamnyp lllamnyp requested review from kvaps and klinch0 as code owners August 26, 2025 15:23
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Walkthrough

Updated gen-profiles.sh to use a dynamic TALOS_VERSION tag for the crane export image reference and refined digest extraction by anchoring grep matches to the "/name:" pattern using fixed-string matching.

Changes

Cohort / File(s) Summary of Changes
Installer profile generator script
packages/core/installer/hack/gen-profiles.sh
- Replaced hard-coded image tag (v1.10.6) with ghcr.io/siderolabs/extensions:${TALOS_VERSION} in crane export
- Tightened digest matching: switched from generic grep by name to grep -F anchored on the "/name:" pattern to avoid false positives

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A nibble of bash, a hop of tag,
The version now dances from env to bag.
Grep’s nose is sharper, follows the trail—
“/name:” it sniffs, with no room to fail.
I thump in delight—profiles align,
Carrots, commits, and pipelines fine! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/unpin-talos-version

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @lllamnyp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue in the Talos profile generator script where specific Talos extension versions were hardcoded. The changes update the script to dynamically retrieve these versions, ensuring consistency with the main Talos version. Additionally, the image digest lookup logic has been improved for greater precision and reliability.

Highlights

  • Dynamic Versioning: The script now dynamically retrieves the Talos extension version using the TALOS_VERSION environment variable, replacing a previously hardcoded version.
  • Improved Image Digest Lookup: The grep commands used to find image digests have been refined with fixed string matching and more specific patterns, improving the accuracy and robustness of image lookups.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly replaces a hardcoded Talos version with a dynamic variable in the profile generation script. It also improves the logic for finding firmware and extension images by making the grep pattern more specific. I've suggested a refactoring to combine two duplicated loops into one, which also addresses a potential bug where multiple matching images could lead to invalid YAML output. Overall, good changes that improve the script's correctness and maintainability.

Comment on lines 20 to 34
for firmware in $FIRMWARES; do
printf "fetching %s version: " "$firmware"
firmware_var=$(echo "$firmware" | tr '[:lower:]' '[:upper:]' | tr - _)_IMAGE
image=$(grep $firmware $TMPDIR/image-digests)
image=$(grep -F "/$firmware:" $TMPDIR/image-digests)
echo "$image"
export "$firmware_var=$image"
done

for extension in $EXTENSIONS; do
printf "fetching %s version: " "$extension"
extension_var=$(echo "$extension" | tr '[:lower:]' '[:upper:]' | tr - _)_IMAGE
image=$(grep $extension $TMPDIR/image-digests)
image=$(grep -F "/$extension:" $TMPDIR/image-digests)
echo "$image"
export "$extension_var=$image"
done

Choose a reason for hiding this comment

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

high

These two loops for FIRMWARES and EXTENSIONS are identical. You can combine them into a single loop to reduce code duplication and improve maintainability.

Additionally, there's a potential issue if grep finds multiple matching images. The $image variable would contain multiple lines, which would generate invalid YAML. The suggested code below includes a fix by taking only the first line using head -n 1. For more robustness, you might consider adding a check to ensure exactly one image is found and erroring out otherwise.

Suggested change
for firmware in $FIRMWARES; do
printf "fetching %s version: " "$firmware"
firmware_var=$(echo "$firmware" | tr '[:lower:]' '[:upper:]' | tr - _)_IMAGE
image=$(grep $firmware $TMPDIR/image-digests)
image=$(grep -F "/$firmware:" $TMPDIR/image-digests)
echo "$image"
export "$firmware_var=$image"
done
for extension in $EXTENSIONS; do
printf "fetching %s version: " "$extension"
extension_var=$(echo "$extension" | tr '[:lower:]' '[:upper:]' | tr - _)_IMAGE
image=$(grep $extension $TMPDIR/image-digests)
image=$(grep -F "/$extension:" $TMPDIR/image-digests)
echo "$image"
export "$extension_var=$image"
done
for component in $FIRMWARES $EXTENSIONS; do
printf "fetching %s version: " "$component"
component_var=$(echo "$component" | tr '[:lower:]' '[:upper:]' | tr - _)_IMAGE
image=$(grep -F "/$component:" "$TMPDIR/image-digests" | head -n 1)
echo "$image"
export "$component_var=$image"
done

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 39042fa and f09fd0b.

📒 Files selected for processing (1)
  • packages/core/installer/hack/gen-profiles.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build

@@ -15,20 +15,20 @@ echo "$talos_version"

export "TALOS_VERSION=$talos_version"

crane export ghcr.io/siderolabs/extensions:v1.10.6 | tar x -O image-digests > $TMPDIR/image-digests
crane export ghcr.io/siderolabs/extensions:${TALOS_VERSION} | tar x -O image-digests > $TMPDIR/image-digests
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Fix tar invocation and harden the pipeline (current form likely breaks on many systems).

tar x -O image-digests without -f - assumes a default tape device rather than stdin; with a pipe, GNU/dash tar won’t reliably read from stdin and will fail. Also, because /bin/sh lacks set -o pipefail, a failure in crane export may not abort the script. Replace the pipeline with a two-step, fail-safe sequence and quote paths.

Apply this diff:

-crane export ghcr.io/siderolabs/extensions:${TALOS_VERSION} | tar x -O image-digests > $TMPDIR/image-digests
+crane export "ghcr.io/siderolabs/extensions:${TALOS_VERSION}" > "$TMPDIR/extensions.tar"
+tar -xO -f "$TMPDIR/extensions.tar" image-digests > "$TMPDIR/image-digests"

Optional (outside this line range, but recommended): add a tempdir cleanup trap near the mktemp line:

trap 'rm -rf "$TMPDIR"' EXIT

Comment on lines +23 to 26
image=$(grep -F "/$firmware:" $TMPDIR/image-digests)
echo "$image"
export "$firmware_var=$image"
done
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make digest selection deterministic and fail-fast; quote paths.

  • If multiple matches exist, grep can yield multiple lines, leaking newlines into env vars and breaking YAML.
  • If there are no matches, grep exits 1, but inside command substitution with /bin/sh -e the script won’t stop; you’ll silently export an empty value.

Harden with -m1, proper quoting, and an explicit error on miss.

-  image=$(grep -F "/$firmware:" $TMPDIR/image-digests)
+  image=$(grep -F -m1 "/$firmware:" "$TMPDIR/image-digests") || {
+    echo "ERROR: digest for firmware '$firmware' not found in $TMPDIR/image-digests" >&2
+    exit 1
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
image=$(grep -F "/$firmware:" $TMPDIR/image-digests)
echo "$image"
export "$firmware_var=$image"
done
image=$(grep -F -m1 "/$firmware:" "$TMPDIR/image-digests") || {
echo "ERROR: digest for firmware '$firmware' not found in $TMPDIR/image-digests" >&2
exit 1
}
echo "$image"
export "$firmware_var=$image"
done
🤖 Prompt for AI Agents
In packages/core/installer/hack/gen-profiles.sh around lines 23-26, make the
grep deterministic, quote the file path, and fail-fast on no-match: use grep -F
-m1 -- "/$firmware:" "$TMPDIR/image-digests" (so at most one line and the path
is quoted), assign that to image, check if image is empty and if so print an
error to stderr and exit non‑zero, then echo the image and export the dynamic
variable name safely (e.g. using eval to export the variable name with the
quoted value) so you don't leak newlines or silently export empty values.

Comment on lines +31 to 34
image=$(grep -F "/$extension:" $TMPDIR/image-digests)
echo "$image"
export "$extension_var=$image"
done
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Apply the same deterministic, fail-fast pattern for extensions; quote paths.

Mirror the firmware fix to avoid multi-line matches and silent empties.

-  image=$(grep -F "/$extension:" $TMPDIR/image-digests)
+  image=$(grep -F -m1 "/$extension:" "$TMPDIR/image-digests") || {
+    echo "ERROR: digest for extension '$extension' not found in $TMPDIR/image-digests" >&2
+    exit 1
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
image=$(grep -F "/$extension:" $TMPDIR/image-digests)
echo "$image"
export "$extension_var=$image"
done
image=$(grep -F -m1 "/$extension:" "$TMPDIR/image-digests") || {
echo "ERROR: digest for extension '$extension' not found in $TMPDIR/image-digests" >&2
exit 1
}
echo "$image"
export "$extension_var=$image"
done
🤖 Prompt for AI Agents
In packages/core/installer/hack/gen-profiles.sh around lines 31–34, the grep and
export for extensions can produce multi-line matches and silently export empty
values; change the grep to be deterministic (e.g. use fixed-string match, limit
to the first match, and quote the path/filename), assign the single-line result
to image, check if image is empty and fail-fast with a clear error and non-zero
exit if so, and set the dynamic environment variable using a safe method that
quotes both name and value (e.g. declare -x or printf -v + declare) instead of
the current unquoted export pattern.

Copy link
Member

@kvaps kvaps left a comment

Choose a reason for hiding this comment

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

LGTM

@kvaps kvaps merged commit a227825 into main Aug 26, 2025
20 checks passed
@kvaps kvaps deleted the fix/unpin-talos-version branch August 26, 2025 16:02
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.

2 participants