Skip to content

Conversation

klinch0
Copy link
Contributor

@klinch0 klinch0 commented Jul 5, 2025

What this PR does

Release note

- vm and vmi add svc to dashboard

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced dashboard permissions to allow viewing and monitoring of specific service resources in both the virtual-machine and vm-instance applications.
  • Chores

    • Updated chart versions for virtual-machine (to 0.12.1) and vm-instance (to 0.9.1).
    • Refreshed version mappings for virtual-machine and vm-instance components.

@klinch0 klinch0 requested review from kvaps and lllamnyp as code owners July 5, 2025 09:04
Copy link
Contributor

coderabbitai bot commented Jul 5, 2025

Walkthrough

This update increments the chart versions for the virtual-machine and vm-instance Helm charts, updates their version mappings by replacing HEAD with specific commit hashes and adding new HEAD entries with incremented patch versions, and adds new RBAC rules to allow dashboard access to specific Kubernetes service resources in both applications.

Changes

File(s) Change Summary
packages/apps/versions_map Updated virtual-machine and vm-instance version mappings: moved previous HEAD to specific commit, added new HEAD with incremented patch version.
packages/apps/virtual-machine/Chart.yaml
packages/apps/vm-instance/Chart.yaml
Incremented chart versions: virtual-machine 0.12.0 → 0.12.1, vm-instance 0.9.0 → 0.9.1.
packages/apps/virtual-machine/templates/dashboard-resourcemap.yaml
packages/apps/vm-instance/templates/dashboard-resourcemap.yaml
Added RBAC rule granting get, list, and watch permissions on the specific services resource for dashboard roles.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Dashboard
    participant Kubernetes API
    participant Service Resource

    User->>Dashboard: Requests service info
    Dashboard->>Kubernetes API: get/list/watch on specific Service (allowed by new RBAC rule)
    Kubernetes API->>Service Resource: Access granted
    Service Resource-->>Kubernetes API: Responds with data
    Kubernetes API-->>Dashboard: Returns service data
    Dashboard-->>User: Displays service info
Loading

Possibly related PRs

Suggested labels

size:XS

Suggested reviewers

  • lllamnyp
  • kvaps

Poem

A hop and a skip, a patch on the way,
Chart numbers climb higher—what a fine day!
RBAC’s new rule lets dashboards now see
The services hopping as safe as can be.
With every small change, our stack’s more complete,
A carrot for coders—this update’s a treat! 🥕


📜 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 6b0ca9f and f251cba.

📒 Files selected for processing (5)
  • packages/apps/versions_map (2 hunks)
  • packages/apps/virtual-machine/Chart.yaml (1 hunks)
  • packages/apps/virtual-machine/templates/dashboard-resourcemap.yaml (1 hunks)
  • packages/apps/vm-instance/Chart.yaml (1 hunks)
  • packages/apps/vm-instance/templates/dashboard-resourcemap.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/apps/virtual-machine/Chart.yaml
  • packages/apps/vm-instance/Chart.yaml
  • packages/apps/vm-instance/templates/dashboard-resourcemap.yaml
  • packages/apps/virtual-machine/templates/dashboard-resourcemap.yaml
  • packages/apps/versions_map
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build

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.

Copy link
Contributor

@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: 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 70f8266 and 6b0ca9f.

📒 Files selected for processing (5)
  • packages/apps/versions_map (2 hunks)
  • packages/apps/virtual-machine/Chart.yaml (1 hunks)
  • packages/apps/virtual-machine/templates/dashboard-resourcemap.yaml (1 hunks)
  • packages/apps/vm-instance/Chart.yaml (1 hunks)
  • packages/apps/vm-instance/templates/dashboard-resourcemap.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
