-
Notifications
You must be signed in to change notification settings - Fork 21
feat(cozystack): enable allocateNodeCIDRs by default #91
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
Conversation
📝 WalkthroughWalkthroughThe Helm chart default configuration for Cozystack is updated to enable CIDR allocation for cluster nodes by changing the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
Summary of ChangesHello @lexfrei, 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 streamlines Cozystack cluster provisioning by enabling automatic node CIDR allocation as a default setting. It also improves the Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this 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 introduces a new -N flag for specifying the cluster name during talm init, making it a required parameter unless specific update/encryption flags are used, and updates the README.md example. It also defaults allocateNodeCIDRs to true in values.yaml. A major change involves refactoring the template rendering logic to correctly handle multiple YAML documents within a single template output, separating Talos configuration patches from other Kubernetes resource definitions (like UserVolumeConfig). This includes introducing path normalization for cross-platform compatibility and new functions (isTalosConfigPatch, extractExtraDocuments, NormalizeTemplatePath) to manage this separation and path handling, with corresponding tests added. However, the review comment points out a regression in test coverage due to the removal of TestRenderWithClientProvider and TestRenderWithClientProvider_error from pkg/engine/helm/engine_test.go, which covered the critical lookup functionality for dynamic data fetching from Kubernetes, requesting their restoration and adaptation.
I am having trouble creating individual review comments. Click here to see my feedback.
pkg/engine/helm/engine_test.go (249-419)
A significant number of tests for the lookup functionality (TestRenderWithClientProvider and TestRenderWithClientProvider_error) have been removed. While the RenderWithClientProvider function may have been refactored, the lookup feature is a critical part of the templating engine that allows dynamic data fetching from a Kubernetes cluster.
Removing these tests creates a regression in test coverage for this important feature. Please restore these tests, adapting them to the new code structure (e.g., in pkg/engine/engine_test.go), to ensure the lookup functionality remains robust and well-tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/commands/template.go (1)
219-384: Consider extracting duplicate path resolution logic.The path resolution logic appears twice (lines 219-272 for helm engine and lines 298-384 for modeline) with very similar fallback handling. Consider extracting this into a helper function to reduce duplication and improve maintainability.
Potential refactor approach
You could create a helper function like:
func resolveTemplatePathsRelativeToRoot(templatePaths []string, rootDir string) []string { resolved := make([]string, len(templatePaths)) absRootDir, rootErr := filepath.Abs(rootDir) if rootErr != nil { for i, p := range templatePaths { resolved[i] = engine.NormalizeTemplatePath(p) } return resolved } // ... common resolution logic ... return resolved }Then call it for both the helm engine keys and modeline paths.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
README.mdcharts/cozystack/values.yamlpkg/commands/init.gopkg/commands/template.gopkg/engine/engine.gopkg/engine/engine_test.gopkg/engine/engine_windows_test.gopkg/engine/helm/engine_test.go
💤 Files with no reviewable changes (1)
- pkg/engine/helm/engine_test.go
🧰 Additional context used
🧬 Code graph analysis (3)
pkg/engine/engine_test.go (1)
pkg/engine/engine.go (1)
NormalizeTemplatePath(64-66)
pkg/engine/engine_windows_test.go (1)
pkg/engine/engine.go (1)
NormalizeTemplatePath(64-66)
pkg/commands/template.go (4)
pkg/commands/root_detection.go (1)
ResolveSecretsPath(226-234)pkg/commands/root.go (1)
Config(38-73)pkg/modeline/modeline.go (1)
Config(12-16)pkg/engine/engine.go (1)
NormalizeTemplatePath(64-66)
🔇 Additional comments (14)
README.md (1)
59-59: LGTM! Documentation reflects the new cluster name flag.The updated example command correctly demonstrates the new
-Nflag for specifying the cluster name.charts/cozystack/values.yaml (1)
14-14: Verify backward compatibility for existing clusters.Enabling node CIDR allocation by default changes networking behavior for all new deployments. Ensure that existing clusters using this chart won't be affected if they upgrade, and consider documenting this change in release notes.
pkg/engine/engine_windows_test.go (1)
1-40: LGTM! Comprehensive Windows path normalization tests.The test cases properly cover backslash conversion scenarios specific to Windows, ensuring cross-platform compatibility.
pkg/commands/template.go (2)
144-144: LGTM! Proper error wrapping.Good improvement using
%wfor error wrapping to preserve the error chain.
176-178: LGTM! Proper error handling added.Good addition of error handling with proper wrapping and early return for file write operations.
pkg/engine/engine_test.go (1)
1-155: LGTM! Comprehensive test coverage.Excellent test coverage for the new YAML patch handling and path normalization functionality. The tests cover:
- Different Talos config document types
- Non-Talos documents (UserVolumeConfig, SideroLinkConfig)
- Edge cases (empty documents, invalid YAML, CRLF line endings)
- Path normalization scenarios
pkg/engine/engine.go (4)
61-66: LGTM! Well-documented path normalization helper.The exported
NormalizeTemplatePathfunction provides consistent cross-platform path normalization. The comment clearly explains why this is necessary (Helm engine uses forward slashes).
245-246: LGTM! Correct use of path.Join for Helm engine keys.Using
path.Joininstead offilepath.Joinis correct here because Helm engine returns map keys with forward slashes regardless of the OS. The comment on line 245 clearly documents this behavior.
347-385: LGTM! Clean separation of Talos config from extra documents.The implementation properly:
- Identifies Talos config patches (containing
machine:orcluster:keys)- Separates extra documents like UserVolumeConfig
- Handles CRLF line endings
- Uses a robust regex for YAML document separator matching
This addresses issue #66 mentioned in the tests.
388-389: LGTM! Proper handling of extra YAML documents.The changes correctly:
- Extract Talos patches separately from extra documents (lines 388-389)
- Process only Talos patches for config generation (line 426)
- Append extra documents to the output after Talos config (lines 543-548)
This ensures non-Talos documents like UserVolumeConfig are preserved in the final output.
Also applies to: 426-426, 543-548
pkg/commands/init.go (4)
36-44: LGTM! New cluster name flag added.The new
namefield is properly integrated into theinitCmdFlagsstructure.
75-84: LGTM! Proper validation logic.The PreRunE validation correctly requires both
presetandnamefor normal initialization, while allowing them to be optional for--encrypt,--decrypt, or--updateoperations.
311-311: Verify backward compatibility: cluster name now from flag.The cluster name is now sourced from
initCmdFlags.nameinstead of being derived from the directory path. This is a behavioral change that might affect existing workflows or scripts.Ensure this change is documented in release notes and migration guides.
675-676: LGTM! Clear flag documentation.The help text properly indicates when the
presetandnameflags are not required, improving the user experience.
Enable automatic node CIDR allocation for all clusters by default. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
6fdfaef to
0ff2aea
Compare
Summary
This change sets
allocateNodeCIDRs: truein the default values, ensuring that node CIDRs are allocated automatically without requiring explicit configuration.Test plan
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.