Skip to content

[fix] - CloudInit - #1012

Closed
gwynbleidd2106 wants to merge 0 commit into
mainfrom
fix-cloudinit
Closed

[fix] - CloudInit#1012
gwynbleidd2106 wants to merge 0 commit into
mainfrom
fix-cloudinit

Conversation

@gwynbleidd2106

@gwynbleidd2106 gwynbleidd2106 commented May 30, 2025

Copy link
Copy Markdown
Contributor

If SSH key and CloudInit provided - proceed
If ssh key provided but not CloudInit - proceed
Otherwise skip CloudInit section

Summary by CodeRabbit

  • New Features
    • Improved handling of SSH keys and cloud-init configuration in virtual machine templates. Cloud-init user data is now generated inline when only SSH keys are provided, and a dedicated user is created with SSH key access.
  • Style
    • Enhanced template readability with additional spacing.
  • Chores
    • Updated installer to use the latest Docker image version for cozystack.

@coderabbitai

coderabbitai Bot commented May 30, 2025

Copy link
Copy Markdown
Contributor

"""

Walkthrough

The VirtualMachine Helm template was updated to refine the conditional logic for including SSH keys and cloud-init configuration. The changes separate handling for SSH keys and cloud-init, adjust the inclusion of disks and volumes, and improve the inline cloud-init user data generation. Formatting improvements were also made. Additionally, the installer image tag for cozystack was updated from a specific release candidate version to the latest tag.

Changes

File(s) Change Summary
packages/apps/virtual-machine/templates/vm.yaml Refined conditional logic for SSH keys and cloud-init, updated disks and volumes sections with distinct conditions, improved inline cloud-init user data generation, and adjusted formatting for readability.
packages/core/installer/values.yaml Updated cozystack installer Docker image reference from a specific release candidate tag to the latest tag with a new SHA256 digest.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HelmTemplate
    participant VMResource

    User->>HelmTemplate: Provide .Values (sshKeys, cloudInit)
    HelmTemplate->>HelmTemplate: Evaluate .Values.sshKeys and .Values.cloudInit
    alt Both sshKeys and cloudInit present
        HelmTemplate->>VMResource: Add cloudinitdisk referencing secret with user "ubuntu" and SSH keys
        HelmTemplate->>VMResource: Add accessCredentials block
    else Only sshKeys present
        HelmTemplate->>VMResource: Add cloudinitdisk generating inline user data with SSH keys
        HelmTemplate->>VMResource: Add accessCredentials block
    else Neither present
        HelmTemplate->>VMResource: Add minimal cloudinitdisk with basic userData
        HelmTemplate->>VMResource: Exclude accessCredentials block
    end
Loading

Possibly related PRs

Suggested labels

enhancement, size:XS

Poem

🐇 Through YAML lines I softly hop,
Tweaking keys that never stop.
SSH or cloud-init flair,
The template now handles with care.
Clean and clear, the bytes align,
Virtual machines now shine! ✨
🌿🐰
"""


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b5a226a and e1e93b1.

📒 Files selected for processing (2)
  • packages/apps/virtual-machine/templates/vm.yaml (4 hunks)
  • packages/core/installer/values.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/core/installer/values.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/apps/virtual-machine/templates/vm.yaml

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

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

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/apps/virtual-machine/templates/vm.yaml (1)

116-146: Consider DRY-ing duplicated inline CloudInit userData
Both conditional blocks (lines 116–131 and 133–146) repeat the same inline users and chpasswd configuration. You could consolidate them into a single if .Values.sshKeys block with a nested condition for secretRef to reduce duplication.

- {{- if and .Values.sshKeys .Values.cloudInit }}
- - name: cloudinitdisk
-   cloudInitNoCloud:
-     secretRef:
-       name: {{ include "virtual-machine.fullname" . }}-cloud-init
-     userData: |
-       {{ printf "%s" "#cloud-config" }}
-       ... (ssh keys & chpasswd)
- {{- end }}
- {{- if and .Values.sshKeys (not .Values.cloudInit) }}
- - name: cloudinitdisk
-   cloudInitNoCloud:
-     userData: |
-       {{ printf "%s" "#cloud-config" }}
-       ... (ssh keys & chpasswd)
- {{- end }}
+ {{- if .Values.sshKeys }}
+ - name: cloudinitdisk
+   cloudInitNoCloud:
+     {{- if .Values.cloudInit }}
+     secretRef:
+       name: {{ include "virtual-machine.fullname" . }}-cloud-init
+     {{- end }}
+     userData: |
+       {{ printf "%s" "#cloud-config" }}
+       users:
+         - name: ubuntu
+           ssh_authorized_keys: |
+             {{- range .Values.sshKeys }}
+             {{ . }}
+             {{- end }}
+       chpasswd:
+         expire: false
+ {{- end }}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 20f4066 and 178c9b8.

📒 Files selected for processing (1)
  • packages/apps/virtual-machine/templates/vm.yaml (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (7)
packages/apps/virtual-machine/templates/vm.yaml (7)

16-16: Approve formatting: inserted blank line for readability
The extra blank line after the running field improves separation of spec sections.


27-27: Approve formatting: inserted blank line for readability
The blank line before dataVolumeTemplates enhances visual structure.


80-80: Approve formatting: inserted blank line before disks block
Additional whitespace aids clarity of device sections.


85-89: Disk inclusion condition now only checks for SSH keys
The cloudinitdisk is now added only when .Values.sshKeys is provided (dropping the previous .Values.cloudInit check), aligning with the requirement to skip CloudInit when no SSH keys exist.

Please confirm that skipping the CloudInit disk when only .Values.cloudInit is set (and no SSH keys) is the intended behavior.


98-107: Access credentials block gated on SSH keys
Replacing the earlier with block, the accessCredentials section is now rendered only when .Values.sshKeys is set, matching the refined logic.


116-131: Render CloudInit volume with secretRef and embedded SSH keys when both SSH and CloudInit are present
This block mounts the CloudInit secret (-cloud-init) and injects the SSH keys inline, disabling password expiration. It correctly handles the combined SSH+CloudInit scenario.


133-146: Render inline CloudInit volume when only SSH keys are present
The template now generates a minimal cloudInitNoCloud volume with embedded SSH keys and disabled password expiration when .Values.cloudInit is not provided.

Comment thread packages/apps/virtual-machine/templates/vm.yaml Outdated
@gwynbleidd2106
gwynbleidd2106 force-pushed the fix-cloudinit branch 3 times, most recently from dde4d78 to b5a226a Compare June 2, 2025 07:09
@gwynbleidd2106 gwynbleidd2106 added kind/bug Categorizes issue or PR as related to a bug do-not-merge and removed do-not-merge labels Jun 2, 2025
@gwynbleidd2106 gwynbleidd2106 removed kind/bug Categorizes issue or PR as related to a bug do-not-merge labels Jun 2, 2025
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