packages/apps/vm-instance/templates/dashboard-resourcemap.yaml (1)
Learnt from: NickVolynkin
PR: cozystack/cozystack#1120
File: packages/apps/clickhouse/README.md:60-67
Timestamp: 2025-07-03T05:54:51.264Z
Learning: The `cozy-lib.resources.sanitize` function in packages/library/cozy-lib/templates/_resources.tpl supports both standard Kubernetes resource format (with limits:/requests: sections) and flat format (direct resource specifications). The flat format takes priority over nested values. CozyStack apps include cozy-lib as a chart dependency through symlinks in packages/apps/*/charts/cozy-lib directories.
packages/apps/virtual-machine/templates/dashboard-resourcemap.yaml (1)
Learnt from: NickVolynkin
PR: cozystack/cozystack#1120
File: packages/apps/clickhouse/README.md:60-67
Timestamp: 2025-07-03T05:54:51.264Z
Learning: The `cozy-lib.resources.sanitize` function in packages/library/cozy-lib/templates/_resources.tpl supports both standard Kubernetes resource format (with limits:/requests: sections) and flat format (direct resource specifications). The flat format takes priority over nested values. CozyStack apps include cozy-lib as a chart dependency through symlinks in packages/apps/*/charts/cozy-lib directories.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (3)
packages/apps/virtual-machine/Chart.yaml (1)

20-20: Patch-level bump OK – double-check frozen appVersion.

Chart version was bumped to 0.12.1 while appVersion stayed at 0.12.0.
That is perfectly valid if the underlying application code didn’t change, but please confirm that this mismatch is intentional and documented in the CHANGELOG so downstream tooling doesn’t mistake it for drift.

packages/apps/vm-instance/Chart.yaml (1)

20-20: Chart version bumped – same appVersion caveat.

version0.9.1 with appVersion unchanged (0.8.0). As with the VM chart, ensure this deliberately represents a chart-only change.

packages/apps/versions_map (1)

156-157: Mapping update looks coherent – verify commit 70f82667 exists.

Old HEAD entries were pinned to the specific commit and new HEAD lines added for 0.12.1 and 0.9.1. Just make sure commit 70f82667 is reachable in the repo history; CI will fail otherwise.

Also applies to: 174-175

Comment on lines +6 to +12
- apiGroups:
- ""
resources:
- services
resourceNames:
- {{ include "virtual-machine.fullname" . }}
verbs: ["get", "list", "watch"]
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 5, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Tighten RBAC rule – list/watch + resourceNames grants cluster-wide visibility.

When resourceNames is specified, the Kubernetes RBAC authorizer ignores it for list/watch verbs, effectively allowing the caller to observe all Services in the namespace – broader than the single-service intent.

Consider splitting the rule:

-  resourceNames:
-  - {{ include "virtual-machine.fullname" . }}
-  verbs: ["get", "list", "watch"]
+# Narrow GET to the exact Service
+  resourceNames:
+  - {{ include "virtual-machine.fullname" . }}
+  verbs: ["get"]
+
+# Separate rule for list/watch (no resourceNames filter possible)
+- apiGroups:
+  - ""
+  resources: ["services"]
+  verbs: ["list", "watch"]

This keeps observability while avoiding unnecessary data exposure.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- apiGroups:
- ""
resources:
- services
resourceNames:
- {{ include "virtual-machine.fullname" . }}
verbs: ["get", "list", "watch"]
- apiGroups:
- ""
resources:
- services
# Narrow GET to the exact Service
resourceNames:
- {{ include "virtual-machine.fullname" . }}
verbs: ["get"]
# Separate rule for list/watch (no resourceNames filter possible)
- apiGroups:
- ""
resources: ["services"]
verbs: ["list", "watch"]
🤖 Prompt for AI Agents
In packages/apps/virtual-machine/templates/dashboard-resourcemap.yaml around
lines 6 to 12, the RBAC rule uses resourceNames with list and watch verbs, which
Kubernetes ignores, granting broader access than intended. To fix this, split
the rule into two: one with get verb and resourceNames to restrict to the
specific service, and another with list and watch verbs without resourceNames to
allow observing all services in the namespace without overexposure.

Copy link
Member

Choose a reason for hiding this comment

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

List/watch works correctly with resource names. kubectl get resource resourcename -w watches for changes on a single resource. Listing a specific resource is possible too: kubectl get resource --field-selector .metadata.name=resourcename and the k8s api server correctly distinguishes such requests from their less specific kubectl get resource -w and kubectl get resource counterparts.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lllamnyp Thank you for the correction! You're absolutely right. I was mistaken about how Kubernetes RBAC handles resourceNames with list/watch verbs. The original RBAC rule in the code is actually correct and properly restricts access to the specific service resource.

I appreciate you taking the time to clarify this with concrete examples. The kubectl examples you provided clearly demonstrate that the API server does indeed respect resourceNames filtering for list/watch operations, contrary to my initial analysis.

