Skip to content

[fix] CloudInit - #1019

Merged
klinch0 merged 1 commit into
mainfrom
fix-cloudinit
Jun 5, 2025
Merged

[fix] CloudInit#1019
klinch0 merged 1 commit into
mainfrom
fix-cloudinit

Conversation

@gwynbleidd2106

@gwynbleidd2106 gwynbleidd2106 commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

If ssh key provided - deploy
If cloudinit provided - deploy
If ssh key and cloudinit provided - deploy both
If none provided - init empty to avoid issues w/
network

Summary by CodeRabbit

  • Refactor
    • Improved handling of SSH keys and cloud-init data in the Virtual Machine setup, clearly distinguishing cases when SSH keys, cloud-init, or both are provided.
    • Enhanced template readability with added spacing for better clarity.

@coderabbitai

coderabbitai Bot commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The update refines the conditional logic in the vm.yaml Helm template for virtual machines. It changes how and when the cloudinitdisk disk, volume, and accessCredentials are included, now basing these on the presence of .Values.sshKeys and .Values.cloudInit with more explicit and separated conditions for each scenario.

Changes

File(s) Change Summary
packages/apps/virtual-machine/templates/vm.yaml Refined conditional logic for cloudinitdisk disk, volume, and accessCredentials based on .Values.sshKeys and .Values.cloudInit; improved readability with added blank lines.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • lllamnyp
  • kvaps

Poem

A whisk of keys, a cloud of config,
The bunny hops through logic, nimble and quick.
Now SSH and secrets each have their own lane,
With YAML more tidy, less tangled, less pain.
🐇✨


📜 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 23a88e1 and 6493602.

📒 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 (1)
packages/apps/virtual-machine/templates/vm.yaml (1)

98-107: Switch from with to if for accessCredentials guard

Replacing with .Values.sshKeys with if .Values.sshKeys preserves the root context ($) for include, making the block clearer and avoiding context confusion. The implementation correctly uses $ to reference the VM fullname:

- {{- with .Values.sshKeys }}
+ {{- if .Values.sshKeys }}

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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a887e19 and 268b6dd.

📒 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: Test
🔇 Additional comments (1)
packages/apps/virtual-machine/templates/vm.yaml (1)

98-107: AccessCredentials injection correctly scoped to SSH keys
Good use of accessCredentials to inject SSH public keys only when .Values.sshKeys is defined. Passing the root context ($) into include ensures the VM name is resolved correctly.

Comment thread packages/apps/virtual-machine/templates/vm.yaml
Comment on lines +112 to +138
- name: systemdisk
dataVolume:
name: {{ include "virtual-machine.fullname" . }}

