Skip to content

fix(backups): move velero-configmap Role to velero chart - #2459

Merged
myasnikovdaniil merged 1 commit into
mainfrom
fix/backupstrategy-velero-rbac
Apr 23, 2026
Merged

myasnikovdaniil merged 1 commit into
mainfrom
fix/backupstrategy-velero-rbac

Conversation

@myasnikovdaniil

@myasnikovdaniil myasnikovdaniil commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

The backupstrategy-controller chart declared a Role and RoleBinding scoped to the cozy-velero namespace (for managing ResourceModifier ConfigMaps consumed by Velero Restore). Because cozystack.velero is an optional package, that namespace does not exist in bundles that do not enable velero — and backupstrategy-controller is a default package. Helm install aborted with:

namespaces "cozy-velero" not found

which blocked the entire cozy-backup-controller/backupstrategy-controller HelmRelease on any cluster where velero was not explicitly enabled (including the E2E environment).

This PR moves that Role/RoleBinding into the velero chart (packages/system/velero/templates/backupstrategy-controller-rbac.yaml), so the permission grant only exists when velero is actually installed — where it is useful. The RoleBinding subject points to the stable backupstrategy-controller ServiceAccount in cozy-backup-controller.

Release note

fix(backups): moved the velero-namespaced ResourceModifier ConfigMap Role and RoleBinding from the backupstrategy-controller chart into the velero chart. This unblocks installs of backupstrategy-controller on bundles that do not enable velero (previously the HelmRelease failed with `namespaces "cozy-velero" not found`).

Summary by CodeRabbit

  • Chores
    • Reorganized RBAC configuration for the backup strategy controller by consolidating namespace-scoped role definitions in the Velero chart template
    • Updated role bindings and permissions structure across system packages

The backupstrategy-controller chart declared a Role/RoleBinding in the
cozy-velero namespace for ResourceModifier ConfigMap management. Because
velero is an optional package, that namespace does not exist in bundles
without velero, so Helm install aborted with "namespaces \"cozy-velero\"
not found" and blocked the default install of backupstrategy-controller.

Move the Role and RoleBinding into the velero chart so they are created
only when velero is actually installed. The RoleBinding subject points
to the backupstrategy-controller ServiceAccount in its fixed namespace
(cozy-backup-controller).

Assisted-By: Claude <[email protected]>
Signed-off-by: Myasnikov Daniil <[email protected]>
@myasnikovdaniil myasnikovdaniil added the kind/backport Categorizes issue or PR as requiring a backport to the current release line label Apr 23, 2026
@dosubot dosubot Bot added the size/XS This PR changes 0-9 lines, ignoring generated files label Apr 23, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses a dependency issue in the Helm chart deployment process. By relocating namespace-specific RBAC resources to the optional Velero package, the backupstrategy-controller can now be successfully installed in environments where Velero is not present, preventing premature namespace validation failures.

Highlights

  • RBAC Refactoring: Moved the Role and RoleBinding for managing Velero ConfigMaps from the backupstrategy-controller chart to the velero chart.
  • Installation Fix: Resolved a Helm installation error where the controller failed to deploy due to a missing 'cozy-velero' namespace when Velero was not enabled.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment Gemini (@gemini-code-assist) Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes relocate RBAC configuration for the backupstrategy-controller's configmaps access from its own chart templates to the velero chart. A Role and RoleBinding granting configmaps management permissions are removed from the backupstrategy-controller chart and introduced as a new template in the velero chart, consolidating related RBAC definitions.

Changes

Cohort / File(s) Summary
Backupstrategy-Controller RBAC Removal
packages/system/backupstrategy-controller/templates/rbac-bind.yaml, packages/system/backupstrategy-controller/templates/rbac.yaml
Deleted the namespaced Role and RoleBinding that granted configmaps create/update/delete permissions. Updated comments to reflect external dependency on Velero chart for this configuration.
Velero Chart RBAC Addition
packages/system/velero/templates/backupstrategy-controller-rbac.yaml
Created new RBAC template containing a Role and RoleBinding that grant backupstrategy-controller ServiceAccount configmaps management permissions in the cozy-backup-controller namespace.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 The RBAC hops across the charts,
From backup-strategy to velero's parts,
Permissions consolidated, clean and bright,
A config shuffle done just right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: moving a Velero-related Role from the backupstrategy-controller chart to the velero chart, which is the core objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/backupstrategy-velero-rbac

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request moves the RBAC configuration for the backupstrategy-controller from its own chart to the velero chart. This ensures that the Role and RoleBinding required for managing ConfigMaps in the Velero namespace are only created when Velero is actually installed, preventing errors related to non-existent namespaces. Feedback was provided regarding the hardcoded namespace cozy-backup-controller in the new template, suggesting the use of a global value for better flexibility.

subjects:
- kind: ServiceAccount
name: backupstrategy-controller
namespace: cozy-backup-controller

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.

low

The namespace cozy-backup-controller is hardcoded here. While this aligns with the current project structure described in the PR, it assumes the backupstrategy-controller is always installed in this specific namespace. If the project allows for custom namespace naming or if the namespace is derived from a different release name, this binding will break. Consider using a global value if one exists for the backup controller's namespace.

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

🧹 Nitpick comments (1)
packages/system/velero/templates/backupstrategy-controller-rbac.yaml (1)

6-26: LGTM — RBAC correctly scoped to the velero install namespace.

The Role and RoleBinding omit metadata.namespace, so Helm will namespace them to the velero chart's release namespace (cozy-velero), which is where createResourceModifiersConfigMap/cleanup paths create and delete ConfigMaps (see internal/backupcontroller/velerostrategy_controller.go:902-934 and restorejob_controller.go:156-193). The RoleBinding subject correctly points at the controller's ServiceAccount in its own namespace (cozy-backup-controller) — cross-namespace subjects are valid for a RoleBinding. Moving this into the velero chart is the right fix for the "namespaces "cozy-velero" not found" install failure when velero is disabled.