🐰✨ learns something new about RBAC


✏️ Learnings added
Learnt from: lllamnyp
PR: cozystack/cozystack#1161
File: packages/apps/virtual-machine/templates/dashboard-resourcemap.yaml:6-12
Timestamp: 2025-07-10T12:14:27.174Z
Learning: Kubernetes RBAC rules with resourceNames work correctly for list/watch verbs. When resourceNames is specified in an RBAC rule, it properly restricts access to only those named resources, even for list and watch operations. Examples: `kubectl get resource resourcename -w` watches for changes on a single resource, and `kubectl get resource --field-selector .metadata.name=resourcename` lists a specific resource. The Kubernetes API server correctly distinguishes such requests from their less specific counterparts.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines +6 to +12
- apiGroups:
- ""
resources:
- services
resourceNames:
- {{ include "virtual-machine.fullname" . }}
verbs: ["get", "list", "watch"]
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 5, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Build-breaking template reference – wrong fullname helper.

{{ include "virtual-machine.fullname" . }} is not defined inside the vm-instance chart (unless the chart explicitly declares virtual-machine as a dependency). Helm will error with:

template: vm-instance/templates/dashboard-resourcemap.yaml:...: execution error at <include "virtual-machine.fullname" .>: template: no template "virtual-machine.fullname" defined

Fix:

-  resourceNames:
-  - {{ include "virtual-machine.fullname" . }}
+  resourceNames:
+  - {{ include "vm-instance.fullname" . }}

Apply the same separation of GET vs LIST/WATCH as noted for the VM chart to avoid over-privilege.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- apiGroups:
- ""
resources:
- services
resourceNames:
- {{ include "virtual-machine.fullname" . }}
verbs: ["get", "list", "watch"]
- apiGroups:
- ""
resources:
- services
resourceNames:
- {{ include "vm-instance.fullname" . }}
verbs: ["get", "list", "watch"]
🤖 Prompt for AI Agents
In packages/apps/vm-instance/templates/dashboard-resourcemap.yaml around lines 6
to 12, the template incorrectly references {{ include "virtual-machine.fullname"
. }}, which is undefined in the vm-instance chart and causes a build error.
Replace this with the correct fullname helper defined within the vm-instance
chart, typically {{ include "vm-instance.fullname" . }}, and separate the
permissions for GET versus LIST/WATCH verbs to follow least privilege principles
as done in the VM chart.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the file mentioned by the user
cat packages/apps/vm-instance/templates/vm.yaml

# Also check if there are any chart dependencies that might explain this
cat packages/apps/vm-instance/Chart.yaml

# Search for all occurrences of virtual-machine.fullname in the vm-instance chart
rg "virtual-machine\.fullname" packages/apps/vm-instance/

# Check if there are any _helpers.tpl files that might define this template
find packages/apps/vm-instance/ -name "_helpers.tpl" -exec cat {} \;

Length of output: 9416


@NickVolynkin Thank you for the correction! You're absolutely right. I can see now that the vm-instance chart actually defines the virtual-machine.fullname template in its own _helpers.tpl file:

{{- define "virtual-machine.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

This template is used consistently across multiple files in the vm-instance chart (vm.yaml, secret.yaml, service.yaml, etc.), so the usage in dashboard-resourcemap.yaml is intentional and correct.

My initial assessment was wrong - this is not a build-breaking error but rather a deliberate design choice where the vm-instance chart creates resources using the "virtual-machine" naming convention. The current implementation is working as intended.

I apologize for the incorrect suggestion and thank you for pointing out the broader context!

@klinch0 klinch0 changed the title vm and vmi add svc to dashboard bugfix: vm and vmi add svc to dashboard Jul 5, 2025
Signed-off-by: kklinch0 <kklinch0@gmail.com>
@klinch0 klinch0 force-pushed the vm-add-services-to-dashboard branch from 6b0ca9f to f251cba Compare July 8, 2025 07:02
Copy link
Member

@kvaps kvaps left a comment

Choose a reason for hiding this comment

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

LGTM

@kvaps kvaps merged commit 699d38d into main Jul 8, 2025
18 checks passed
@kvaps kvaps deleted the vm-add-services-to-dashboard branch July 8, 2025 08:49
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