{{- if and .Values.sshKeys .Values.cloudInit }}
- name: cloudinitdisk
cloudInitNoCloud:
secretRef:
name: {{ include "virtual-machine.fullname" . }}-cloud-init
{{- else if .Values.sshKeys }}
- name: cloudinitdisk
cloudInitNoCloud:
userData: |
{{ printf "%s" "#cloud-config" }}
users:
- name: ubuntu
ssh_authorized_keys:
{{- range .Values.sshKeys }}
- {{ . }}
{{- end }}
chpasswd:
expire: false
{{- else }}
userData: |
#cloud-config
final_message: Cloud-init user-data was left blank intentionally.
- name: cloudinitdisk
cloudInitNoCloud:
userData: |
{{ printf "%s" "#cloud-config" }}
{{- end }}
{{- 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.

⚠️ Potential issue

Missing CloudInit-only volume handling
The volumes block currently only distinguishes “both SSH+CloudInit” and “SSH-only” cases, then falls back to a minimal header for all others. A CloudInit‐only scenario (.Values.cloudInit set, no .Values.sshKeys) ends up mounting an empty stub instead of the user’s CloudInit config, defeating the PR’s goal of supporting standalone CloudInit.

Introduce a dedicated branch for CloudInit‐only, for example:

- {{- if and .Values.sshKeys .Values.cloudInit }}
  - name: cloudinitdisk
    cloudInitNoCloud:
      secretRef:
        name: {{ include "virtual-machine.fullname" . }}-cloud-init
- {{- else if .Values.sshKeys }}
  - name: cloudinitdisk
    cloudInitNoCloud:
      userData: |
        {{ printf "%s" "#cloud-config" }}
        users:
          - name: ubuntu
            ssh_authorized_keys:
              {{- range .Values.sshKeys }}
              - {{ . }}
              {{- end }}
        chpasswd:
          expire: false
- {{- else }}
  - name: cloudinitdisk
    cloudInitNoCloud:
      userData: |
        {{ printf "%s" "#cloud-config" }}
- {{- end }}
+ {{- if and .Values.sshKeys .Values.cloudInit }}
    ...same as before...
+ {{- else if .Values.sshKeys }}
    ...same as before...
+ {{- else if .Values.cloudInit }}
  - name: cloudinitdisk
    cloudInitNoCloud:
      secretRef:
        name: {{ include "virtual-machine.fullname" . }}-cloud-init
+ {{- else }}
  - name: cloudinitdisk
    cloudInitNoCloud:
      userData: |
        {{ printf "%s" "#cloud-config" }}
+ {{- end }}

Ensure the branch correctly references the intended secret or field for standalone CloudInit content.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/apps/virtual-machine/templates/vm.yaml around lines 112 to 140, the
volumes block lacks a specific case for CloudInit-only configuration, causing it
to mount an empty stub instead of the user's CloudInit config when
.Values.cloudInit is true but .Values.sshKeys is not set. Add a dedicated
conditional branch that checks for CloudInit-only (true .Values.cloudInit and
false or empty .Values.sshKeys) and configure the cloudInitdisk volume to
reference the correct secret or userData for standalone CloudInit content,
ensuring the volume mounts the intended CloudInit configuration properly.

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@gwynbleidd2106
gwynbleidd2106 force-pushed the fix-cloudinit branch 2 times, most recently from f99c474 to 23a88e1 Compare June 3, 2025 06:11
gwynbleidd2106 pushed a commit that referenced this pull request Jun 3, 2025
Made same changes as in
[PR](#1019)

Signed-off-by: Ahmad Murzahmatov <gwynbleid2106@yandex.com>
gwynbleidd2106 pushed a commit that referenced this pull request Jun 3, 2025
Made same changes as in
[PR](#1019)

Signed-off-by: Ahmad Murzahmatov <gwynbleid2106@yandex.com>
This PR prepares the release `v0.31.0-rc.3`.

Signed-off by: Timofei Larkin <lllamnyp@gmail.com>
gwynbleidd2106 pushed a commit that referenced this pull request Jun 3, 2025
Made same changes as in
[PR](#1019)

Signed-off-by: Ahmad Murzahmatov <gwynbleid2106@yandex.com>
gwynbleidd2106 pushed a commit that referenced this pull request Jun 3, 2025
Made same changes as in
[PR](#1019)

Signed-off-by: Ahmad Murzahmatov <gwynbleid2106@yandex.com>
gwynbleidd2106 pushed a commit that referenced this pull request Jun 3, 2025
Made same changes as in
[PR](#1019)

Signed-off-by: Ahmad Murzahmatov <gwynbleid2106@yandex.com>
@klinch0
klinch0 merged commit 730ea4d into main Jun 5, 2025
@klinch0
klinch0 deleted the fix-cloudinit branch June 5, 2025 12:53
gwynbleidd2106 pushed a commit that referenced this pull request Jun 5, 2025
Made same changes as in
[PR](#1019)

Signed-off-by: Ahmad Murzahmatov <gwynbleidd2106@yandex.com>
gwynbleidd2106 added a commit that referenced this pull request Jun 6, 2025
made same change as in
(PR){#1019}

Signed-off-by: Ahmad Murzahmatov <gwynbleidd2106@yandex.com>
gwynbleidd2106 added a commit that referenced this pull request Jun 6, 2025
made same change as in
(PR){#1019}

Signed-off-by: Ahmad Murzahmatov <gwynbleidd2106@yandex.com>
gwynbleidd2106 added a commit that referenced this pull request Jun 6, 2025
made same change as in
(PR){#1019}

Signed-off-by: Ahmad Murzahmatov <gwynbleidd2106@yandex.com>
gwynbleidd2106 added a commit that referenced this pull request Jun 6, 2025
made same change as in
[PR](#1019)

Signed-off-by: Ahmad Murzahmatov <gwynbleidd2106@yandex.com>
Andrei Kvapil (kvaps) added a commit that referenced this pull request Jun 9, 2025
Made same changes as in
[PR](#1019)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for defining a system disk with customizable storage and
image sources for virtual machines.
- **Improvements**
- Enhanced cloud-init configuration to require both SSH keys and
cloud-init data for certain volume setups, improving user data handling.
- Simplified disk configuration for virtual machines, making setup more
straightforward.
- Shortened and clarified error messages for missing configuration
fields.
- **Chores**
- Updated chart and package versions for virtual-machine and vm-instance
applications.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@NickVolynkin Nick Volynkin (NickVolynkin) mentioned this pull request Jun 16, 2025
8 tasks
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.

4 participants