Skip to content

feat(helpers): add bond interface discovery helpers#94

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
feat/bond-discovery-helpers
Jan 6, 2026
Merged

feat(helpers): add bond interface discovery helpers#94
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
feat/bond-discovery-helpers

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Jan 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Add template helpers for automatic bond interface discovery from Talos links resource
  • Enable bond configuration generation in insecure/maintenance mode without machineconfig access

New helpers

  • talm.discovered.bond_slaves - finds slave interfaces by masterIndex
  • talm.discovered.bond_config - generates bond section from bondMaster spec
  • talm.discovered.is_bond - checks if interface is a bond

Changes

  • charts/talm/templates/_helpers.tpl - add bond discovery helpers
  • charts/generic/templates/_helpers.tpl - use bond_config in interface generation
  • charts/cozystack/templates/_helpers.tpl - use bond_config in interface generation

Example output

interfaces:
  - interface: bond0
    bond:
      interfaces:
        - enp1s0f1
        - enp2s0f1
      mode: 802.3ad
      xmitHashPolicy: layer3+4
      lacpRate: slow
      miimon: 100
      updelay: 200
      downdelay: 200
    addresses:
      - 23.109.46.209/31
    routes:
      - network: 0.0.0.0/0
        gateway: 23.109.46.208

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for network bond configuration on interfaces, enabling optional bond settings for master/slave interface management.
    • Bond configuration is conditionally applied when bond relationships are discovered, while preserving existing address and route configurations.

✏️ Tip: You can customize this high-level summary in your review settings.

Add three new template helpers for bond interface configuration:
- talm.discovered.bond_slaves: finds slave interfaces by masterIndex
- talm.discovered.bond_config: generates bond section from bondMaster spec
- talm.discovered.is_bond: checks if interface is a bond

These helpers read bond information directly from Talos links resource,
enabling bond configuration discovery in insecure/maintenance mode.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai

coderabbitai Bot commented Jan 6, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request introduces bond interface configuration management to three Helm chart templates. Three new template helpers are added to discover bond relationships and generate corresponding configuration, while two existing templates are refactored to use these helpers to conditionally inject bond settings into interface blocks.

Changes

Cohort / File(s) Summary
Bond Configuration Injection
charts/cozystack/templates/_helpers.tpl, charts/generic/templates/_helpers.tpl
Refactored to compute default link name into a variable and conditionally include bond configuration from talm.discovered.bond_config if present. Preserves existing addresses and routes blocks while augmenting interface configuration with optional bond settings.
Bond Discovery Helpers
charts/talm/templates/_helpers.tpl
Added three new template definitions: talm.discovered.bond_slaves (filters slave interfaces for a given bond index), talm.discovered.bond_config (generates YAML bond configuration including mode, hash policy, and timing parameters), and talm.discovered.is_bond (identifies bond-kind links).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Bonds tie interfaces together,
With slaves and masters, light as feather,
Helpers discovered, configs injected,
Network harmony, perfectly connected!


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da29320 and fd1b4f9.

📒 Files selected for processing (3)
  • charts/cozystack/templates/_helpers.tpl
  • charts/generic/templates/_helpers.tpl
  • charts/talm/templates/_helpers.tpl

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello Andrei Kvapil (@kvaps), 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 enhances network configuration capabilities by introducing new Helm template helpers for automated discovery and configuration of bonded network interfaces. These helpers leverage Talos links resources to dynamically generate bond configurations, making it easier to set up complex network interfaces, particularly in scenarios where direct machine configuration access is restricted.

Highlights

  • Bond Interface Discovery: Added template helpers for automatic bond interface discovery from Talos links resource.
  • Bond Configuration Generation: Enabled bond configuration generation in insecure/maintenance mode without machineconfig access.
  • New Helpers: Introduced talm.discovered.bond_slaves to find slave interfaces by masterIndex, talm.discovered.bond_config to generate bond sections from bondMaster spec, and talm.discovered.is_bond to check if an interface is a bond.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 (@gemini-code-assist) Responds in comments when explicitly tagged, both in pull request 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 (@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.

@kvaps Andrei Kvapil (kvaps) marked this pull request as ready for review January 6, 2026 10:59
@kvaps Andrei Kvapil (kvaps) merged commit 59d3d43 into main Jan 6, 2026
1 of 2 checks passed

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

Copy link
Copy Markdown
Contributor

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 introduces valuable new Helm template helpers for discovering and configuring bond interfaces in Talos, which is a great feature for automating network setup. The changes in the cozystack and generic charts correctly utilize these new helpers. My review focuses on improving the robustness of the new helpers in charts/talm/templates/_helpers.tpl to prevent potential template rendering errors when encountering unexpected or malformed input data. I've suggested adding more checks for data existence before use and utilizing hasKey for optional parameters to correctly handle all valid values, including zero.

Comment on lines +185 to +199
{{- if $bondMaster.xmitHashPolicy }}
xmitHashPolicy: {{ $bondMaster.xmitHashPolicy }}
{{- end }}
{{- if $bondMaster.lacpRate }}
lacpRate: {{ $bondMaster.lacpRate }}
{{- end }}
{{- if $bondMaster.miimon }}
miimon: {{ $bondMaster.miimon }}
{{- end }}
{{- if $bondMaster.updelay }}
updelay: {{ $bondMaster.updelay }}
{{- end }}
{{- if $bondMaster.downdelay }}
downdelay: {{ $bondMaster.downdelay }}
{{- end }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The current implementation uses if $bondMaster.someKey to check for optional parameters. This can cause issues for numeric parameters like miimon, updelay, and downdelay if their value is 0, as if 0 evaluates to false in Go templates, causing the parameter to be omitted. Using hasKey $bondMaster "someKey" is a more robust way to check for a key's presence, regardless of its value.

  {{- if hasKey $bondMaster "xmitHashPolicy" }}
  xmitHashPolicy: {{ $bondMaster.xmitHashPolicy }}
  {{- end }}
  {{- if hasKey $bondMaster "lacpRate" }}
  lacpRate: {{ $bondMaster.lacpRate }}
  {{- end }}
  {{- if hasKey $bondMaster "miimon" }}
  miimon: {{ $bondMaster.miimon }}
  {{- end }}
  {{- if hasKey $bondMaster "updelay" }}
  updelay: {{ $bondMaster.updelay }}
  {{- end }}
  {{- if hasKey $bondMaster "downdelay" }}
  downdelay: {{ $bondMaster.downdelay }}
  {{- end }}

{{- $bondIndex := . -}}
{{- $slaves := list -}}
{{- range (lookup "links" "" "").items -}}
{{- if and (eq .spec.slaveKind "bond") (eq (int .spec.masterIndex) (int $bondIndex)) -}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness, it's safer to check for the existence of .spec.masterIndex before attempting to use it in the int function. This will prevent potential template rendering errors if a link item in the loop is missing the masterIndex field.

{{- if and .spec.masterIndex (eq .spec.slaveKind "bond") (eq (int .spec.masterIndex) (int $bondIndex)) -}}

{{- define "talm.discovered.bond_config" -}}
{{- $linkName := . -}}
{{- $link := lookup "links" "" $linkName -}}
{{- if and $link (eq $link.spec.kind "bond") -}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To make the helper more robust, it's good practice to also check for the existence of bondMaster and index on the link spec before trying to access them. This prevents potential template rendering errors if a link of kind "bond" is missing these fields for some reason.

{{- if and $link (eq $link.spec.kind "bond") $link.spec.bondMaster $link.spec.index -}}

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.

1 participant