Optional: consider setting metadata.namespace: cozy-velero explicitly on both objects to make the intent obvious to readers and decouple from the chart's install-time release namespace.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/system/velero/templates/backupstrategy-controller-rbac.yaml` around
lines 6 - 26, The Role and RoleBinding currently lack metadata.namespace so they
rely on the Helm release namespace and caused "namespaces \"cozy-velero\" not
found"; update both the Role (metadata.name:
backups.cozystack.io:strategy-controller:velero-configmaps) and the RoleBinding
(same name, subject ServiceAccount name: backupstrategy-controller, subject
namespace: cozy-backup-controller) to include metadata.namespace: cozy-velero so
the RBAC objects are explicitly created in the velero namespace where
createResourceModifiersConfigMap / restorejob cleanup operate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/system/velero/templates/backupstrategy-controller-rbac.yaml`:
- Around line 6-26: The Role and RoleBinding currently lack metadata.namespace
so they rely on the Helm release namespace and caused "namespaces
\"cozy-velero\" not found"; update both the Role (metadata.name:
backups.cozystack.io:strategy-controller:velero-configmaps) and the RoleBinding
(same name, subject ServiceAccount name: backupstrategy-controller, subject
namespace: cozy-backup-controller) to include metadata.namespace: cozy-velero so
the RBAC objects are explicitly created in the velero namespace where
createResourceModifiersConfigMap / restorejob cleanup operate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 968e41d1-3366-4d27-94f4-b6758b055a37

📥 Commits

Reviewing files that changed from the base of the PR and between 5c89a2c and c447725.

📒 Files selected for processing (3)
  • packages/system/backupstrategy-controller/templates/rbac-bind.yaml
  • packages/system/backupstrategy-controller/templates/rbac.yaml
  • packages/system/velero/templates/backupstrategy-controller-rbac.yaml
💤 Files with no reviewable changes (1)
  • packages/system/backupstrategy-controller/templates/rbac-bind.yaml

@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

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 23, 2026
@myasnikovdaniil
myasnikovdaniil merged commit f505c4d into main Apr 23, 2026
13 checks passed
@myasnikovdaniil
myasnikovdaniil deleted the fix/backupstrategy-velero-rbac branch April 23, 2026 06:57
@github-actions

Copy link
Copy Markdown

Backport failed for release-1.2, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-1.2
git worktree add -d .worktree/backport-2459-to-release-1.2 origin/release-1.2
cd .worktree/backport-2459-to-release-1.2
git switch --create backport-2459-to-release-1.2
git cherry-pick -x c4477259c7e914accaf45238a2b2b591451672a9

myasnikovdaniil added a commit that referenced this pull request Apr 23, 2026
…lero chart (#2467)

## Summary

Backport of #2459 to release-1.3.

Fixes installation failure of `backupstrategy-controller` in bundles
without velero.

## Changes

- Move velero-configmap Role/RoleBinding from backupstrategy-controller
chart to velero chart
- Prevents "namespaces \"cozy-velero\" not found" error when velero is
not installed

## Original Commit

Cherry-pick of c447725 from main.
myasnikovdaniil added a commit that referenced this pull request Apr 29, 2026
The AI-generated v1.3.1 changelog (#2480) was generated from
git log v1.3.0..main rather than git log v1.3.0..v1.3.1, because
the workflow checked out main while the v1.3.1 tag points to
release-1.3. As a result the changelog included:

- 8 PRs that were merged to main but never shipped in v1.3.1
- 6 backport PRs that were merged to release-1.3 *after* v1.3.1
  was tagged
- Both originals and their backports as separate duplicate entries
- A 2024 PR (#435) that has nothing to do with this range
- Generic "Documentation updates" placeholders for website entries
- Title duplicated as both the bold label and the description
  (`* **fix(...): X**: fix(...): X (...)`)
- The cozystack-ci bot listed as a human contributor

The actual v1.3.1 release range (v1.3.0..v1.3.1) contains exactly
one user-facing change:

  41bcb0b [Backport release-1.3] fix(backups): move
           velero-configmap Role to velero chart (#2467)

which is the backport of #2459 (myasnikovdaniil) shipped via
#2467 (IvanHunters). This commit replaces the contents of
docs/changelogs/v1.3.1.md with that one entry, the matching
two-person contributors list, and the standard footer.

The workflow + docs fixes that prevent this regression for future
patch releases will land in a separate PR against main.

Signed-off-by: Myasnikov Daniil <[email protected]>
myasnikovdaniil added a commit that referenced this pull request Apr 29, 2026
The auto-generated changelog only listed #2459/#2467 (velero-configmap
Role move). Five additional PRs were backported and merged into
release-1.3 between then and the v1.3.1 tag (2026-04-28):

- #2471/#2524 - fix(api): IDOR in TenantNamespace Get/Watch
- #2496/#2505 - feat(linstor): linstor-csi v1.10.6 (Protocol-C dual-attach)
- #2462/#2511 - fix(etcd): remove destructive post-upgrade hook
- #2421/#2491 - fix(kamaji): memory limits + startup probe
- #2498/#2518 - build(linstor): wire linstor-gui into root build target

Update the release date to match the actual tag (2026-04-28), rewrite
the intro paragraph, and add @kvaps to contributors.

Signed-off-by: Myasnikov Daniil <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/backport Categorizes issue or PR as requiring a backport to the current release line lgtm This PR has been approved by a maintainer size/XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants