8000 Reuse networking configuration from the node if exists by kvaps · Pull Request #53 · cozystack/talm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Reuse networking configuration from the node if exists #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

kvaps
Copy link
Member
@kvaps kvaps commented Apr 17, 2025

Signed-off-by: Andrei Kvapil kvapss@gmail.com

Summary by CodeRabbit

  • New Features

    • Added support for using existing network interface configurations in machine setup, enabling more flexible network customization.
    • Introduced a helper to retrieve and render existing network interfaces from machine configuration resources.
  • Improvements

    • Enhanced the logic for assigning floating IPs, now restricting VIP assignment to control plane machines only.
    • Simplified and clarified the conditional logic for interface configuration and floating IP assignment.

Copy link
coderabbitai bot commented Apr 17, 2025

Warning

Rate limit exceeded

@kvaps has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 43 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 566642d and c3b1c34.

⛔ Files ignored due to path filters (1)
  • pkg/generated/presets.go is excluded by !**/generated/**
📒 Files selected for processing (3)
  • charts/cozystack/templates/_helpers.tpl (1 hunks)
  • charts/generic/templates/_helpers.tpl (1 hunks)
  • charts/talm/templates/_helpers.tpl (1 hunks)

Walkthrough

This update modifies Helm chart helper templates for network interface configuration. It introduces conditional logic to include either an existing interfaces configuration or a default setup, depending on whether an existing configuration is detected. The floating IP assignment is now more restrictive, applying only when both a floating IP is set and the machine type is "controlplane." Additionally, a new helper is added to the talm chart to discover and render existing network interfaces from a cluster resource. No exported or public function signatures are changed.

Changes

File(s) Change Summary
charts/cozystack/templates/_helpers.tpl,
charts/generic/templates/_helpers.tpl
Updated template logic to conditionally include existing interfaces configuration or default; refined floating IP assignment to require both a floating IP and "controlplane" type.
charts/talm/templates/_helpers.tpl Added a helper to discover and render existing network interfaces configuration from a cluster resource.

Sequence Diagram(s)

sequenceDiagram
    participant HelmTemplate
    participant Cluster
    participant MachineConfig

    HelmTemplate->>Cluster: Lookup machineconfig (v1alpha1)
    Cluster-->>HelmTemplate: Return resource (if exists)
    HelmTemplate->>HelmTemplate: Extract .spec.machine.network.interfaces
    alt interfaces found
        HelmTemplate->>HelmTemplate: Render existing interfaces configuration
    else
        HelmTemplate->>HelmTemplate: Render default interface configuration
    end
    alt floatingIP set and type == "controlplane"
        HelmTemplate->>HelmTemplate: Add VIP block with floating IP
    end
Loading

Possibly related PRs

  • Switch back to use interface names by default #50: Modifies network interface configuration templates, focusing on changing interface specification from selector-based to direct interface name assignment, which is related to the template logic areas updated in this PR.

Poem

In the warren of code, a network grows,
With helpers that sniff where the interface flows.
If old configs are found, they're brought to the light,
Else defaults hop in, making things right.
A floating IP only for leaders to keep—
This rabbit ensures your networks won't sleep!
🐇✨


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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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
@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f9d35c and 566642d.

⛔ Files ignored due to path filters (1)
  • pkg/generated/presets.go is excluded by !**/generated/**
📒 Files selected for processing (3)
  • charts/cozystack/templates/_helpers.tpl (1 hunks)
  • charts/generic/templates/_helpers.tpl (1 hunks)
  • charts/talm/templates/_helpers.tpl (1 hunks)
🔇 Additional comments (2)
8000 charts/talm/templates/_helpers.tpl (1)

145-149: Well-implemented helper for discovering existing network interfaces

This new helper function correctly retrieves the existing network interfaces configuration from a machineconfig resource if it exists. The implementation properly handles the case when the resource or nested fields don't exist by defaulting to an empty list.

This is a good approach for reusing existing network configuration rather than always generating a new one, which aligns with the PR objective.

charts/cozystack/templates/_helpers.tpl (1)

50-62: Good conditional logic for network interfaces configuration

The implementation correctly uses the new helper to conditionally include either the existing interfaces configuration or the default setup, matching the implementation in the generic chart.

The floating IP assignment is now more restrictive, requiring both a floating IP value and the machine type to be "controlplane". This is a security improvement over the previous implementation.

Similar to the generic chart, I notice that the $existingInterfacesConfiguration variable is not explicitly defined in this file.

Do both charts/generic/templates/_helpers.tpl and charts/cozystack/templates/_helpers.tpl get the $existingInterfacesConfiguration variable from the same source? Helm variables are typically scoped to their template, so this variable should be defined or imported in both templates.

@kvaps kvaps force-pushed the reuse-networking branch from 566642d to 02feb3e Compare April 17, 2025 20:09
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps kvaps force-pushed the reuse-networking branch from 02feb3e to c3b1c34 Compare April 17, 2025 20:11
@kvaps kvaps requested a review from lllamnyp April 17, 2025 20:13
@kvaps kvaps merged commit 23e6338 into main Apr 17, 2025
3 of 4 checks passed
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
0